Skip to content

Commit

Permalink
Merge branch 'master' into feature/ignore-on-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
nlewycky committed Oct 14, 2020
2 parents e025778 + 0048133 commit 8d83548
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[cranelift_coverage]
features = "cranelift,singlepass,llvm,test-no-traps,test-cranelift"
features = "cranelift,singlepass,llvm,coverage,test-cranelift,test-jit"
examples = ["early-exit", "engine-jit", "engine-native", "engine-headless", "cross-compilation", "compiler-cranelift", "exported-function", "wasi"]
release = true

[llvm_coverage]
features = "cranelift,singlepass,llvm,test-no-traps,test-llvm"
features = "cranelift,singlepass,llvm,coverage,test-llvm,test-jit"
examples = ["compiler-llvm"]
release = true

[singlepass_coverage]
features = "cranelift,singlepass,llvm,test-no-traps,test-singlepass"
features = "cranelift,singlepass,llvm,coverage,test-singlepass,test-jit"
examples = ["compiler-singlepass"]
release = true

[report]
out = ["Xml"]
out = ["Xml"]
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ test-jit = [
"test-generator/test-jit",
]

# Disable trap asserts in the WAST tests. This is useful for running the tests in a
# context where signal handling is a problem, such as tarpaulin for code coverage.
test-no-traps = ["wasmer-wast/test-no-traps"]
# Specifies that we're running in coverage testing mode. This disables tests
# that raise signals because that interferes with tarpaulin.
coverage = []

[[bench]]
name = "static_and_dynamic_functions"
Expand Down
8 changes: 6 additions & 2 deletions tests/compilers/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ pub fn run_wast(wast_path: &str, compiler: &str) -> anyhow::Result<()> {
if is_simd {
features.simd(true);
}
#[cfg(feature = "test-singlepass")]
features.multi_value(false);
if cfg!(feature = "test-singlepass") {
features.multi_value(false);
}
let store = get_store(features, try_nan_canonicalization);
let mut wast = Wast::new_with_spectest(store);
// `bulk-memory-operations/bulk.wast` checks for a message that
Expand All @@ -77,6 +78,9 @@ pub fn run_wast(wast_path: &str, compiler: &str) -> anyhow::Result<()> {
wast.allow_trap_message("uninitialized element", "call stack exhausted");
wast.allow_trap_message("unreachable", "call stack exhausted");
}
if cfg!(feature = "coverage") {
wast.disable_assert_and_exhaustion();
}
if is_simd {
// We allow this, so tests can be run properly for `simd_const` test.
wast.allow_instantiation_failures(&[
Expand Down
1 change: 0 additions & 1 deletion tests/lib/wast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ typetag = "0.1"
[features]
default = ["wat"]
wat = ["wasmer/wat"]
test-no-traps = []

[badges]
maintenance = { status = "actively-developed" }
26 changes: 17 additions & 9 deletions tests/lib/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct Wast {
store: Store,
/// A flag indicating if Wast tests should stop as soon as one test fails.
pub fail_fast: bool,
/// A flag indicating that assert_trap and assert_exhaustion should be skipped.
/// See https://github.com/wasmerio/wasmer/issues/1550 for more info
disable_assert_trap_exhaustion: bool,
}

impl Wast {
Expand All @@ -41,6 +44,7 @@ impl Wast {
current_is_allowed_failure: false,
instances: HashMap::new(),
fail_fast: true,
disable_assert_trap_exhaustion: false,
}
}

Expand All @@ -58,6 +62,11 @@ impl Wast {
.insert(expected.into(), allowed.into());
}

/// Do not run any code in assert_trap or assert_exhaustion.
pub fn disable_assert_and_exhaustion(&mut self) {
self.disable_assert_trap_exhaustion = true;
}

/// Construct a new instance of `Wast` with the spectests imports.
pub fn new_with_spectest(store: Store) -> Self {
let import_object = spectest_importobject(&store);
Expand Down Expand Up @@ -165,27 +174,26 @@ impl Wast {
let result = self.perform_execute(exec);
self.assert_return(result, &results)?;
}
#[cfg(not(feature = "test-no-traps"))]
AssertTrap {
span: _,
exec,
message,
} => {
let result = self.perform_execute(exec);
self.assert_trap(result, message)?;
if !self.disable_assert_trap_exhaustion {
let result = self.perform_execute(exec);
self.assert_trap(result, message)?;
}
}
#[cfg(not(feature = "test-no-traps"))]
AssertExhaustion {
span: _,
call,
message,
} => {
let result = self.perform_invoke(call);
self.assert_trap(result, message)?;
if !self.disable_assert_trap_exhaustion {
let result = self.perform_invoke(call);
self.assert_trap(result, message)?;
}
}
// See https://github.com/wasmerio/wasmer/issues/1550 for more info
#[cfg(feature = "test-no-traps")]
AssertTrap { .. } | AssertExhaustion { .. } => {}
AssertInvalid {
span: _,
mut module,
Expand Down

0 comments on commit 8d83548

Please sign in to comment.