Run WASI C API tests based on feature; prevent cmake caching

This commit is contained in:
Mark McCaskey 2019-11-20 15:41:33 -08:00
parent 6831a6d8c9
commit 4a84441ab0
4 changed files with 18 additions and 5 deletions

View File

@ -7,7 +7,6 @@ add_executable(test-globals test-globals.c)
add_executable(test-import-function test-import-function.c)
add_executable(test-imports test-imports.c)
add_executable(test-import-object test-import-object.c)
add_executable(test-wasi-import-object test-wasi-import-object.c)
add_executable(test-instantiate test-instantiate.c)
add_executable(test-memory test-memory.c)
add_executable(test-module test-module.c)
@ -19,6 +18,10 @@ add_executable(test-validate test-validate.c)
add_executable(test-context test-context.c)
add_executable(test-module-import-instantiate test-module-import-instantiate.c)
if (DEFINED WASI_TESTS)
add_executable(test-wasi-import-object test-wasi-import-object.c)
endif()
find_library(
WASMER_LIB NAMES libwasmer_runtime_c_api.dylib libwasmer_runtime_c_api.so wasmer_runtime_c_api.dll
PATHS ${CMAKE_SOURCE_DIR}/../../../target/release/
@ -64,9 +67,12 @@ target_link_libraries(test-import-object general ${WASMER_LIB})
target_compile_options(test-import-object PRIVATE ${COMPILER_OPTIONS})
add_test(test-import-object test-import-object)
target_link_libraries(test-wasi-import-object general ${WASMER_LIB})
target_compile_options(test-wasi-import-object PRIVATE ${COMPILER_OPTIONS})
add_test(test-wasi-import-object test-wasi-import-object)
if (DEFINED WASI_TESTS)
target_link_libraries(test-wasi-import-object general ${WASMER_LIB})
target_compile_options(test-wasi-import-object PRIVATE ${COMPILER_OPTIONS})
add_test(test-wasi-import-object test-wasi-import-object)
endif()
target_link_libraries(test-instantiate general ${WASMER_LIB})
target_compile_options(test-instantiate PRIVATE ${COMPILER_OPTIONS})

View File

@ -4,7 +4,14 @@ use std::process::Command;
fn test_c_api() {
let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests");
run_command("cmake", project_tests_dir, vec!["."]);
let cmake_args = vec![
".",
#[cfg(feature = "wasi")]
"-DWASI_TESTS=ON",
];
// we use -f so it doesn't fail if the fiel doesn't exist
run_command("rm", project_tests_dir, vec!["-f", "CMakeCache.txt"]);
run_command("cmake", project_tests_dir, cmake_args);
run_command("make", project_tests_dir, vec!["-Wdev", "-Werror=dev"]);
run_command("make", project_tests_dir, vec!["test", "ARGS=\"-V\""]);
}