aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-06-28 13:19:49 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-10 17:12:14 +0200
commit80cb32ffd50f8b3899039e351349f569e02d6116 (patch)
tree3ff97d0fb3514d25f58bf41e6081cb6d248164f4
parente27706bf711b50f44bec3ef4aa85a5007abb3b07 (diff)
Redirect print to a file in addition of standard output
Change-Id: I3cd556d8dba9b2d30d169da15a1f09de7ccc2b10 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--conf.d/project/lua.d/aft.lua14
1 files changed, 13 insertions, 1 deletions
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