summaryrefslogtreecommitdiffstats
path: root/conf.d/controller
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-09-12 10:49:54 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-09-24 11:32:50 +0000
commitbc69040626197b2bd7a9e05cf751f2d3ef2c083e (patch)
tree4d7debdd5b39d38e204a63c62cff365150f76b43 /conf.d/controller
parenta8d85028514fd7336b4f88cc64bccd0e3a78f60f (diff)
Separate output files
Use one output file by test suite executed with the according extension depending upon the output type chosen. Change-Id: I1804287fc56e4ee2b6df9f672d94553a3d947d49 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'conf.d/controller')
-rw-r--r--conf.d/controller/lua.d/aft.lua23
1 files changed, 20 insertions, 3 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua
index afe9691..aabeb93 100644
--- a/conf.d/controller/lua.d/aft.lua
+++ b/conf.d/controller/lua.d/aft.lua
@@ -20,7 +20,6 @@
local lu = require('luaunit')
lu.LuaUnit:setOutputType('TAP')
-lu.LuaUnit.fname = "xUnitResults.xml"
_AFT = {
exit = {0, code},
@@ -44,7 +43,23 @@ function _AFT.setJunitFile(filePath)
end
function _AFT.setOutputFile(filePath)
- local file = assert(io.open(filePath, "w+"))
+ local fileName = string.gsub(filePath, "(.*)%..*$", "%1")
+ local file = nil
+
+ -- Set the file output according the output type chosen.
+ -- JUNIT produces 2 files, the first one using TXT format and a second
+ -- one using xUnit XML format.
+ if lu.LuaUnit.outputType.__class__ == 'TapOutput' then
+ file = assert(io.open(fileName..".tap", "w+"))
+ elseif lu.LuaUnit.outputType.__class__ == 'JunitOutput' then
+ file = assert(io.open(fileName..".txt", "w+"))
+ lu.LuaUnit.fname = fileName..".xml"
+ elseif lu.LuaUnit.outputType.__class__ == 'TextOutput' then
+ file = assert(io.open(fileName..".txt", "w+"))
+ else
+ file = assert(io.open(filePath, "w+"))
+ end
+
io.output(file)
io.stdout = file
end
@@ -55,7 +70,6 @@ end
-- Use our own print function to redirect it to a file in the workdir of the
-- binder instead of the standard output.
-_AFT.setOutputFile("test_results.log")
_standard_print = print
print = function(...)
io.write(... .. '\n')
@@ -597,14 +611,17 @@ function _launch_test(context, args)
if args.files and type(args.files) == 'table' then
for _,f in pairs(args.files) do
+ _AFT.setOutputFile(f)
readOneFile(f)
process_tests()
_AFT.beforeEach = nil
_AFT.afterEach = nil
_AFT.beforeAll = nil
_AFT.afterAll = nil
+ _AFT.tests_list = {}
end
elseif type(args.files) == 'string' then
+ _AFT.setOutputFile(f)
readOneFile(args.files)
process_tests()
end