[llvm] r354068 - [lit] Set --single-process for single tests and --threads=1

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 14 14:30:07 PST 2019


Author: yln
Date: Thu Feb 14 14:30:07 2019
New Revision: 354068

URL: http://llvm.org/viewvc/llvm-project?rev=354068&view=rev
Log:
[lit] Set --single-process for single tests and --threads=1

Summary:
Automatically upgrade debugging experience (single process, no thread
pool) when:
  1) we only run a single test
  2) user specifies `-j1`

Details:
Fix `--max-failures` in single process mode. Option did not have an
effect in single process mode.

Add display feedback for single process mode. Adapted test.

Improve argument checking (require positive integers).

`--single-process` is now essentially an alias for `-j1`. Should we
remove it?

Reviewers: rnk

Differential Revision: https://reviews.llvm.org/D58249

Modified:
    llvm/trunk/utils/lit/lit/LitConfig.py
    llvm/trunk/utils/lit/lit/discovery.py
    llvm/trunk/utils/lit/lit/main.py
    llvm/trunk/utils/lit/lit/run.py
    llvm/trunk/utils/lit/tests/max-failures.py
    llvm/trunk/utils/lit/tests/unit/TestRunner.py

Modified: llvm/trunk/utils/lit/lit/LitConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/LitConfig.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/LitConfig.py (original)
+++ llvm/trunk/utils/lit/lit/LitConfig.py Thu Feb 14 14:30:07 2019
@@ -21,7 +21,7 @@ class LitConfig(object):
 
     def __init__(self, progname, path, quiet,
                  useValgrind, valgrindLeakCheck, valgrindArgs,
-                 noExecute, debug, isWindows, singleProcess,
+                 noExecute, debug, isWindows,
                  params, config_prefix = None,
                  maxIndividualTestTime = 0,
                  maxFailures = None,
@@ -37,7 +37,6 @@ class LitConfig(object):
         self.valgrindUserArgs = list(valgrindArgs)
         self.noExecute = noExecute
         self.debug = debug
-        self.singleProcess = singleProcess
         self.isWindows = bool(isWindows)
         self.params = dict(params)
         self.bashPath = None

Modified: llvm/trunk/utils/lit/lit/discovery.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/discovery.py (original)
+++ llvm/trunk/utils/lit/lit/discovery.py Thu Feb 14 14:30:07 2019
@@ -262,7 +262,6 @@ def load_test_suite(inputs):
                                     useValgrind = False,
                                     valgrindLeakCheck = False,
                                     valgrindArgs = [],
-                                    singleProcess=False,
                                     noExecute = False,
                                     debug = False,
                                     isWindows = (platform.system()=='Windows'),

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Thu Feb 14 14:30:07 2019
@@ -336,11 +336,11 @@ def main_with_tmp(builtinParameters):
     if not args:
         parser.error('No inputs specified')
 
-    if opts.numThreads is None:
-        opts.numThreads = lit.util.detectCPUs()
+    if opts.numThreads is not None and opts.numThreads <= 0:
+        parser.error("Option '--threads' or '-j' requires positive integer")
 
-    if opts.maxFailures == 0:
-        parser.error("Setting --max-failures to 0 does not have any effect.")
+    if opts.maxFailures is not None and opts.maxFailures <= 0:
+        parser.error("Option '--max-failures' requires positive integer")
 
     if opts.echoAllCommands:
         opts.showOutput = True
@@ -374,7 +374,6 @@ def main_with_tmp(builtinParameters):
         valgrindLeakCheck = opts.valgrindLeakCheck,
         valgrindArgs = opts.valgrindArgs,
         noExecute = opts.noExecute,
-        singleProcess = opts.singleProcess,
         debug = opts.debug,
         isWindows = isWindows,
         params = userParams,
@@ -481,6 +480,12 @@ def main_with_tmp(builtinParameters):
     if opts.maxTests is not None:
         run.tests = run.tests[:opts.maxTests]
 
+    # Determine number of workers to use.
+    if opts.singleProcess:
+        opts.numThreads = 1
+    elif opts.numThreads is None:
+        opts.numThreads = lit.util.detectCPUs()
+
     # Don't create more threads than tests.
     opts.numThreads = min(len(run.tests), opts.numThreads)
 
@@ -506,11 +511,9 @@ def main_with_tmp(builtinParameters):
     except:
         pass
 
-    extra = ''
-    if len(run.tests) != numTotalTests:
-        extra = ' of %d' % numTotalTests
-    header = '-- Testing: %d%s tests, %d threads --'%(len(run.tests), extra,
-                                                      opts.numThreads)
+    extra = (' of %d' % numTotalTests) if (len(run.tests) != numTotalTests) else ''
+    threads = 'single process' if (opts.numThreads == 1) else ('%d threads' % opts.numThreads)
+    header = '-- Testing: %d%s tests, %s --' % (len(run.tests), extra, threads)
     progressBar = None
     if not opts.quiet:
         if opts.succinct and opts.useProgressBar:

Modified: llvm/trunk/utils/lit/lit/run.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/run.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/run.py (original)
+++ llvm/trunk/utils/lit/lit/run.py Thu Feb 14 14:30:07 2019
@@ -133,7 +133,7 @@ class Run(object):
         be given an UNRESOLVED result.
         """
         # Don't do anything if we aren't going to run any tests.
-        if not self.tests or jobs == 0:
+        if not self.tests:
             return
 
         # Save the display object on the runner so that we can update it from
@@ -142,12 +142,14 @@ class Run(object):
 
         self.failure_count = 0
         self.hit_max_failures = False
-        if self.lit_config.singleProcess:
+        if jobs == 1:
             global child_lit_config
             child_lit_config = self.lit_config
             for test_index, test in enumerate(self.tests):
                 result = worker_run_one_test(test_index, test)
                 self.consume_test_result(result)
+                if self.hit_max_failures:
+                    break
         else:
             self.execute_tests_in_pool(jobs, max_time)
 

Modified: llvm/trunk/utils/lit/tests/max-failures.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/max-failures.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/max-failures.py (original)
+++ llvm/trunk/utils/lit/tests/max-failures.py Thu Feb 14 14:30:07 2019
@@ -11,4 +11,4 @@
 # CHECK: Failing Tests (27)
 # CHECK: Failing Tests (1)
 # CHECK: Failing Tests (2)
-# CHECK: error: Setting --max-failures to 0 does not have any effect.
+# CHECK: error: Option '--max-failures' requires positive integer

Modified: llvm/trunk/utils/lit/tests/unit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/unit/TestRunner.py?rev=354068&r1=354067&r2=354068&view=diff
==============================================================================
--- llvm/trunk/utils/lit/tests/unit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/tests/unit/TestRunner.py Thu Feb 14 14:30:07 2019
@@ -29,7 +29,6 @@ class TestIntegratedTestKeywordParser(un
                                              quiet=False,
                                              useValgrind=False,
                                              valgrindLeakCheck=False,
-                                             singleProcess=False,
                                              valgrindArgs=[],
                                              noExecute=False,
                                              debug=False,




More information about the llvm-commits mailing list