diff --git a/tests/all/build.rs b/tests/all/build.rs index 2d8d56d3..b3dc9a96 100644 --- a/tests/all/build.rs +++ b/tests/all/build.rs @@ -1,3 +1,4 @@ +use std::path::Path; use structopt::StructOpt; use utils; use wasm_pack::Cli; @@ -34,3 +35,52 @@ fn it_should_build_js_hello_world_example() { .unwrap(); fixture.run(cli.cmd).unwrap(); } + +#[test] +fn it_should_build_crates_in_a_workspace() { + let fixture = utils::fixture::Fixture::new(); + fixture + .file( + "Cargo.toml", + r#" + [workspace] + members = ["blah"] + "#, + ) + .file( + Path::new("blah").join("Cargo.toml"), + r#" + [package] + authors = ["The wasm-pack developers"] + description = "so awesome rust+wasm package" + license = "WTFPL" + name = "blah" + repository = "https://github.com/rustwasm/wasm-pack.git" + version = "0.1.0" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + wasm-bindgen = "=0.2.21" + "#, + ) + .file( + Path::new("blah").join("src").join("lib.rs"), + r#" + extern crate wasm_bindgen; + use wasm_bindgen::prelude::*; + + #[wasm_bindgen] + pub fn hello() -> u32 { 42 } + "#, + ); + fixture.install_local_wasm_bindgen(); + let cli = Cli::from_iter_safe(vec![ + "wasm-pack", + "build", + &fixture.path.join("blah").display().to_string(), + ]) + .unwrap(); + fixture.run(cli.cmd).unwrap(); +}