repl_wasm: disable console_error_panic_hook for tests

This commit is contained in:
Brian Carroll 2022-03-12 19:23:17 +00:00
parent 4f7591f963
commit be72439acc
4 changed files with 6 additions and 3 deletions

View File

@ -4,7 +4,7 @@ set -eux
# We *could* write a build.rs to do this but we'd have nested cargo processes with different targets.
# That can be solved using two separate target direcories with --target-dir but there isn't a huge win.
# We need to clear RUSTFLAGS for this command, as CI sets normally some flags that are specific to CPU targets.
RUSTFLAGS="" cargo build --target wasm32-unknown-unknown -p roc_repl_wasm --features wasmer --release
RUSTFLAGS="" cargo build --target wasm32-unknown-unknown -p roc_repl_wasm --no-default-features --features wasmer --release
# Build & run the test code on *native* target, not WebAssembly
cargo test -p repl_test --features wasm -- --test-threads=1

View File

@ -11,7 +11,7 @@ roc_builtins = {path = "../compiler/builtins"}
[dependencies]
bumpalo = {version = "3.8.0", features = ["collections"]}
console_error_panic_hook = "0.1.7"
console_error_panic_hook = {version = "0.1.7", optional = true}
futures = {version = "0.3.17", optional = true}
js-sys = "0.3.56"
wasm-bindgen = "0.2.79"
@ -26,6 +26,7 @@ roc_target = {path = "../compiler/roc_target"}
roc_types = {path = "../compiler/types"}
[features]
default = ["console_error_panic_hook"]
wasmer = ["futures"]
[package.metadata.wasm-pack.profile.profiling]

View File

@ -1,10 +1,11 @@
extern crate console_error_panic_hook;
mod repl;
//
// Interface with external JS in the browser
//
#[cfg(not(feature = "wasmer"))]
extern crate console_error_panic_hook;
#[cfg(not(feature = "wasmer"))]
mod externs_js;
#[cfg(not(feature = "wasmer"))]
pub use externs_js::{entrypoint_from_js, js_create_app, js_get_result_and_memory, js_run_app};

View File

@ -155,6 +155,7 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
}
pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
#[cfg(not(feature = "wasmer"))]
console_error_panic_hook::set_once();
let arena = &Bump::new();