|
|
@ -8,18 +8,16 @@ use wasm_pack::{self, manifest}; |
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn it_gets_the_crate_name_default_path() { |
|
|
|
fn it_gets_the_crate_name_default_path() { |
|
|
|
let path = &PathBuf::from("."); |
|
|
|
let path = &PathBuf::from("."); |
|
|
|
assert!(manifest::get_crate_name(path).is_ok()); |
|
|
|
let crate_data = manifest::CargoManifest::read(&path).unwrap(); |
|
|
|
assert_eq!(manifest::get_crate_name(path).unwrap(), "wasm-pack"); |
|
|
|
let name = crate_data.get_crate_name(); |
|
|
|
|
|
|
|
assert_eq!(name, "wasm-pack"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn it_gets_the_crate_name_provided_path() { |
|
|
|
fn it_gets_the_crate_name_provided_path() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
assert!(manifest::get_crate_name(&fixture.path).is_ok()); |
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
assert_eq!(crate_data.get_crate_name(), "js-hello-world"); |
|
|
|
manifest::get_crate_name(&fixture.path).unwrap(), |
|
|
|
|
|
|
|
"js-hello-world" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -27,8 +25,9 @@ fn it_checks_has_cdylib_default_path() { |
|
|
|
let fixture = fixture::no_cdylib(); |
|
|
|
let fixture = fixture::no_cdylib(); |
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
fixture.cargo_check(); |
|
|
|
fixture.cargo_check(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_err()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -36,15 +35,17 @@ fn it_checks_has_cdylib_provided_path() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
fixture.cargo_check(); |
|
|
|
fixture.cargo_check(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_ok()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_ok()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn it_checks_has_cdylib_wrong_crate_type() { |
|
|
|
fn it_checks_has_cdylib_wrong_crate_type() { |
|
|
|
let fixture = fixture::bad_cargo_toml(); |
|
|
|
let fixture = fixture::bad_cargo_toml(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_err()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -52,17 +53,21 @@ fn it_recognizes_a_map_during_depcheck() { |
|
|
|
let fixture = fixture::serde_feature(); |
|
|
|
let fixture = fixture::serde_feature(); |
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
fixture.cargo_check(); |
|
|
|
fixture.cargo_check(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_ok()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_ok()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn it_creates_a_package_json_default_path() { |
|
|
|
fn it_creates_a_package_json_default_path() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
assert!(crate_data |
|
|
|
|
|
|
|
.write_package_json(&out_dir, &None, false, "", &step) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
@ -93,9 +98,12 @@ fn it_creates_a_package_json_default_path() { |
|
|
|
fn it_creates_a_package_json_provided_path() { |
|
|
|
fn it_creates_a_package_json_provided_path() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
assert!(crate_data |
|
|
|
|
|
|
|
.write_package_json(&out_dir, &None, false, "", &step) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
@ -119,17 +127,12 @@ fn it_creates_a_package_json_provided_path() { |
|
|
|
fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json( |
|
|
|
assert!(crate_data |
|
|
|
&fixture.path, |
|
|
|
.write_package_json(&out_dir, &Some("test".to_string()), false, "", &step) |
|
|
|
&out_dir, |
|
|
|
.is_ok()); |
|
|
|
&Some("test".to_string()), |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
&step |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
@ -153,12 +156,12 @@ fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!( |
|
|
|
assert!(crate_data |
|
|
|
manifest::write_package_json(&fixture.path, &out_dir, &None, false, "nodejs", &step) |
|
|
|
.write_package_json(&out_dir, &None, false, "nodejs", &step) |
|
|
|
.is_ok() |
|
|
|
.is_ok()); |
|
|
|
); |
|
|
|
|
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
@ -188,17 +191,12 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_nomodules() { |
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_nomodules() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json( |
|
|
|
assert!(crate_data |
|
|
|
&fixture.path, |
|
|
|
.write_package_json(&out_dir, &None, false, "no-modules", &step) |
|
|
|
&out_dir, |
|
|
|
.is_ok()); |
|
|
|
&None, |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
"no-modules", |
|
|
|
|
|
|
|
&step |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
|
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
@ -228,9 +226,12 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() { |
|
|
|
fn it_creates_a_pkg_json_in_out_dir() { |
|
|
|
fn it_creates_a_pkg_json_in_out_dir() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("./custom/out"); |
|
|
|
let out_dir = fixture.path.join("./custom/out"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
assert!(crate_data |
|
|
|
|
|
|
|
.write_package_json(&out_dir, &None, false, "", &step) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
|
|
|
|
|
|
|
|
let package_json_path = &fixture.path.join(&out_dir).join("package.json"); |
|
|
|
let package_json_path = &fixture.path.join(&out_dir).join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
@ -241,9 +242,12 @@ fn it_creates_a_pkg_json_in_out_dir() { |
|
|
|
fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() { |
|
|
|
fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, true, "", &step).is_ok()); |
|
|
|
assert!(crate_data |
|
|
|
|
|
|
|
.write_package_json(&out_dir, &None, true, "", &step) |
|
|
|
|
|
|
|
.is_ok()); |
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
@ -267,8 +271,9 @@ fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() { |
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn it_errors_when_wasm_bindgen_is_not_declared() { |
|
|
|
fn it_errors_when_wasm_bindgen_is_not_declared() { |
|
|
|
let fixture = fixture::bad_cargo_toml(); |
|
|
|
let fixture = fixture::bad_cargo_toml(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_err()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -276,6 +281,7 @@ fn it_does_not_error_when_wasm_bindgen_is_declared() { |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
// Ensure that there is a `Cargo.lock`.
|
|
|
|
fixture.cargo_check(); |
|
|
|
fixture.cargo_check(); |
|
|
|
|
|
|
|
let crate_data = manifest::CargoManifest::read(&fixture.path).unwrap(); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
assert!(manifest::check_crate_config(&fixture.path, &step).is_ok()); |
|
|
|
assert!(crate_data.check_crate_config(&step).is_ok()); |
|
|
|
} |
|
|
|
} |
|
|
|