summaryrefslogtreecommitdiffstats
path: root/conf.d/controller/lua.d
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-06 18:05:41 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-10 17:12:30 +0200
commit5d43cc3428569c62ff1804a5d79afa27637c8479 (patch)
tree6df7b6b71cb0642af645560c47f3ad1ab297eb73 /conf.d/controller/lua.d
parentc63e3b622eca925e6f3144607251f3936efbb678 (diff)
Include pkg config file.
afb-test is considered like a binding "system" which could be retrieved using pkgconfig file variable. Change-Id: Icc9a0186093c98817e1a421d7ddee8043a33efa1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'conf.d/controller/lua.d')
-rw-r--r--conf.d/controller/lua.d/aft.lua45
1 files changed, 34 insertions, 11 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua
index 27b558e..bd0141f 100644
--- a/conf.d/controller/lua.d/aft.lua
+++ b/conf.d/controller/lua.d/aft.lua
@@ -253,10 +253,17 @@ function _AFT.testVerbError(testName, api, verb, args, cb)
end
function _AFT.describe(testName, testFunction)
+ sanitizedTestName = "test"..tostring(testName)
+ if _AFT.beforeEach then local b = _AFT.beforeEach() end
+ if _AFT.afterEach then local a = _AFT.afterEach() end
+ local aTest = {}
+
+ function aTest:sanitizedTestName() testFunction() end
+ function aTest:setUp() b() end
+ function aTest:tearDown() a() end
+
table.insert(_AFT.tests_list, {testName, function()
- if _AFT.beforeEach then _AFT.beforeEach() end
testFunction()
- if _AFT.afterEach then _AFT.afterEach() end
end})
end
@@ -399,6 +406,8 @@ end
function _launch_test(context, args)
_AFT.context = context
+ -- Prepare the tests execution configuring the monitoring and loading
+ -- lua test files to execute in the Framework.
_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", event = "push_after" }})
@@ -410,17 +419,31 @@ function _launch_test(context, args)
dofile('var/'..args.files)
end
- AFB:success(_AFT.context, { info = "Launching tests"})
- if _AFT.beforeAll then _AFT.beforeAll() end
- lu.LuaUnit:runSuiteByInstances(_AFT.tests_list)
- if _AFT.afterAll then _AFT.afterAll() end
+ -- Execute the test within a context if given. We assume that the before
+ -- function success returning '0' else we abort the whole test procedure
+ if _AFT.beforeAll then
+ if _AFT.beforeAll() == 0 then
+ AFB:success(_AFT.context, { info = "Launching tests"})
+ lu.LuaUnit:runSuiteByInstances(_AFT.tests_list)
+
+ local success ="Success : "..tostring(lu.LuaUnit.result.passedCount)
+ local failures="Failures : "..tostring(lu.LuaUnit.result.testCount-lu.LuaUnit.result.passedCount)
- local success ="Success : "..tostring(lu.LuaUnit.result.passedCount)
- local failures="Failures : "..tostring(lu.LuaUnit.result.testCount-lu.LuaUnit.result.passedCount)
+ local evtHandle = AFB:evtmake(_AFT.context, 'results')
+ AFB:subscribe(_AFT.context,evtHandle)
+ AFB:evtpush(_AFT.context,evtHandle,{info = success.." "..failures})
+ else
+ AFB:fail(_AFT.context, { info = "Can't set the context to execute the tests correctly. Look at the log and retry."})
+ end
+ end
- local evtHandle = AFB:evtmake(_AFT.context, 'results')
- AFB:subscribe(_AFT.context,evtHandle)
- AFB:evtpush(_AFT.context,evtHandle,{info = success.." "..failures})
+ -- Keep the context unset function to be executed after all no matter if
+ -- tests have been executed or not.
+ if _AFT.afterAll then
+ if _AFT.afterAll() != 0 then
+ print('Unsetting the tests context failed.')
+ end
+ end
if _AFT.exit[1] == 1 then os.exit(_AFT.exit[2]) end
end