-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b8f6a4
commit db623f6
Showing
16 changed files
with
147 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#[macro_export] | ||
#[allow(unused)] | ||
macro_rules! test_output_snapshot { | ||
($name:ident, $start_output:literal, $init:expr) => { | ||
#[test] | ||
fn $name() { | ||
use std::path::PathBuf; | ||
use wasm_bindgen_cli_support::Bindgen; | ||
|
||
let mut bindgen = Bindgen::new(); | ||
$init(&mut bindgen); | ||
bindgen.input_path(WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
let mut settings = insta::Settings::clone_current(); | ||
settings.set_snapshot_suffix( | ||
PathBuf::from(WASM[1]) | ||
.file_stem() | ||
.unwrap() | ||
.to_str() | ||
.unwrap(), | ||
); | ||
settings.set_prepend_module_to_snapshot(false); | ||
if $start_output { | ||
settings.bind(|| insta::assert_snapshot!(output.start().unwrap())); | ||
} else { | ||
settings.bind(|| insta::assert_snapshot!(output.js())); | ||
} | ||
} | ||
}; | ||
} | ||
#[macro_export] | ||
#[allow(unused)] | ||
macro_rules! test_output_empty { | ||
($name:ident, $start_output:literal, $init:expr) => { | ||
#[test] | ||
fn $name() { | ||
use wasm_bindgen_cli_support::Bindgen; | ||
|
||
let mut bindgen = Bindgen::new(); | ||
$init(&mut bindgen); | ||
bindgen.input_path(WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
if $start_output { | ||
assert!(output.start().is_none()); | ||
} else { | ||
assert!(output.js().is_empty()); | ||
} | ||
} | ||
}; | ||
} | ||
#[macro_export] | ||
#[allow(unused)] | ||
macro_rules! test_output_error { | ||
($name:ident, $init:expr) => { | ||
#[test] | ||
fn $name() { | ||
use wasm_bindgen_cli_support::Bindgen; | ||
|
||
let mut bindgen = Bindgen::new(); | ||
$init(&mut bindgen); | ||
bindgen.input_path(WASM.concat()); | ||
|
||
let output = bindgen.generate_output(); | ||
assert!(output.is_err()); | ||
} | ||
}; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,43 @@ | ||
use wasm_bindgen_cli_support::Bindgen; | ||
|
||
const ADD_WASM: &[&str] = &[ | ||
const WASM: &[&str] = &[ | ||
std::env!("CARGO_MANIFEST_DIR"), | ||
"/../../examples/wasm-in-wasm/src/add.wasm", | ||
]; | ||
|
||
#[test] | ||
fn test_bundler_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.bundler(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
assert!(output.start().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_bundler_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.bundler(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
|
||
#[test] | ||
fn test_deno_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.deno(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
assert!(output.start().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_deno_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.deno(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
|
||
#[test] | ||
fn test_nodejs_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.nodejs(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
assert!(output.start().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_nodejs_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.nodejs(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
|
||
#[test] | ||
fn test_nodejs_module_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.nodejs_module(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.start().unwrap()); | ||
} | ||
|
||
#[test] | ||
fn test_nodejs_module_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.nodejs_module(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
|
||
#[test] | ||
fn test_web_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.web(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
assert!(output.start().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_web_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.web(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
|
||
#[test] | ||
fn test_nomodule_start() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.no_modules(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
assert!(output.start().is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_nomodule_js() { | ||
let mut bindgen = Bindgen::new(); | ||
bindgen.no_modules(true).unwrap(); | ||
bindgen.input_path(ADD_WASM.concat()); | ||
|
||
let output = bindgen.generate_output().unwrap(); | ||
insta::assert_snapshot!(output.js()); | ||
} | ||
mod common; | ||
|
||
test_output_snapshot!(test_bundler_js, false, |b: &mut Bindgen| { | ||
b.bundler(true).unwrap(); | ||
}); | ||
test_output_empty!(test_bundler_start, true, |b: &mut Bindgen| { | ||
b.bundler(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_deno_js, false, |b: &mut Bindgen| { | ||
b.deno(true).unwrap(); | ||
}); | ||
test_output_empty!(test_deno_start, true, |b: &mut Bindgen| { | ||
b.deno(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_nodejs_js, false, |b: &mut Bindgen| { | ||
b.nodejs(true).unwrap(); | ||
}); | ||
test_output_empty!(test_nodejs_start, true, |b: &mut Bindgen| { | ||
b.nodejs(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_nodejs_module_js, false, |b: &mut Bindgen| { | ||
b.nodejs_module(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_nodejs_module_start, true, |b: &mut Bindgen| { | ||
b.nodejs_module(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_web_js, false, |b: &mut Bindgen| { | ||
b.web(true).unwrap(); | ||
}); | ||
test_output_empty!(test_web_start, true, |b: &mut Bindgen| { | ||
b.web(true).unwrap(); | ||
}); | ||
test_output_snapshot!(test_nomodule_js, false, |b: &mut Bindgen| { | ||
b.no_modules(true).unwrap(); | ||
}); | ||
test_output_empty!(test_nomodule_start, true, |b: &mut Bindgen| { | ||
b.no_modules(true).unwrap(); | ||
}); |
Oops, something went wrong.