Skip to content

Commit 3b76868

Browse files
committed
Fix the webidl-tests crate
1 parent 76a6853 commit 3b76868

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test_script:
2828
- where chromedriver
2929
- set CHROMEDRIVER=C:\Tools\WebDriver\chromedriver.exe
3030
- cargo test -p js-sys --target wasm32-unknown-unknown
31+
- set WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE=1
3132
- cargo test -p webidl-tests --target wasm32-unknown-unknown
3233
# Try just a few features for `web-sys`, unfortunately the whole crate blows
3334
# system command line limits meaning we can't even spawn rustc to enable all

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ matrix:
166166
install: *INSTALL_NODE_VIA_NVM
167167
script:
168168
- cargo test -p wasm-bindgen-webidl
169+
- export WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE=1
169170
- cargo test -p webidl-tests --target wasm32-unknown-unknown
170171
if: branch = master
171172

crates/cli-support/src/js/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::descriptor::{Descriptor, VectorKind};
33
use crate::{Bindgen, EncodeInto, OutputMode};
44
use failure::{bail, Error, ResultExt};
55
use std::collections::{HashMap, HashSet};
6+
use std::env;
67
use walrus::{MemoryId, Module};
78
use wasm_bindgen_wasm_interpreter::Interpreter;
89

@@ -2791,11 +2792,14 @@ impl<'a, 'b> SubContext<'a, 'b> {
27912792
// module syntax in the snippet to a CommonJS module, which is in theory
27922793
// not that hard but is a chunk of work to do.
27932794
if is_local_snippet && self.cx.config.mode.nodejs() {
2794-
bail!(
2795-
"local JS snippets are not supported with `--nodejs`; \
2796-
see rustwasm/rfcs#6 for more details, but this restriction \
2797-
will be lifted in the future"
2798-
);
2795+
// have a small unergonomic escape hatch for our webidl-tests tests
2796+
if env::var("WBINDGEN_I_PROMISE_JS_SYNTAX_WORKS_IN_NODE").is_err() {
2797+
bail!(
2798+
"local JS snippets are not supported with `--nodejs`; \
2799+
see rustwasm/rfcs#6 for more details, but this restriction \
2800+
will be lifted in the future"
2801+
);
2802+
}
27992803
}
28002804

28012805
// Similar to `--no-modules`, only allow vendor prefixes basically for web

crates/webidl-tests/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ fn main() {
2121

2222
let out_file = out_dir.join(path.file_name().unwrap()).with_extension("rs");
2323

24-
let js_file = path.with_extension("js").canonicalize().unwrap();
2524
generated_rust.push_str(&format!(
2625
r#"
2726
pub mod import_script {{
2827
use wasm_bindgen::prelude::*;
2928
use wasm_bindgen_test::*;
3029
31-
#[wasm_bindgen(module = r"{}")]
30+
#[wasm_bindgen(module = "/{}.js")]
3231
extern "C" {{
3332
fn not_actually_a_function{1}(x: &str);
3433
}}
@@ -41,7 +40,7 @@ fn main() {
4140
}}
4241
}}
4342
"#,
44-
js_file.display(),
43+
path.file_stem().unwrap().to_str().unwrap(),
4544
i
4645
));
4746

0 commit comments

Comments
 (0)