Skip to content

Commit

Permalink
tools,test: make -J behavior default for test.py
Browse files Browse the repository at this point in the history
PR-URL: #40945
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
Trott authored and danielleadams committed Dec 13, 2021
1 parent 5c27ec8 commit 82daaa9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,9 +1362,9 @@ def BuildOptions():
default="")
result.add_option("--warn-unused", help="Report unused rules",
default=False, action="store_true")
result.add_option("-j", help="The number of parallel tasks to run",
default=1, type="int")
result.add_option("-J", help="Run tasks in parallel on all cores",
result.add_option("-j", help="The number of parallel tasks to run, 0=use number of cores",
default=0, type="int")
result.add_option("-J", help="For legacy compatibility, has no effect",
default=False, action="store_true")
result.add_option("--time", help="Print timing information after running",
default=False, action="store_true")
Expand Down Expand Up @@ -1423,11 +1423,16 @@ def ProcessOptions(options):
if options.run[0] >= options.run[1]:
print("The test group to run (n) must be smaller than number of groups (m).")
return False
if options.J:
if options.j == 0:
# inherit JOBS from environment if provided. some virtualised systems
# tends to exaggerate the number of available cpus/cores.
cores = os.environ.get('JOBS')
options.j = int(cores) if cores is not None else multiprocessing.cpu_count()
elif options.J:
# If someone uses -j and legacy -J, let them know that we will be respecting
# -j and ignoring -J, which is the opposite of what we used to do before -J
# became a legacy no-op.
print('Warning: Legacy -J option is ignored. Using the -j option.')
if options.flaky_tests not in [RUN, SKIP, DONTCARE]:
print("Unknown flaky-tests mode %s" % options.flaky_tests)
return False
Expand Down

0 comments on commit 82daaa9

Please sign in to comment.