2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00

Parallel tests can now have an execution order

This commit is contained in:
Thomas Nagy 2016-09-01 22:08:03 +02:00
parent 478d31e701
commit e3092aadc7
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
2 changed files with 31 additions and 0 deletions

View File

@ -42,10 +42,16 @@ def configure(conf):
#ctx.check_large_file(mandatory=False)
conf.multicheck(
# list of conf.check() arguments
{'header_name':'stdio.h', 'msg':'... stdio', 'uselib_store': 'STDIO'},
{'header_name':'xyztabcd.h', 'msg':'... optional xyztabcd.h', 'mandatory': False},
{'header_name':'stdlib.h', 'msg':'... stdlib', 'okmsg': 'aye', 'errmsg': 'nope'},
{'func': test_build, 'msg':'... testing an arbitrary build function', 'okmsg':'ok'},
# parallelism control with after_tests/before_tests
{'header_name':'malloc.h', 'msg':'... malloc', 'uselib_store': 'MALLOC', 'id': 'malloc_t'},
{'header_name':'unistd.h', 'msg':'... unistd', 'uselib_store': 'UNISTD', 'before_tests': ['malloc_t']},
msg = 'Checking for headers in parallel',
#mandatory = False, # set to False to make all tests non-mandatory
#run_all_tests = False # set to False to stop at the first error

View File

@ -1250,10 +1250,17 @@ class cfgtask(Task.TaskBase):
Make sure to use locks if concurrent access to the same conf.env data is necessary.
"""
def __init__(self, *k, **kw):
Task.TaskBase.__init__(self, *k, **kw)
self.run_after = set()
def display(self):
return ''
def runnable_status(self):
for x in self.run_after:
if not x.hasrun:
return Task.ASK_LATER
return Task.RUN_ME
def uid(self):
@ -1343,6 +1350,8 @@ def multicheck(self, *k, **kw):
bld = par()
bld.keep = kw.get('run_all_tests', True)
tasks = []
id_to_task = {}
for dct in k:
x = Task.classes['cfgtask'](bld=bld)
tasks.append(x)
@ -1354,6 +1363,22 @@ def multicheck(self, *k, **kw):
# bind a logger that will keep the info in memory
x.logger = Logs.make_mem_logger(str(id(x)), self.logger)
if 'id' in dct:
id_to_task[dct['id']] = x
# second pass to set dependencies with after_test/before_test
for x in tasks:
for key in Utils.to_list(x.args.get('before_tests', [])):
tsk = id_to_task[key]
if not tsk:
raise ValueError('No test named %r' % key)
tsk.run_after.add(x)
for key in Utils.to_list(x.args.get('after_tests', [])):
tsk = id_to_task[key]
if not tsk:
raise ValueError('No test named %r' % key)
x.run_after.add(tsk)
def it():
yield tasks
while 1: