[Git][NTPsec/ntpsec][master] 2 commits: Write test logs to $out/test.log
Amar Takhar
gitlab at mg.gitlab.com
Mon Nov 30 15:01:45 UTC 2015
Amar Takhar pushed to branch master at NTPsec / ntpsec
Commits:
d0936a39 by Amar Takhar at 2015-11-30T09:56:51Z
Write test logs to $out/test.log
This fixes #23
- - - - -
38cb66c7 by Amar Takhar at 2015-11-30T10:01:12Z
Move test code to pylib/test.py
- - - - -
2 changed files:
- + pylib/test.py
- wscript
Changes:
=====================================
pylib/test.py
=====================================
--- /dev/null
+++ b/pylib/test.py
@@ -0,0 +1,38 @@
+from waflib.Logs import pprint
+
+def test_write_log(ctx):
+ file_out = "%s/test.log" % ctx.bldnode.abspath()
+
+ log = lst = getattr(ctx, 'utest_results', [])
+
+ if not log:
+ return
+
+ with open(file_out, "w") as fp:
+ for binary, retval, lines, error in ctx.utest_results:
+ fp.write("BINARY : %s\n" % binary)
+ fp.write("RETURN VALUE: %s\n" % retval)
+ fp.write("\n*** stdout ***\n")
+ fp.write(lines)
+ fp.write("\n*** stderr ***\n")
+ fp.write(error)
+ fp.write("\n\n\n")
+
+ pprint("BLUE", "Wrote test log to: ", file_out)
+
+
+def test_print_log(ctx):
+ for binary, retval, lines, error in ctx.utest_results:
+ pprint("YELLOW", "BINARY :", binary)
+ pprint("YELLOW", "RETURN VALUE:", retval)
+ print("")
+
+ if retval or error:
+ pprint("RED", "****** ERROR ******\n")
+
+ print error or lines
+
+ if (not retval) and (not error):
+ pprint("GREEN", "****** LOG ******\n", lines)
+
+ print
=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -4,6 +4,7 @@ out="build"
from pylib.configure import cmd_configure
from waflib.Tools import waf_unit_test
+from pylib.test import test_write_log, test_print_log
OPT_STORE = {} # Storage for options to pass into configure
@@ -97,27 +98,8 @@ class check(BuildContext):
cmd = 'check'
-
-def test_print_log(ctx):
- from waflib.Logs import pprint
- for binary, retval, lines, error in ctx.utest_results:
-
- pprint("YELLOW", "BINARY :", binary)
- pprint("YELLOW", "RETURN VALUE:", retval)
- print("")
-
- if retval or error:
- pprint("RED", "****** ERROR ******\n")
-
- print error or lines
-
- if (not retval) and (not error):
- pprint("GREEN", "****** LOG ******\n", lines)
-
- print
-
-
def build(ctx):
+
ctx.load('waf', tooldir='pylib/')
ctx.load('bison')
ctx.load('asciidoc', tooldir='pylib/')
@@ -169,6 +151,9 @@ def build(ctx):
if ctx.options.verbose:
ctx.add_post_fun(test_print_log)
+ # Write test log to a file
+ ctx.add_post_fun(test_write_log)
+
# Print a summary at the end
ctx.add_post_fun(waf_unit_test.summary)
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/d96344411cc91969dcc1e742f64f8aba7802804d...38cb66c7edcdbe6ef8024a4b971f957cd91646a7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151130/ba19c7cc/attachment.html>
More information about the vc
mailing list