<div dir="ltr">Comments:<div><br></div><div style>1. I have a marginal preference for yielding from the getTestsInExecutable iterator instead of collecting in a list.</div><div style><br></div><div style>2. I am having trouble understanding what the code is trying to do, but I now that I am reading the current version I don't understand it either, so that is probably not a problem with the patch. If it fixes a problem with compiler-rt and you tested with LLVM's unit tests then I am fine with it.</div>
<div style><br></div><div style> - Daniel</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 6:41 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi chapuni,<br>
<br>
This patch makes llvm-lit test discoverer work correctly<br>
if "test_sub_dir" attribute contains a "." subdirectory. This is<br>
necessary to fix compiler-rt unittests after r173617.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D337" target="_blank">http://llvm-reviews.chandlerc.com/D337</a><br>
<br>
Files:<br>
  utils/lit/lit/TestFormats.py<br>
<br>
Index: utils/lit/lit/TestFormats.py<br>
===================================================================<br>
--- utils/lit/lit/TestFormats.py<br>
+++ utils/lit/lit/TestFormats.py<br>
@@ -54,28 +54,37 @@<br>
             else:<br>
                 yield ''.join(nested_tests) + ln<br>
<br>
+    def getTestsInExecutable(self, testSuite, path_in_suite, execpath,<br>
+                             litConfig, localConfig):<br>
+        if not execpath.endswith(self.test_suffix):<br>
+            return<br>
+        (dirname, basename) = os.path.split(execpath)<br>
+        # Discover the tests in this executable.<br>
+        for testname in self.getGTestTests(execpath, litConfig, localConfig):<br>
+            testPath = path_in_suite + (dirname, basename, testname)<br>
+            yield Test.Test(testSuite, testPath, localConfig)<br>
+<br>
     def getTestsInDirectory(self, testSuite, path_in_suite,<br>
                             litConfig, localConfig):<br>
         source_path = testSuite.getSourcePath(path_in_suite)<br>
+        all_tests = []<br>
         for filename in os.listdir(source_path):<br>
-            # Check for the one subdirectory (build directory) tests will be in.<br>
-            if not '.' in self.test_sub_dir:<br>
+            filepath = os.path.join(source_path, filename)<br>
+            if os.path.isdir(filepath):<br>
+                # Iterate over executables in a directory.<br>
                 if not os.path.normcase(filename) in self.test_sub_dir:<br>
                     continue<br>
-<br>
-            filepath = os.path.join(source_path, filename)<br>
-            if not os.path.isdir(filepath):<br>
-                continue<br>
-<br>
-            for subfilename in os.listdir(filepath):<br>
-                if subfilename.endswith(self.test_suffix):<br>
+                for subfilename in os.listdir(filepath):<br>
                     execpath = os.path.join(filepath, subfilename)<br>
-<br>
-                    # Discover the tests in this executable.<br>
-                    for name in self.getGTestTests(execpath, litConfig,<br>
-                                                   localConfig):<br>
-                        testPath = path_in_suite + (filename, subfilename, name)<br>
-                        yield Test.Test(testSuite, testPath, localConfig)<br>
+                    all_tests += self.getTestsInExecutable(<br>
+                                    testSuite, path_in_suite, execpath,<br>
+                                    litConfig, localConfig)<br>
+            elif ('.' in self.test_sub_dir):<br>
+                all_tests += self.getTestsInExecutable(<br>
+                    testSuite, path_in_suite, filepath,<br>
+                    litConfig, localConfig)<br>
+        for test in all_tests:<br>
+            yield test<br>
<br>
     def execute(self, test, litConfig):<br>
         testPath,testName = os.path.split(test.getSourcePath())<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>