Skip to content

Commit 96adb78

Browse files
committed
[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 llvm-svn: 354068
1 parent 9e5e868 commit 96adb78

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

llvm/utils/lit/lit/LitConfig.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LitConfig(object):
2121

2222
def __init__(self, progname, path, quiet,
2323
useValgrind, valgrindLeakCheck, valgrindArgs,
24-
noExecute, debug, isWindows, singleProcess,
24+
noExecute, debug, isWindows,
2525
params, config_prefix = None,
2626
maxIndividualTestTime = 0,
2727
maxFailures = None,
@@ -37,7 +37,6 @@ def __init__(self, progname, path, quiet,
3737
self.valgrindUserArgs = list(valgrindArgs)
3838
self.noExecute = noExecute
3939
self.debug = debug
40-
self.singleProcess = singleProcess
4140
self.isWindows = bool(isWindows)
4241
self.params = dict(params)
4342
self.bashPath = None

llvm/utils/lit/lit/discovery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ def load_test_suite(inputs):
262262
useValgrind = False,
263263
valgrindLeakCheck = False,
264264
valgrindArgs = [],
265-
singleProcess=False,
266265
noExecute = False,
267266
debug = False,
268267
isWindows = (platform.system()=='Windows'),

llvm/utils/lit/lit/main.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ def main_with_tmp(builtinParameters):
336336
if not args:
337337
parser.error('No inputs specified')
338338

339-
if opts.numThreads is None:
340-
opts.numThreads = lit.util.detectCPUs()
339+
if opts.numThreads is not None and opts.numThreads <= 0:
340+
parser.error("Option '--threads' or '-j' requires positive integer")
341341

342-
if opts.maxFailures == 0:
343-
parser.error("Setting --max-failures to 0 does not have any effect.")
342+
if opts.maxFailures is not None and opts.maxFailures <= 0:
343+
parser.error("Option '--max-failures' requires positive integer")
344344

345345
if opts.echoAllCommands:
346346
opts.showOutput = True
@@ -374,7 +374,6 @@ def main_with_tmp(builtinParameters):
374374
valgrindLeakCheck = opts.valgrindLeakCheck,
375375
valgrindArgs = opts.valgrindArgs,
376376
noExecute = opts.noExecute,
377-
singleProcess = opts.singleProcess,
378377
debug = opts.debug,
379378
isWindows = isWindows,
380379
params = userParams,
@@ -481,6 +480,12 @@ def main_with_tmp(builtinParameters):
481480
if opts.maxTests is not None:
482481
run.tests = run.tests[:opts.maxTests]
483482

483+
# Determine number of workers to use.
484+
if opts.singleProcess:
485+
opts.numThreads = 1
486+
elif opts.numThreads is None:
487+
opts.numThreads = lit.util.detectCPUs()
488+
484489
# Don't create more threads than tests.
485490
opts.numThreads = min(len(run.tests), opts.numThreads)
486491

@@ -506,11 +511,9 @@ def main_with_tmp(builtinParameters):
506511
except:
507512
pass
508513

509-
extra = ''
510-
if len(run.tests) != numTotalTests:
511-
extra = ' of %d' % numTotalTests
512-
header = '-- Testing: %d%s tests, %d threads --'%(len(run.tests), extra,
513-
opts.numThreads)
514+
extra = (' of %d' % numTotalTests) if (len(run.tests) != numTotalTests) else ''
515+
threads = 'single process' if (opts.numThreads == 1) else ('%d threads' % opts.numThreads)
516+
header = '-- Testing: %d%s tests, %s --' % (len(run.tests), extra, threads)
514517
progressBar = None
515518
if not opts.quiet:
516519
if opts.succinct and opts.useProgressBar:

llvm/utils/lit/lit/run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def execute_tests(self, display, jobs, max_time=None):
133133
be given an UNRESOLVED result.
134134
"""
135135
# Don't do anything if we aren't going to run any tests.
136-
if not self.tests or jobs == 0:
136+
if not self.tests:
137137
return
138138

139139
# Save the display object on the runner so that we can update it from
@@ -142,12 +142,14 @@ def execute_tests(self, display, jobs, max_time=None):
142142

143143
self.failure_count = 0
144144
self.hit_max_failures = False
145-
if self.lit_config.singleProcess:
145+
if jobs == 1:
146146
global child_lit_config
147147
child_lit_config = self.lit_config
148148
for test_index, test in enumerate(self.tests):
149149
result = worker_run_one_test(test_index, test)
150150
self.consume_test_result(result)
151+
if self.hit_max_failures:
152+
break
151153
else:
152154
self.execute_tests_in_pool(jobs, max_time)
153155

llvm/utils/lit/tests/max-failures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# CHECK: Failing Tests (27)
1212
# CHECK: Failing Tests (1)
1313
# CHECK: Failing Tests (2)
14-
# CHECK: error: Setting --max-failures to 0 does not have any effect.
14+
# CHECK: error: Option '--max-failures' requires positive integer

llvm/utils/lit/tests/unit/TestRunner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def load_keyword_parser_lit_tests():
2929
quiet=False,
3030
useValgrind=False,
3131
valgrindLeakCheck=False,
32-
singleProcess=False,
3332
valgrindArgs=[],
3433
noExecute=False,
3534
debug=False,

0 commit comments

Comments
 (0)