mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
test(runtime-c-api) Transforms all C/C++ warnings into errors.
This patch ensures that all our examples and tests do not generate warnings. In C, it can be catastrophic sometimes… Also, be sure that the `cmake` command doesn't emit any warnings too.
This commit is contained in:
parent
af9c26f4f9
commit
c658224f0c
@ -1,5 +1,5 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
project (WasmerCApiTests)
|
||||
project (WasmerRuntimeCApiTests)
|
||||
|
||||
add_executable(test-imports test-imports.c)
|
||||
add_executable(test-exports test-exports.c)
|
||||
@ -22,39 +22,58 @@ if(NOT WASMER_LIB)
|
||||
message(FATAL_ERROR "wasmer library not found")
|
||||
endif()
|
||||
|
||||
target_link_libraries(test-imports
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-exports
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-globals
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-instantiate
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-import-function
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-memory
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-module-imports
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-module
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-module-exports
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-validate
|
||||
general ${WASMER_LIB})
|
||||
target_link_libraries(test-tables
|
||||
general ${WASMER_LIB})
|
||||
|
||||
enable_testing()
|
||||
add_test(test-imports test-imports)
|
||||
add_test(test-exports test-exports)
|
||||
add_test(test-globals test-globals)
|
||||
add_test(test-instantiate test-instantiate)
|
||||
add_test(test-import-function test-import-function)
|
||||
add_test(test-memory test-memory)
|
||||
add_test(test-module-imports test-module-imports)
|
||||
add_test(test-module test-module)
|
||||
add_test(test-module-exports test-module-exports)
|
||||
add_test(test-validate test-validate)
|
||||
add_test(test-tables test-tables)
|
||||
|
||||
set(
|
||||
COMPILER_OPTIONS
|
||||
# Clang or gcc
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
"-Werror" >
|
||||
# MSVC
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
"/WX" >
|
||||
)
|
||||
|
||||
target_link_libraries(test-imports general ${WASMER_LIB})
|
||||
target_compile_options(test-imports PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-imports test-imports)
|
||||
|
||||
target_link_libraries(test-exports general ${WASMER_LIB})
|
||||
target_compile_options(test-exports PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-exports test-exports)
|
||||
|
||||
target_link_libraries(test-globals general ${WASMER_LIB})
|
||||
target_compile_options(test-globals PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-globals test-globals)
|
||||
|
||||
target_link_libraries(test-instantiate general ${WASMER_LIB})
|
||||
target_compile_options(test-instantiate PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-instantiate test-instantiate)
|
||||
|
||||
target_link_libraries(test-import-function general ${WASMER_LIB})
|
||||
target_compile_options(test-import-function PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-import-function test-import-function)
|
||||
|
||||
target_link_libraries(test-memory general ${WASMER_LIB})
|
||||
target_compile_options(test-memory PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-memory test-memory)
|
||||
|
||||
target_link_libraries(test-module-imports general ${WASMER_LIB})
|
||||
target_compile_options(test-module-imports PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-module-imports test-module-imports)
|
||||
|
||||
target_link_libraries(test-module general ${WASMER_LIB})
|
||||
target_compile_options(test-module PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-module test-module)
|
||||
|
||||
target_link_libraries(test-module-exports general ${WASMER_LIB})
|
||||
target_compile_options(test-module-exports PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-module-exports test-module-exports)
|
||||
|
||||
target_link_libraries(test-validate general ${WASMER_LIB})
|
||||
target_compile_options(test-validate PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-validate test-validate)
|
||||
|
||||
target_link_libraries(test-tables general ${WASMER_LIB})
|
||||
target_compile_options(test-tables PRIVATE ${COMPILER_OPTIONS})
|
||||
add_test(test-tables test-tables)
|
||||
|
@ -3,37 +3,47 @@ use std::process::Command;
|
||||
#[test]
|
||||
fn test_c_api() {
|
||||
let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests");
|
||||
|
||||
run_command("cmake", project_tests_dir, Some("."));
|
||||
run_command("make", project_tests_dir, None);
|
||||
run_command("make", project_tests_dir, Some("-Wdev -Werror=dev"));
|
||||
run_command("make", project_tests_dir, Some("test"));
|
||||
}
|
||||
|
||||
fn run_command(command_str: &str, dir: &str, arg: Option<&str>) {
|
||||
println!("Running command: `{}` arg: {:?}", command_str, arg);
|
||||
|
||||
let mut command = Command::new(command_str);
|
||||
|
||||
if let Some(a) = arg {
|
||||
command.arg(a);
|
||||
}
|
||||
|
||||
command.current_dir(dir);
|
||||
|
||||
let result = command.output();
|
||||
|
||||
match result {
|
||||
Ok(r) => {
|
||||
println!("output:");
|
||||
|
||||
if let Some(code) = r.status.code() {
|
||||
println!("status: {}", code);
|
||||
} else {
|
||||
println!("status: None");
|
||||
}
|
||||
|
||||
println!("stdout:");
|
||||
println!("{}", String::from_utf8_lossy(&r.stdout[..]));
|
||||
println!("stderr:");
|
||||
println!("{}", String::from_utf8_lossy(&r.stderr[..]));
|
||||
|
||||
if r.status.success() {
|
||||
assert!(true)
|
||||
} else {
|
||||
panic!("Command failed with exit status: {:?}", r.status);
|
||||
}
|
||||
}
|
||||
|
||||
Err(e) => panic!("Command failed: {}", e),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user