mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
JSON: Adding ctest
This commit adds node based tests provided by Nico to the ctest framework already established in UPM. Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
02d8a16d4b
commit
d52c2df7c6
@ -149,6 +149,14 @@ find_package (JPEG)
|
||||
# Find nodejs
|
||||
if (BUILDSWIGNODE)
|
||||
find_package (Node REQUIRED)
|
||||
if (BUILDTESTS)
|
||||
find_package (Npm REQUIRED)
|
||||
if(NPM_EXECUTABLE)
|
||||
message(STATUS "NPM Executable found at: ${NPM_EXECUTABLE}")
|
||||
else()
|
||||
message(FATAL_ERROR "Please install NPM first, you can't run tests without it")
|
||||
endif()
|
||||
endif (BUILDTESTS)
|
||||
endif (BUILDSWIGNODE)
|
||||
|
||||
# Find JAVA/JNI
|
||||
|
13
cmake/modules/FindNpm.cmake
Normal file
13
cmake/modules/FindNpm.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
# Finding and pointing a variable to the npm executable if found
|
||||
# Only works on Linux systems as of now
|
||||
|
||||
find_program(NPM_EXECUTABLE NAMES npm
|
||||
HINTS
|
||||
/usr
|
||||
)
|
||||
|
||||
if(NPM_EXECUTABLE)
|
||||
message(STATUS "NPM Executable found at ${NPM_EXECUTABLE}")
|
||||
else()
|
||||
message(ERROR "Unable to find NPM installation, please install NPM")
|
||||
endif()
|
@ -74,3 +74,11 @@ if (BUILDSWIGPYTHON AND PYTHON3INTERP_FOUND)
|
||||
${CMAKE_SOURCE_DIR}/examples/python/*.py
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/)
|
||||
endif (BUILDSWIGPYTHON AND PYTHON3INTERP_FOUND)
|
||||
|
||||
# add JSON test
|
||||
if(NPM_EXECUTABLE)
|
||||
add_test (NAME check_jsons COMMAND ${CMAKE_COMMAND}
|
||||
-DNPMEXEC=${NPM_EXECUTABLE}
|
||||
-DUPMBASEDIR=${CMAKE_SOURCE_DIR}
|
||||
-P ${CMAKE_SOURCE_DIR}/tests/runjsontest.cmake)
|
||||
endif(NPM_EXECUTABLE)
|
||||
|
36
tests/runjsontest.cmake
Normal file
36
tests/runjsontest.cmake
Normal file
@ -0,0 +1,36 @@
|
||||
# This macro sets up the initial JSON test environment
|
||||
# it copies over everything required by the test over to the
|
||||
# build directory so that the tests can be run from there
|
||||
macro(SETUP_JSON_COLLATERAL UBD NE)
|
||||
execute_process(COMMAND mkdir -p ${UBD}/build/node_test;
|
||||
COMMAND cp ${UBD}/tests/node/package.json ${UBD}/build/node_test/;
|
||||
COMMAND cp ${UBD}/tests/node/jsonlint.js ${UBD}/build/node_test/;
|
||||
COMMAND cp ${UBD}/tests/node/test.js ${UBD}/build/node_test/;
|
||||
COMMAND ${NE} install --prefix=${UBD}/build/node_test/;
|
||||
RESULT_VARIABLE ret_val
|
||||
)
|
||||
if(ret_val)
|
||||
message(FATAL_ERROR "value of result of first test: ${ret_val_1}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# This macro runs the json test and checks the json files for
|
||||
# their validity and also checks for the required fields
|
||||
macro(EXEC_JSON_TEST UBD NE)
|
||||
execute_process(COMMAND ${NE} test --prefix=${UBD}/build/node_test/
|
||||
RESULT_VARIABLE ret_val
|
||||
)
|
||||
execute_process(COMMAND rm -rf ${UBD}/build/node_test)
|
||||
if(ret_val)
|
||||
message(FATAL_ERROR "value of the result of the second test: ${ret_val_2}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# this macro removes all the JSON collateral from the build directory
|
||||
#macro(REMOVE_JSON_COLLATERAL UBD)
|
||||
# execute_process(COMMAND rm -rf ${UBD}/build/node_test)
|
||||
#endmacro()
|
||||
|
||||
setup_json_collateral(${UPMBASEDIR} ${NPMEXEC})
|
||||
exec_json_test(${UPMBASEDIR} ${NPMEXEC})
|
||||
#remove_json_collateral(${UPMBASEDIR})
|
Loading…
x
Reference in New Issue
Block a user