diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py --- a/llvm/utils/lit/lit/LitConfig.py +++ b/llvm/utils/lit/lit/LitConfig.py @@ -21,7 +21,7 @@ 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 @@ self.valgrindUserArgs = list(valgrindArgs) self.noExecute = noExecute self.debug = debug - self.singleProcess = singleProcess self.isWindows = bool(isWindows) self.params = dict(params) self.bashPath = None diff --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py --- a/llvm/utils/lit/lit/discovery.py +++ b/llvm/utils/lit/lit/discovery.py @@ -262,7 +262,6 @@ useValgrind = False, valgrindLeakCheck = False, valgrindArgs = [], - singleProcess=False, noExecute = False, debug = False, isWindows = (platform.system()=='Windows'), diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -336,11 +336,11 @@ 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 @@ valgrindLeakCheck = opts.valgrindLeakCheck, valgrindArgs = opts.valgrindArgs, noExecute = opts.noExecute, - singleProcess = opts.singleProcess, debug = opts.debug, isWindows = isWindows, params = userParams, @@ -481,6 +480,12 @@ if opts.maxTests is not None: run.tests = run.tests[:opts.maxTests] + # Determine number of threads 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 @@ 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: diff --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py --- a/llvm/utils/lit/lit/run.py +++ b/llvm/utils/lit/lit/run.py @@ -113,7 +113,7 @@ 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 @@ -122,10 +122,12 @@ self.failure_count = 0 self.hit_max_failures = False - if self.lit_config.singleProcess: + if jobs == 1: for test_index, test in enumerate(self.tests): lit.worker._execute_test(test, self.lit_config) self.consume_test_result((test_index, test)) + if self.hit_max_failures: + break else: self.execute_tests_in_pool(jobs, max_time) diff --git a/llvm/utils/lit/lit/worker.py b/llvm/utils/lit/lit/worker.py --- a/llvm/utils/lit/lit/worker.py +++ b/llvm/utils/lit/lit/worker.py @@ -1,5 +1,5 @@ # The code in this file runs in a separate worker process. -# Exception: if lit_config.singleProcess then _execute_test is called directly. +# Exception: in single process mode _execute_test is called directly. import time import traceback diff --git a/llvm/utils/lit/tests/max-failures.py b/llvm/utils/lit/tests/max-failures.py --- a/llvm/utils/lit/tests/max-failures.py +++ b/llvm/utils/lit/tests/max-failures.py @@ -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 diff --git a/llvm/utils/lit/tests/unit/TestRunner.py b/llvm/utils/lit/tests/unit/TestRunner.py --- a/llvm/utils/lit/tests/unit/TestRunner.py +++ b/llvm/utils/lit/tests/unit/TestRunner.py @@ -29,7 +29,6 @@ quiet=False, useValgrind=False, valgrindLeakCheck=False, - singleProcess=False, valgrindArgs=[], noExecute=False, debug=False,