Error if format_test can't be executed.

This ensures that on Travis, format_test will always be executed, or the
build fails.
This commit is contained in:
iphydf 2016-10-24 16:06:09 +01:00
parent 09c8575a7d
commit de966cdf90
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
4 changed files with 23 additions and 3 deletions

View File

@ -263,6 +263,8 @@ target_link_modules(toxencryptsave toxcore)
set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified") set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the number of seconds specified")
option(FORMAT_TEST "Require the format_test to be executed; fail cmake if it can't" OFF)
if(APIDSL AND ASTYLE) if(APIDSL AND ASTYLE)
add_test( add_test(
NAME format_test NAME format_test
@ -271,6 +273,8 @@ if(APIDSL AND ASTYLE)
"${APIDSL}" "${APIDSL}"
"${ASTYLE}") "${ASTYLE}")
set_tests_properties(format_test PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}") set_tests_properties(format_test PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
elseif(FORMAT_TEST)
message(FATAL_ERROR "format_test can not be run, because either APIDSL (${APIDSL}) or ASTYLE (${ASTYLE}) could not be found")
endif() endif()
function(auto_test target) function(auto_test target)

View File

@ -10,14 +10,29 @@ find_program(APIDSL NAMES
apidsl.byte apidsl.byte
${CMAKE_SOURCE_DIR}/../apidsl/apigen.native) ${CMAKE_SOURCE_DIR}/../apidsl/apigen.native)
find_program(ASTYLE NAMES find_program(ASTYLE NAMES
astyle) astyle
$ENV{ASTYLE})
function(apidsl) function(apidsl)
if(APIDSL AND ASTYLE) if(APIDSL AND ASTYLE)
foreach(in_file ${ARGN}) foreach(in_file ${ARGN})
get_filename_component(dirname ${in_file} DIRECTORY) # Get the directory component of the input file name.
if(CMAKE_VERSION VERSION_LESS 3.0)
execute_process(
COMMAND dirname ${in_file}
OUTPUT_VARIABLE dirname
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
get_filename_component(dirname ${in_file} DIRECTORY)
endif()
# Get the name without extension (i.e. without ".api.h").
get_filename_component(filename ${in_file} NAME_WE) get_filename_component(filename ${in_file} NAME_WE)
# Put them together, with the new extension that is ".h".
set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h) set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h)
# Run apidsl.
add_custom_command( add_custom_command(
OUTPUT ${out_file} OUTPUT ${out_file}
COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}" COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}"

View File

@ -27,6 +27,7 @@ if ! which "$APIDSL"; then
APIDSL=../apidsl/apigen.native APIDSL=../apidsl/apigen.native
else else
APIDSL=apidsl_curl APIDSL=apidsl_curl
fi
fi fi
apidsl_curl() { apidsl_curl() {

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
CMAKE=cmake CMAKE=cmake
CMAKE_EXTRA_FLAGS="" CMAKE_EXTRA_FLAGS="-DFORMAT_TEST=ON"
NPROC=`nproc` NPROC=`nproc`
CURDIR=$PWD CURDIR=$PWD