Skip to content
Snippets Groups Projects
Commit a1d7f7f7 authored by Craig Tiller's avatar Craig Tiller
Browse files

Merge pull request #843 from nicolasnoble/travis

Trying to do a better job at running C tests on travis.
parents 1844d6bc a7df3f9e
No related branches found
No related tags found
No related merge requests found
language: cpp language: cpp
script: make static_c script: ./tools/run_tests/run_tests.py -lc -t -j2
notifications: notifications:
email: false email: false
...@@ -154,7 +154,7 @@ class JobSpec(object): ...@@ -154,7 +154,7 @@ class JobSpec(object):
class Job(object): class Job(object):
"""Manages one job.""" """Manages one job."""
def __init__(self, spec, bin_hash, newline_on_success): def __init__(self, spec, bin_hash, newline_on_success, travis):
self._spec = spec self._spec = spec
self._bin_hash = bin_hash self._bin_hash = bin_hash
self._tempfile = tempfile.TemporaryFile() self._tempfile = tempfile.TemporaryFile()
...@@ -167,7 +167,9 @@ class Job(object): ...@@ -167,7 +167,9 @@ class Job(object):
env=env) env=env)
self._state = _RUNNING self._state = _RUNNING
self._newline_on_success = newline_on_success self._newline_on_success = newline_on_success
message('START', spec.shortname) self._travis = travis
if not travis:
message('START', spec.shortname)
def state(self, update_cache): def state(self, update_cache):
"""Poll current state of the job. Prints messages at completion.""" """Poll current state of the job. Prints messages at completion."""
...@@ -181,7 +183,7 @@ class Job(object): ...@@ -181,7 +183,7 @@ class Job(object):
else: else:
self._state = _SUCCESS self._state = _SUCCESS
message('PASSED', self._spec.shortname, message('PASSED', self._spec.shortname,
do_newline=self._newline_on_success) do_newline=self._newline_on_success or self._travis)
if self._bin_hash: if self._bin_hash:
update_cache.finished(self._spec.identity(), self._bin_hash) update_cache.finished(self._spec.identity(), self._bin_hash)
return self._state return self._state
...@@ -195,7 +197,7 @@ class Job(object): ...@@ -195,7 +197,7 @@ class Job(object):
class Jobset(object): class Jobset(object):
"""Manages one run of jobs.""" """Manages one run of jobs."""
def __init__(self, check_cancelled, maxjobs, newline_on_success, cache): def __init__(self, check_cancelled, maxjobs, newline_on_success, travis, cache):
self._running = set() self._running = set()
self._check_cancelled = check_cancelled self._check_cancelled = check_cancelled
self._cancelled = False self._cancelled = False
...@@ -203,6 +205,7 @@ class Jobset(object): ...@@ -203,6 +205,7 @@ class Jobset(object):
self._completed = 0 self._completed = 0
self._maxjobs = maxjobs self._maxjobs = maxjobs
self._newline_on_success = newline_on_success self._newline_on_success = newline_on_success
self._travis = travis
self._cache = cache self._cache = cache
def start(self, spec): def start(self, spec):
...@@ -224,7 +227,8 @@ class Jobset(object): ...@@ -224,7 +227,8 @@ class Jobset(object):
if should_run: if should_run:
self._running.add(Job(spec, self._running.add(Job(spec,
bin_hash, bin_hash,
self._newline_on_success)) self._newline_on_success,
self._travis))
return True return True
def reap(self): def reap(self):
...@@ -240,8 +244,9 @@ class Jobset(object): ...@@ -240,8 +244,9 @@ class Jobset(object):
self._completed += 1 self._completed += 1
self._running.remove(job) self._running.remove(job)
if dead: return if dead: return
message('WAITING', '%d jobs running, %d complete, %d failed' % ( if (not self._travis):
len(self._running), self._completed, self._failures)) message('WAITING', '%d jobs running, %d complete, %d failed' % (
len(self._running), self._completed, self._failures))
signal.pause() signal.pause()
def cancelled(self): def cancelled(self):
...@@ -277,10 +282,11 @@ def run(cmdlines, ...@@ -277,10 +282,11 @@ def run(cmdlines,
check_cancelled=_never_cancelled, check_cancelled=_never_cancelled,
maxjobs=None, maxjobs=None,
newline_on_success=False, newline_on_success=False,
travis=False,
cache=None): cache=None):
js = Jobset(check_cancelled, js = Jobset(check_cancelled,
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS, maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS,
newline_on_success, newline_on_success, travis,
cache if cache is not None else NoCache()) cache if cache is not None else NoCache())
for cmdline in shuffle_iteratable(cmdlines): for cmdline in shuffle_iteratable(cmdlines):
if not js.start(cmdline): if not js.start(cmdline):
......
...@@ -175,6 +175,10 @@ argp.add_argument('-f', '--forever', ...@@ -175,6 +175,10 @@ argp.add_argument('-f', '--forever',
default=False, default=False,
action='store_const', action='store_const',
const=True) const=True)
argp.add_argument('-t', '--travis',
default=False,
action='store_const',
const=True)
argp.add_argument('--newline_on_success', argp.add_argument('--newline_on_success',
default=False, default=False,
action='store_const', action='store_const',
...@@ -251,17 +255,18 @@ class TestCache(object): ...@@ -251,17 +255,18 @@ class TestCache(object):
self.parse(json.loads(f.read())) self.parse(json.loads(f.read()))
def _build_and_run(check_cancelled, newline_on_success, cache): def _build_and_run(check_cancelled, newline_on_success, travis, cache):
"""Do one pass of building & running tests.""" """Do one pass of building & running tests."""
# build latest sequentially # build latest sequentially
if not jobset.run(build_steps, maxjobs=1): if not jobset.run(build_steps, maxjobs=1,
newline_on_success=newline_on_success, travis=travis):
return 1 return 1
# run all the tests # run all the tests
all_runs = itertools.chain.from_iterable( all_runs = itertools.chain.from_iterable(
itertools.repeat(one_run, runs_per_test)) itertools.repeat(one_run, runs_per_test))
if not jobset.run(all_runs, check_cancelled, if not jobset.run(all_runs, check_cancelled,
newline_on_success=newline_on_success, newline_on_success=newline_on_success, travis=travis,
maxjobs=min(args.jobs, min(c.maxjobs for c in run_configs)), maxjobs=min(args.jobs, min(c.maxjobs for c in run_configs)),
cache=cache): cache=cache):
return 2 return 2
...@@ -292,6 +297,7 @@ if forever: ...@@ -292,6 +297,7 @@ if forever:
else: else:
result = _build_and_run(check_cancelled=lambda: False, result = _build_and_run(check_cancelled=lambda: False,
newline_on_success=args.newline_on_success, newline_on_success=args.newline_on_success,
travis=args.travis,
cache=test_cache) cache=test_cache)
if result == 0: if result == 0:
jobset.message('SUCCESS', 'All tests passed', do_newline=True) jobset.message('SUCCESS', 'All tests passed', do_newline=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment