mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-20 08:16:31 +00:00
Allow disabling --debug
in wasm-bindgen-test-runner
Afterwards remove the `non_debug` test as we're running the entire test suite in non-debug mode!
This commit is contained in:
@ -52,6 +52,7 @@ matrix:
|
|||||||
script:
|
script:
|
||||||
- cargo test --release
|
- cargo test --release
|
||||||
- cargo test --target wasm32-unknown-unknown
|
- cargo test --target wasm32-unknown-unknown
|
||||||
|
- WASM_BINDGEN_NO_DEBUG=1 cargo test --target wasm32-unknown-unknown
|
||||||
- cargo test --target wasm32-unknown-unknown --features serde-serialize
|
- cargo test --target wasm32-unknown-unknown --features serde-serialize
|
||||||
# Check JS output from all tests against eslint
|
# Check JS output from all tests against eslint
|
||||||
- npm run run-lint-generated-tests
|
- npm run run-lint-generated-tests
|
||||||
|
@ -123,11 +123,12 @@ fn rmain() -> Result<(), Error> {
|
|||||||
node = !custom.payload().contains(&0x01);
|
node = !custom.payload().contains(&0x01);
|
||||||
}
|
}
|
||||||
let headless = env::var("NO_HEADLESS").is_err();
|
let headless = env::var("NO_HEADLESS").is_err();
|
||||||
|
let debug = env::var("WASM_BINDGEN_NO_DEBUG").is_err();
|
||||||
|
|
||||||
// Make the generated bindings available for the tests to execute against.
|
// Make the generated bindings available for the tests to execute against.
|
||||||
shell.status("Executing bindgen...");
|
shell.status("Executing bindgen...");
|
||||||
let mut b = Bindgen::new();
|
let mut b = Bindgen::new();
|
||||||
b.debug(true)
|
b.debug(debug)
|
||||||
.nodejs(node)
|
.nodejs(node)
|
||||||
.input_module(module, wasm, |w| parity_wasm::serialize(w).unwrap())
|
.input_module(module, wasm, |w| parity_wasm::serialize(w).unwrap())
|
||||||
.keep_debug(false)
|
.keep_debug(false)
|
||||||
|
@ -10,5 +10,4 @@ mod js_objects;
|
|||||||
mod imports;
|
mod imports;
|
||||||
mod simple;
|
mod simple;
|
||||||
mod node;
|
mod node;
|
||||||
mod non_debug;
|
|
||||||
mod typescript;
|
mod typescript;
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
use super::project;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn works() {
|
|
||||||
project()
|
|
||||||
.debug(false)
|
|
||||||
.file(
|
|
||||||
"src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub struct A {}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
impl A {
|
|
||||||
pub fn new() -> A {
|
|
||||||
A {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn clone(a: &JsValue) -> JsValue {
|
|
||||||
drop(a.clone());
|
|
||||||
a.clone()
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"test.js",
|
|
||||||
r#"
|
|
||||||
import * as assert from "assert";
|
|
||||||
import * as wasm from "./out";
|
|
||||||
|
|
||||||
export function test() {
|
|
||||||
let sym = Symbol('a');
|
|
||||||
assert.strictEqual(wasm.clone(sym), sym);
|
|
||||||
let a = wasm.A.new();
|
|
||||||
a.free();
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.test();
|
|
||||||
}
|
|
@ -31,6 +31,10 @@ exports.js_strings = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.js_exceptions = () => {
|
exports.js_exceptions = () => {
|
||||||
|
// this test only works when `--debug` is passed to `wasm-bindgen` (or the
|
||||||
|
// equivalent thereof)
|
||||||
|
if (require('process').env.WASM_BINDGEN_NO_DEBUG)
|
||||||
|
return;
|
||||||
assert.throws(() => new wasm.ClassesExceptions1(), /cannot invoke `new` directly/);
|
assert.throws(() => new wasm.ClassesExceptions1(), /cannot invoke `new` directly/);
|
||||||
let a = wasm.ClassesExceptions1.new();
|
let a = wasm.ClassesExceptions1.new();
|
||||||
a.free();
|
a.free();
|
||||||
|
@ -22,6 +22,10 @@ exports.test_return_a_string = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.test_wrong_types = function() {
|
exports.test_wrong_types = function() {
|
||||||
|
// this test only works when `--debug` is passed to `wasm-bindgen` (or the
|
||||||
|
// equivalent thereof)
|
||||||
|
if (require('process').env.WASM_BINDGEN_NO_DEBUG)
|
||||||
|
return;
|
||||||
assert.throws(() => wasm.simple_int('a'), /expected a number argument/);
|
assert.throws(() => wasm.simple_int('a'), /expected a number argument/);
|
||||||
assert.throws(() => wasm.simple_str(3), /expected a string argument/);
|
assert.throws(() => wasm.simple_str(3), /expected a string argument/);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user