Skip to content

Commit 1caa020

Browse files
committed
[lldb] Make duplicate test names a conditional exception
When two or more tests have the same name, dotest will raise an exception. However, when using a test name pattern (`-p`) which does not match the duplicate test names, there seems to be no reason to prevent the user from running they wish to run. This changes the exception to be raised only when a pattern matches duplicate tests.
1 parent 4546da0 commit 1caa020

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,12 @@ def visit_file(dir, name):
619619
if configuration.regexp:
620620
if not re.search(configuration.regexp, name):
621621
# We didn't match the regex, we're done.
622-
return
622+
return False
623623

624624
if configuration.skip_tests:
625625
for file_regexp in configuration.skip_tests:
626626
if re.search(file_regexp, name):
627-
return
627+
return False
628628

629629
# We found a match for our test. Add it to the suite.
630630

@@ -659,22 +659,20 @@ def iter_filters():
659659
if check(value, parts):
660660
yield key + "." + filterspec
661661

662-
filtered = False
663-
for filterspec in iter_filters():
664-
filtered = True
665-
print("adding filter spec %s to module %s" % (filterspec, repr(module)))
666-
tests = unittest.defaultTestLoader.loadTestsFromName(filterspec, module)
667-
configuration.suite.addTests(tests)
668-
669-
# Forgo this module if the (base, filterspec) combo is invalid
670-
if configuration.filters and not filtered:
671-
return
662+
if configuration.filters:
663+
filtered = False
664+
for filterspec in iter_filters():
665+
filtered = True
666+
print(f"adding filter spec {filterspec} to module {module!r}")
667+
tests = unittest.defaultTestLoader.loadTestsFromName(filterspec, module)
668+
configuration.suite.addTests(tests)
669+
return filtered
672670

673-
if not filtered:
674-
# Add the entire file's worth of tests since we're not filtered.
675-
# Also the fail-over case when the filterspec branch
676-
# (base, filterspec) combo doesn't make sense.
677-
configuration.suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))
671+
# Add the entire file's worth of tests since we're not filtered.
672+
# Also the fail-over case when the filterspec branch
673+
# (base, filterspec) combo doesn't make sense.
674+
configuration.suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))
675+
return True
678676

679677

680678
def visit(prefix, dir, names):
@@ -699,10 +697,11 @@ def visit(prefix, dir, names):
699697
# to disambiguate these, so we shouldn't need this constraint.
700698
if name in configuration.all_tests:
701699
raise Exception("Found multiple tests with the name %s" % name)
702-
configuration.all_tests.add(name)
703700

704701
# Run the relevant tests in the python file.
705-
visit_file(dir, name)
702+
if visit_file(dir, name):
703+
# Only add to all_tests if the test wasn't skipped/filtered.
704+
configuration.all_tests.add(name)
706705

707706

708707
# ======================================== #

0 commit comments

Comments
 (0)