diff --git a/ChangeLog b/ChangeLog index f0402100..6ca6d81e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ CHANGES IN WAF 2.1.0 -------------------- * While the Waf file runs on Python 2 and 3, creating it requires version 3 + Added wafcache ++ waf_unit_test: Added task in returned tuples, custom reports should be adapted - Remove waflib.Runner.PriorityTasks.appendleft - Remove waflib.Task.TaskBase - Remove the upper class of waflib.Task.Task (metaclass syntax) diff --git a/demos/unit_test/tests/test0/wscript_build b/demos/unit_test/tests/test0/wscript_build index 36456e48..ff6e0099 100644 --- a/demos/unit_test/tests/test0/wscript_build +++ b/demos/unit_test/tests/test0/wscript_build @@ -7,6 +7,7 @@ bld( source = 'HelloWorldTest.cpp', target = 'unit_test_program', use = 'unittestmain useless CPPUNIT', - ut_str = '${SRC[0].abspath()} -flag1 ${NARG}' + ut_str = '${SRC[0].abspath()} -flag1 ${NARG}', + name = 'test0', ) diff --git a/demos/unit_test/tests/test1/wscript_build b/demos/unit_test/tests/test1/wscript_build index b46df743..253292a6 100644 --- a/demos/unit_test/tests/test1/wscript_build +++ b/demos/unit_test/tests/test1/wscript_build @@ -7,5 +7,6 @@ bld( target = 'unit_test_program', use = 'unittestmain useless CPPUNIT', ut_cwd = bld.path, + name = 'test1', ) diff --git a/demos/unit_test/tests/test2/wscript_build b/demos/unit_test/tests/test2/wscript_build index 83f80fd7..97c779b2 100644 --- a/demos/unit_test/tests/test2/wscript_build +++ b/demos/unit_test/tests/test2/wscript_build @@ -5,7 +5,8 @@ if bld.env['PYTHON']: bld( features = 'test_scripts', test_scripts_source = 'test.py', - test_scripts_template = '${PYTHON} ${SCRIPT}' + test_scripts_template = '${PYTHON} ${SCRIPT}', + name = 'test2', ) diff --git a/demos/unit_test/tests/test3/wscript_build b/demos/unit_test/tests/test3/wscript_build index a2c6ae31..ae052915 100644 --- a/demos/unit_test/tests/test3/wscript_build +++ b/demos/unit_test/tests/test3/wscript_build @@ -23,7 +23,8 @@ if bld.env['PYTHON']: features = 'test_scripts', test_scripts_source = 'test.1.py test.2.py', test_scripts_template = '${PYTHON} ${SCRIPT}', - test_scripts_paths = paths + test_scripts_paths = paths, + name = 'test3', ) diff --git a/demos/unit_test/wscript b/demos/unit_test/wscript index cf89b2e2..3b606c0d 100644 --- a/demos/unit_test/wscript +++ b/demos/unit_test/wscript @@ -40,9 +40,11 @@ def summary(bld): Logs.pprint('CYAN', 'test report %3.0f%% success' % val) Logs.pprint('CYAN', ' tests that fail %d/%d' % (tfail, total)) - for (f, code, out, err) in lst: + for (f, code, out, err, ut_task) in lst: if code: - Logs.pprint('CYAN', ' %s' % f) + # In ut_task we have the task running the test and we can get any extra information + # from there (in this example just the generator name) + Logs.pprint('CYAN', ' %s (%s)' % (f, ut_task.generator.name)) Logs.pprint('RED', 'status: %r' % code) if out: Logs.pprint('RED', 'out: %r' % out) if err: Logs.pprint('RED', 'err: %r' % err) diff --git a/waflib/Tools/waf_unit_test.py b/waflib/Tools/waf_unit_test.py index 6ff6f727..e2ffe885 100644 --- a/waflib/Tools/waf_unit_test.py +++ b/waflib/Tools/waf_unit_test.py @@ -222,7 +222,7 @@ class utest(Task.Task): proc = Utils.subprocess.Popen(cmd, cwd=self.get_cwd().abspath(), env=self.get_test_env(), stderr=Utils.subprocess.PIPE, stdout=Utils.subprocess.PIPE, shell=isinstance(cmd,str)) (stdout, stderr) = proc.communicate() - self.waf_unit_test_results = tup = (self.inputs[0].abspath(), proc.returncode, stdout, stderr) + self.waf_unit_test_results = tup = (self.inputs[0].abspath(), proc.returncode, stdout, stderr, self) testlock.acquire() try: return self.generator.add_test_results(tup) @@ -249,12 +249,12 @@ def summary(bld): tfail = len([x for x in lst if x[1]]) Logs.pprint('GREEN', ' tests that pass %d/%d' % (total-tfail, total)) - for (f, code, out, err) in lst: + for (f, code, out, err, ut_task) in lst: if not code: Logs.pprint('GREEN', ' %s' % f) Logs.pprint('GREEN' if tfail == 0 else 'RED', ' tests that fail %d/%d' % (tfail, total)) - for (f, code, out, err) in lst: + for (f, code, out, err, ut_task) in lst: if code: Logs.pprint('RED', ' %s' % f) @@ -271,7 +271,7 @@ def set_exit_code(bld): bld.add_post_fun(waf_unit_test.set_exit_code) """ lst = getattr(bld, 'utest_results', []) - for (f, code, out, err) in lst: + for (f, code, out, err, ut_task) in lst: if code: msg = [] if out: