From 5d43cc3428569c62ff1804a5d79afa27637c8479 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 6 Jul 2018 18:05:41 +0200 Subject: 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 --- conf.d/CMakeLists.txt | 4 ++-- conf.d/afb-test.pc.in | 27 +++++++++++++++++++++++++ conf.d/aft.pc.in | 27 ------------------------- conf.d/cmake/config.cmake | 4 ++-- conf.d/controller/lua.d/aft.lua | 45 +++++++++++++++++++++++++++++++---------- 5 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 conf.d/afb-test.pc.in delete mode 100644 conf.d/aft.pc.in 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/afb-test.pc.in b/conf.d/afb-test.pc.in new file mode 100644 index 0000000..5d00415 --- /dev/null +++ b/conf.d/afb-test.pc.in @@ -0,0 +1,27 @@ +## +## Copyright (C) 2016, 2017, 2018 "IoT.bzh" +## Author: José Bollo +## +## This file is part of afb-daemon project. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +libdir=@CMAKE_INSTALL_PREFIX@ + +Name: @PROJECT_PRETTY_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ +URL: @PROJECT_URL@ + +Requires: afb-daemon diff --git a/conf.d/aft.pc.in b/conf.d/aft.pc.in deleted file mode 100644 index ef6b2a4..0000000 --- a/conf.d/aft.pc.in +++ /dev/null @@ -1,27 +0,0 @@ -## -## Copyright (C) 2016, 2017, 2018 "IoT.bzh" -## Author: José Bollo -## -## This file is part of afb-daemon project. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## - -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ - -Name: @PROJECT_PRETTY_NAME@ -Description: @PROJECT_DESCRIPTION@ -Version: @PROJECT_VERSION@ -URL: @PROJECT_URL@ - -Requires: afb-daemon 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 -- cgit 1.2.3-korg