llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/137681.diff


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+18-19) 


``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 7cc8f2985043e..e9b5985e03c11 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -619,12 +619,12 @@ def visit_file(dir, name):
     if configuration.regexp:
         if not re.search(configuration.regexp, name):
             # We didn't match the regex, we're done.
-            return
+            return False
 
     if configuration.skip_tests:
         for file_regexp in configuration.skip_tests:
             if re.search(file_regexp, name):
-                return
+                return False
 
     # We found a match for our test.  Add it to the suite.
 
@@ -659,22 +659,20 @@ def iter_filters():
                     if check(value, parts):
                         yield key + "." + filterspec
 
-    filtered = False
-    for filterspec in iter_filters():
-        filtered = True
-        print("adding filter spec %s to module %s" % (filterspec, 
repr(module)))
-        tests = unittest.defaultTestLoader.loadTestsFromName(filterspec, 
module)
-        configuration.suite.addTests(tests)
-
-    # Forgo this module if the (base, filterspec) combo is invalid
-    if configuration.filters and not filtered:
-        return
+    if configuration.filters:
+        filtered = False
+        for filterspec in iter_filters():
+            filtered = True
+            print(f"adding filter spec {filterspec} to module {module!r}")
+            tests = unittest.defaultTestLoader.loadTestsFromName(filterspec, 
module)
+            configuration.suite.addTests(tests)
+        return filtered
 
-    if not filtered:
-        # Add the entire file's worth of tests since we're not filtered.
-        # Also the fail-over case when the filterspec branch
-        # (base, filterspec) combo doesn't make sense.
-        
configuration.suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))
+    # Add the entire file's worth of tests since we're not filtered.
+    # Also the fail-over case when the filterspec branch
+    # (base, filterspec) combo doesn't make sense.
+    
configuration.suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))
+    return True
 
 
 def visit(prefix, dir, names):
@@ -699,10 +697,11 @@ def visit(prefix, dir, names):
         # to disambiguate these, so we shouldn't need this constraint.
         if name in configuration.all_tests:
             raise Exception("Found multiple tests with the name %s" % name)
-        configuration.all_tests.add(name)
 
         # Run the relevant tests in the python file.
-        visit_file(dir, name)
+        if visit_file(dir, name):
+            # Only add to all_tests if the test wasn't skipped/filtered.
+            configuration.all_tests.add(name)
 
 
 # ======================================== #

``````````

</details>


https://github.com/llvm/llvm-project/pull/137681
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to