Add more coverage and use the ARGS option of try_run
This commit is contained in:
parent
06b0f676ce
commit
32f156b218
|
@ -142,6 +142,17 @@ IF(NOT "${TRY_OUT}" MATCHES "hello world")
|
||||||
MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"hello world\": \"${TRY_OUT}\"")
|
MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"hello world\": \"${TRY_OUT}\"")
|
||||||
ENDIF(NOT "${TRY_OUT}" MATCHES "hello world")
|
ENDIF(NOT "${TRY_OUT}" MATCHES "hello world")
|
||||||
|
|
||||||
|
TRY_RUN(ARG_TEST_RUN ARG_TEST_COMPILE
|
||||||
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
||||||
|
${TryCompile_SOURCE_DIR}/expect_arg.c
|
||||||
|
OUTPUT_VARIABLE TRY_OUT
|
||||||
|
ARGS arg1 arg2)
|
||||||
|
IF(NOT ARG_TEST_COMPILE)
|
||||||
|
MESSAGE(SEND_ERROR "expect_arg failed compiling: ${TRY_OUT}")
|
||||||
|
ENDIF(NOT ARG_TEST_COMPILE)
|
||||||
|
IF(NOT "${ARG_TEST_RUN}" STREQUAL "0")
|
||||||
|
MESSAGE(SEND_ERROR "expect_arg failed running with exit code ${ARG_TEST_RUN} ${TRY_OUT}")
|
||||||
|
ENDIF(NOT "${ARG_TEST_RUN}" STREQUAL "0")
|
||||||
|
|
||||||
# try to run a file that should compile and run, but return an error
|
# try to run a file that should compile and run, but return an error
|
||||||
TRY_RUN(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
|
TRY_RUN(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
int main(int ac, char*av[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
printf("ac = [%d]\n", ac);
|
||||||
|
for(i =0; i < ac; i++)
|
||||||
|
{
|
||||||
|
printf("arg[%d] = %s\n", i, av[i]);
|
||||||
|
}
|
||||||
|
if(ac == 3)
|
||||||
|
{
|
||||||
|
if(strcmp(av[1], "arg1") ==0
|
||||||
|
&& strcmp(av[2], "arg2") ==0)
|
||||||
|
{
|
||||||
|
printf("arg1 and arg2 present and accounted for!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("arg1 and arg2 missing!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
Loading…
Reference in New Issue