[LNT] r263443 - [cmake] Fix --only-test handling

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 09:11:18 PDT 2016


Author: jamesm
Date: Mon Mar 14 11:11:17 2016
New Revision: 263443

URL: http://llvm.org/viewvc/llvm-project?rev=263443&view=rev
Log:
[cmake] Fix --only-test handling

Handling of --only-test was patchy, and expected it to be a directory. This caused problems when trying to reproduce a SingleSource test.

Now, we parse the path and assert that it either points to a directory or one level under a directory (where the basename is expected to be the test name, so is passed through to make).

Modified:
    lnt/trunk/lnt/tests/test_suite.py

Modified: lnt/trunk/lnt/tests/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/test_suite.py?rev=263443&r1=263442&r2=263443&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/test_suite.py (original)
+++ lnt/trunk/lnt/tests/test_suite.py Mon Mar 14 11:11:17 2016
@@ -233,6 +233,21 @@ class TestSuiteTest(BuiltinTest):
             if not isexecfile(split[0]):
                 parser.error("Run under wrapper not found (looked for %s)" %
                              opts.run_under)
+
+        if opts.only_test:
+            # --only-test can either point to a particular test or a directory.
+            # Therefore, test_suite_root + opts.only_test or
+            # test_suite_root + dirname(opts.only_test) must be a directory.
+            path = os.path.join(self.test_suite_root, opts.only_test)
+            parent_path = os.path.dirname(path)
+
+            if os.path.isdir(path):
+                opts.only_test = (path, None)
+            elif os.path.isdir(parent_path):
+                opts.only_test = (parent_path, os.path.basename(path))
+            else:
+                parser.error("--only-test argument not understood (must be a " +
+                             " test or directory name)")
                 
         opts.cppflags = ' '.join(opts.cppflags)
         opts.cflags = ' '.join(opts.cflags)
@@ -335,7 +350,7 @@ class TestSuiteTest(BuiltinTest):
 
         subdir = path
         if self.opts.only_test:
-            components = [path] + self.opts.only_test.split('/')
+            components = [path] + self.opts.only_test[0]
             subdir = os.path.join(*components)
 
         self._check_call([make_cmd, 'clean'],
@@ -394,14 +409,18 @@ class TestSuiteTest(BuiltinTest):
         make_cmd = self.opts.make
         
         subdir = path
+        target = 'all'
         if self.opts.only_test:
-            components = [path] + self.opts.only_test.split('/')
+            components = [path] + self.opts.only_test[0]
+            if self.opts.only_test[1]:
+                target = self.opts.only_test[1]:
             subdir = os.path.join(*components)
 
         note('Building...')
         self._check_call([make_cmd,
                           '-j', str(self._build_threads()),
-                          "VERBOSE=1"],
+                          "VERBOSE=1",
+                          target],
                          cwd=subdir)
 
     def _lit(self, path, test):
@@ -415,7 +434,7 @@ class TestSuiteTest(BuiltinTest):
         
         subdir = path
         if self.opts.only_test:
-            components = [path] + self.opts.only_test.split('/')
+            components = [path] + self.opts.only_test[0]
             subdir = os.path.join(*components)
 
         extra_args = []




More information about the llvm-commits mailing list