提交 e3e2cf33 编写于 作者: C Cleber Rosa

avocado list command: also show tag statistics

Just like `avocado list` presents the statistics for the test types,
it may be useful to also list the number of tests that have a
particular tag.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 e9ad7b6d
......@@ -57,6 +57,7 @@ class TestLister(object):
decorator_mapping = loader.loader.get_decorator_mapping()
stats = {}
tag_stats = {}
for value in type_label_mapping.values():
stats[value.lower()] = 0
......@@ -83,14 +84,19 @@ class TestLister(object):
tags = params['tags']
else:
tags = set()
for tag in tags:
if tag not in tag_stats:
tag_stats[tag] = 1
else:
tag_stats[tag] += 1
tags = ",".join(tags)
test_matrix.append((type_label, id_label, tags))
else:
test_matrix.append((type_label, id_label))
return test_matrix, stats
return test_matrix, stats, tag_stats
def _display(self, test_matrix, stats):
def _display(self, test_matrix, stats, tag_stats):
header = None
if self.args.verbose:
header = (output.TERM_SUPPORT.header_str('Type'),
......@@ -101,10 +107,19 @@ class TestLister(object):
LOG_UI.debug(line)
if self.args.verbose:
LOG_UI.debug("")
LOG_UI.info("")
LOG_UI.info("TEST TYPES SUMMARY")
LOG_UI.info("==================")
for key in sorted(stats):
LOG_UI.info("%s: %s", key.upper(), stats[key])
if tag_stats:
LOG_UI.info("")
LOG_UI.info("TEST TAGS SUMMARY")
LOG_UI.info("=================")
for key in sorted(tag_stats):
LOG_UI.info("%s: %s", key, tag_stats[key])
def _list(self):
self._extra_listing()
test_suite = self._get_test_suite(self.args.reference)
......@@ -113,8 +128,8 @@ class TestLister(object):
test_suite,
self.args.filter_by_tags,
self.args.filter_by_tags_include_empty)
test_matrix, stats = self._get_test_matrix(test_suite)
self._display(test_matrix, stats)
test_matrix, stats, tag_stats = self._get_test_matrix(test_suite)
self._display(test_matrix, stats, tag_stats)
def list(self):
try:
......
......@@ -268,6 +268,8 @@ display files that were found by Avocado, but are not considered Avocado tests::
NOT_A_TEST examples/gdb-prerun-scripts/README
NOT_A_TEST examples/gdb-prerun-scripts/pass-sigusr1
TEST TYPES SUMMARY
==================
SIMPLE: 0
INSTRUMENTED: 0
MISSING: 0
......
......@@ -1186,6 +1186,8 @@ If you try to list the tests in that file, this is what you'll get::
Type Test Tag(s)
NOT_A_TEST mytest.py
TEST TYPES SUMMARY
==================
ACCESS_DENIED: 0
BROKEN_SYMLINK: 0
EXTERNAL: 0
......@@ -1224,6 +1226,8 @@ Now, trying to list the tests on the ``mytest.py`` file again::
INSTRUMENTED mytest.py:MyTest.test1
INSTRUMENTED mytest.py:MyTest.test2
TEST TYPES SUMMARY
==================
ACCESS_DENIED: 0
BROKEN_SYMLINK: 0
EXTERNAL: 0
......
......@@ -608,6 +608,8 @@ are not avocado tests, along with summary information::
NOT_A_TEST examples/gdb-prerun-scripts/README
NOT_A_TEST examples/gdb-prerun-scripts/pass-sigusr1
TEST TYPES SUMMARY
==================
SIMPLE: 0
INSTRUMENTED: 0
MISSING: 0
......
......@@ -934,6 +934,8 @@ class PluginsTest(AbsPluginsTest, unittest.TestCase):
% (exit_codes.AVOCADO_ALL_OK, result))
exp = ("Type Test Tag(s)\n"
"MISSING this-wont-be-matched \n\n"
"TEST TYPES SUMMARY\n"
"==================\n"
"EXTERNAL: 0\n"
"MISSING: 1\n")
self.assertEqual(exp, result.stdout, "Stdout mismatch:\n%s\n\n%s"
......@@ -957,6 +959,10 @@ class PluginsTest(AbsPluginsTest, unittest.TestCase):
full_test_name = "%s:MyTest.test" % test
self.assertEquals("INSTRUMENTED %s BIG_TAG_NAME" % full_test_name,
stdout_lines[1])
self.assertIn("TEST TYPES SUMMARY", stdout_lines)
self.assertIn("INSTRUMENTED: 1", stdout_lines)
self.assertIn("TEST TAGS SUMMARY", stdout_lines)
self.assertEquals("BIG_TAG_NAME: 1", stdout_lines[-1])
def test_plugin_list(self):
os.chdir(basedir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册