Only run one make at a time.

If openssl has not been built, running parallel make processes causes some problems.
	Change on 2015/01/09 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83617340
pull/3/merge
ctiller 10 years ago committed by Nicolas Noble
parent a5cf7bd7e6
commit 94e5ddece6
  1. 13
      tools/run_tests/jobset.py
  2. 4
      tools/run_tests/run_tests.py

@ -8,7 +8,7 @@ import tempfile
import time
_MAX_JOBS = 16 * multiprocessing.cpu_count()
_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
def shuffle_iteratable(it):
@ -81,15 +81,16 @@ class Job(object):
class Jobset(object):
"""Manages one run of jobs."""
def __init__(self, check_cancelled):
def __init__(self, check_cancelled, maxjobs):
self._running = set()
self._check_cancelled = check_cancelled
self._cancelled = False
self._failures = 0
self._maxjobs = maxjobs
def start(self, cmdline):
"""Start a job. Return True on success, False on failure."""
while len(self._running) >= _MAX_JOBS:
while len(self._running) >= self._maxjobs:
if self.cancelled(): return False
self.reap()
if self.cancelled(): return False
@ -130,10 +131,10 @@ def _never_cancelled():
return False
def run(cmdlines, check_cancelled=_never_cancelled):
js = Jobset(check_cancelled)
def run(cmdlines, check_cancelled=_never_cancelled, maxjobs=None):
js = Jobset(check_cancelled,
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS)
for cmdline in shuffle_iteratable(cmdlines):
if not js.start(cmdline):
break
return js.finish()

@ -43,10 +43,10 @@ def _build_and_run(check_cancelled):
# build latest, sharing cpu between the various makes
if not jobset.run(
(['make',
'-j', '%d' % max(multiprocessing.cpu_count() / len(configs), 1),
'-j', '%d' % (multiprocessing.cpu_count() + 1),
'buildtests_c',
'CONFIG=%s' % cfg]
for cfg in configs), check_cancelled):
for cfg in configs), check_cancelled, maxjobs=1):
sys.exit(1)
# run all the tests

Loading…
Cancel
Save