From 80cb32ffd50f8b3899039e351349f569e02d6116 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 28 Jun 2018 13:19:49 +0200 Subject: Redirect print to a file in addition of standard output Change-Id: I3cd556d8dba9b2d30d169da15a1f09de7ccc2b10 Signed-off-by: Romain Forlot --- conf.d/project/lua.d/aft.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/conf.d/project/lua.d/aft.lua b/conf.d/project/lua.d/aft.lua index 43ea15c..5b0a4b7 100644 --- a/conf.d/project/lua.d/aft.lua +++ b/conf.d/project/lua.d/aft.lua @@ -18,11 +18,17 @@ NOTE: strict mode: every global variables should be prefixed by '_' --]] -package.path = package.path .. ';./var/?.lua' local lu = require('luaunit') lu.LuaUnit:setOutputType('JUNIT') lu.LuaUnit.fname = "var/jUnitResults.xml" +-- Use our own print function to redirect it to a file the standard output +_standard_print = print +print = function(...) + io.write(... .. '\n') + _standard_print(...) +end + _AFT = { context = _ctx, tests_list = {}, @@ -38,6 +44,10 @@ function _AFT.setJunitFile(filePath) lu.LuaUnit.fname = filePath end +function _AFT.setOutputFile(filePath) + local file = assert(io.open(filePath, "w+")) + io.output(file) +end --[[ Events listener and assertion functions to test correctness of received event data. @@ -345,6 +355,8 @@ end function _launch_test(context, args) _AFT.context = context + + _AFT.setOutputFile("var/test_results.log") AFB:servsync(_AFT.context, "monitor", "set", { verbosity = "debug" }) AFB:servsync(_AFT.context, "monitor", "trace", { add = { api = args.trace, request = "vverbose", daemon = "vverbose", event = "push_after" }}) if args.files and type(args.files) == 'table' then -- cgit 1.2.3-korg