sanitycheck: add option to print duplicate identifiers
A new option to list all duplicate identifiers. This now will output the following: sanitycheck --list-test-duplicates Tests with duplicate identifiers: - arch.interrupt - tests/arch/arm/arm_interrupt/arch.interrupt - tests/kernel/interrupt/arch.interrupt - system.settings.nffs.config_empty_lookups - tests/subsys/settings/nffs/base64/system.settings.nffs - tests/subsys/settings/nffs/raw/system.settings.nffs - system.settings.nffs.config_insert - tests/subsys/settings/nffs/base64/system.settings.nffs - tests/subsys/settings/nffs/raw/system.settings.nffs - system.settings.nffs.config_getset_unknown - tests/subsys/settings/nffs/base64/system.settings.nffs - tests/subsys/settings/nffs/raw/system.settings.nffs - system.settings.nffs.config_getset_int - tests/subsys/settings/nffs/base64/system.settings.nffs - tests/subsys/settings/nffs/raw/system.settings.nffs .. .. .. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
eabaa7f8bf
commit
19ca7833e5
1 changed files with 38 additions and 10 deletions
|
@ -3020,6 +3020,15 @@ class TestSuite:
|
|||
cw.writerow(rowdict)
|
||||
|
||||
|
||||
def get_testcase(self, identifier):
|
||||
results = []
|
||||
for _, tc in self.testcases.items():
|
||||
for case in tc.cases:
|
||||
if case == identifier:
|
||||
results.append(tc)
|
||||
return results
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -3157,6 +3166,10 @@ Artificially long but functional example:
|
|||
and net.socket.fd_set belong to different directories.
|
||||
""")
|
||||
|
||||
case_select.add_argument("--list-test-duplicates", action="store_true",
|
||||
help="""List tests with duplicate identifiers.
|
||||
""")
|
||||
|
||||
parser.add_argument("--export-tests", action="store",
|
||||
metavar="FILENAME",
|
||||
help="Export tests case meta-data to a file in CSV format.")
|
||||
|
@ -3570,14 +3583,17 @@ def export_tests(filename, tests):
|
|||
cw = csv.DictWriter(csvfile, fieldnames, lineterminator=os.linesep)
|
||||
for test in tests:
|
||||
data = test.split(".")
|
||||
subsec = " ".join(data[1].split("_")).title()
|
||||
rowdict = {
|
||||
"section": data[0].capitalize(),
|
||||
"subsection": subsec,
|
||||
"title": test,
|
||||
"reference": test
|
||||
}
|
||||
cw.writerow(rowdict)
|
||||
if len(data) > 1:
|
||||
subsec = " ".join(data[1].split("_")).title()
|
||||
rowdict = {
|
||||
"section": data[0].capitalize(),
|
||||
"subsection": subsec,
|
||||
"title": test,
|
||||
"reference": test
|
||||
}
|
||||
cw.writerow(rowdict)
|
||||
else:
|
||||
info("{} can't be exported".format(test))
|
||||
|
||||
|
||||
def native_and_unit_first(a, b):
|
||||
|
@ -3750,7 +3766,6 @@ def main():
|
|||
platform is allowed""")
|
||||
|
||||
|
||||
|
||||
if suite.load_errors:
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -3775,10 +3790,23 @@ def main():
|
|||
if options.test:
|
||||
run_individual_tests = options.test
|
||||
|
||||
if options.list_tests or options.sub_test:
|
||||
if options.list_tests or options.list_test_duplicates or options.sub_test:
|
||||
cnt = 0
|
||||
all_tests = suite.get_all_tests()
|
||||
|
||||
if options.list_test_duplicates:
|
||||
import collections
|
||||
dupes = [item for item, count in collections.Counter(all_tests).items() if count > 1]
|
||||
if dupes:
|
||||
print("Tests with duplicate identifiers:")
|
||||
for dupe in dupes:
|
||||
print("- {}".format(dupe))
|
||||
for dc in suite.get_testcase(dupe):
|
||||
print(" - {}".format(dc))
|
||||
else:
|
||||
print("No duplicates found.")
|
||||
return
|
||||
|
||||
if options.sub_test:
|
||||
if run_individual_tests:
|
||||
info("Running the following tests:")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue