summaryrefslogtreecommitdiffstats
path: root/conf.d
diff options
context:
space:
mode:
Diffstat (limited to 'conf.d')
-rw-r--r--conf.d/CMakeLists.txt4
-rw-r--r--conf.d/afb-test.pc.in (renamed from conf.d/aft.pc.in)2
-rw-r--r--conf.d/cmake/config.cmake4
-rw-r--r--conf.d/controller/lua.d/aft.lua45
4 files changed, 39 insertions, 16 deletions
diff --git a/conf.d/CMakeLists.txt b/conf.d/CMakeLists.txt
index 3fd4d3c..64be68c 100644
--- a/conf.d/CMakeLists.txt
+++ b/conf.d/CMakeLists.txt
@@ -21,10 +21,10 @@
# -----------------------------------------------------
PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/aft.pc.in ${CMAKE_CURRENT_BINARY_DIR}/aft.pc @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/afb-test.pc.in ${CMAKE_CURRENT_BINARY_DIR}/afb-test.pc @ONLY)
INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/aft.pc
+ ${CMAKE_CURRENT_BINARY_DIR}/afb-test.pc
DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
diff --git a/conf.d/aft.pc.in b/conf.d/afb-test.pc.in
index ef6b2a4..5d00415 100644
--- a/conf.d/aft.pc.in
+++ b/conf.d/afb-test.pc.in
@@ -17,7 +17,7 @@
## limitations under the License.
##
-libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+libdir=@CMAKE_INSTALL_PREFIX@
Name: @PROJECT_PRETTY_NAME@
Description: @PROJECT_DESCRIPTION@
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 889ee9a..b66cd77 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -18,11 +18,11 @@
# Project Info
# ------------------
-set(PROJECT_NAME test)
+set(PROJECT_NAME afb-test)
set(PROJECT_VERSION "5.0")
set(PROJECT_PRETTY_NAME "Binding to test other bindings")
set(PROJECT_DESCRIPTION "Binding used to test other binding")
-set(PROJECT_URL "https://github.com/iotbzh/afb-afb-test")
+set(PROJECT_URL "https://github.com/iotbzh/afb-test")
set(PROJECT_ICON "icon.png")
set(PROJECT_AUTHOR "Forlot Romain")
set(PROJECT_AUTHOR_MAIL "romain.forlot@iot.bzh")
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