mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 06:33:33 +03: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:
parent
3c52a82213
commit
6edf063c94
@ -52,6 +52,7 @@ matrix:
|
||||
script:
|
||||
- cargo test --release
|
||||
- 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
|
||||
# Check JS output from all tests against eslint
|
||||
- npm run run-lint-generated-tests
|
||||
|
@ -123,11 +123,12 @@ fn rmain() -> Result<(), Error> {
|
||||
node = !custom.payload().contains(&0x01);
|
||||
}
|
||||
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.
|
||||
shell.status("Executing bindgen...");
|
||||
let mut b = Bindgen::new();
|
||||
b.debug(true)
|
||||
b.debug(debug)
|
||||
.nodejs(node)
|
||||
.input_module(module, wasm, |w| parity_wasm::serialize(w).unwrap())
|
||||
.keep_debug(false)
|
||||
|
@ -10,5 +10,4 @@ mod js_objects;
|
||||
mod imports;
|
||||
mod simple;
|
||||
mod node;
|
||||
mod non_debug;
|
||||
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 = () => {
|
||||
// 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/);
|
||||
let a = wasm.ClassesExceptions1.new();
|
||||
a.free();
|
||||
|
@ -22,6 +22,10 @@ exports.test_return_a_string = 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_str(3), /expected a string argument/);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user