Skip to content

Commit 82daaa9

Browse files
Trottdanielleadams
authored andcommitted
tools,test: make -J behavior default for test.py
PR-URL: #40945 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 5c27ec8 commit 82daaa9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/test.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1362,9 +1362,9 @@ def BuildOptions():
13621362
default="")
13631363
result.add_option("--warn-unused", help="Report unused rules",
13641364
default=False, action="store_true")
1365-
result.add_option("-j", help="The number of parallel tasks to run",
1366-
default=1, type="int")
1367-
result.add_option("-J", help="Run tasks in parallel on all cores",
1365+
result.add_option("-j", help="The number of parallel tasks to run, 0=use number of cores",
1366+
default=0, type="int")
1367+
result.add_option("-J", help="For legacy compatibility, has no effect",
13681368
default=False, action="store_true")
13691369
result.add_option("--time", help="Print timing information after running",
13701370
default=False, action="store_true")
@@ -1423,11 +1423,16 @@ def ProcessOptions(options):
14231423
if options.run[0] >= options.run[1]:
14241424
print("The test group to run (n) must be smaller than number of groups (m).")
14251425
return False
1426-
if options.J:
1426+
if options.j == 0:
14271427
# inherit JOBS from environment if provided. some virtualised systems
14281428
# tends to exaggerate the number of available cpus/cores.
14291429
cores = os.environ.get('JOBS')
14301430
options.j = int(cores) if cores is not None else multiprocessing.cpu_count()
1431+
elif options.J:
1432+
# If someone uses -j and legacy -J, let them know that we will be respecting
1433+
# -j and ignoring -J, which is the opposite of what we used to do before -J
1434+
# became a legacy no-op.
1435+
print('Warning: Legacy -J option is ignored. Using the -j option.')
14311436
if options.flaky_tests not in [RUN, SKIP, DONTCARE]:
14321437
print("Unknown flaky-tests mode %s" % options.flaky_tests)
14331438
return False

0 commit comments

Comments
 (0)