|
|
@ -9,7 +9,7 @@ use wasm_pack::{self, license, 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("."); |
|
|
|
let crate_data = manifest::CrateData::new(&path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&path, None).unwrap(); |
|
|
|
let name = crate_data.crate_name(); |
|
|
|
let name = crate_data.crate_name(); |
|
|
|
assert_eq!(name, "wasm_pack"); |
|
|
|
assert_eq!(name, "wasm_pack"); |
|
|
|
} |
|
|
|
} |
|
|
@ -17,7 +17,7 @@ fn it_gets_the_crate_name_default_path() { |
|
|
|
#[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(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
assert_eq!(crate_data.crate_name(), "js_hello_world"); |
|
|
|
assert_eq!(crate_data.crate_name(), "js_hello_world"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -26,7 +26,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -35,14 +35,14 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -51,7 +51,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ fn it_recognizes_a_map_during_depcheck() { |
|
|
|
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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
@ -94,7 +94,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
@ -122,7 +122,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &Some("test".to_string()), false, &Target::Bundler,) |
|
|
|
.write_package_json(&out_dir, &Some("test".to_string()), false, &Target::Bundler,) |
|
|
@ -150,7 +150,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Nodejs) |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Nodejs) |
|
|
@ -185,7 +185,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::NoModules) |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::NoModules) |
|
|
@ -219,7 +219,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
|
.write_package_json(&out_dir, &None, false, &Target::Bundler) |
|
|
@ -234,7 +234,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
assert!(crate_data |
|
|
|
assert!(crate_data |
|
|
|
.write_package_json(&out_dir, &None, true, &Target::Bundler) |
|
|
|
.write_package_json(&out_dir, &None, true, &Target::Bundler) |
|
|
@ -262,7 +262,7 @@ 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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
assert!(crate_data.check_crate_config().is_err()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -294,7 +294,7 @@ fn it_sets_homepage_field_if_available_in_cargo_toml() { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
crate_data |
|
|
|
crate_data |
|
|
@ -310,7 +310,7 @@ fn it_sets_homepage_field_if_available_in_cargo_toml() { |
|
|
|
// When 'homepage' is unavailable
|
|
|
|
// When 'homepage' is unavailable
|
|
|
|
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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
crate_data |
|
|
|
crate_data |
|
|
@ -326,7 +326,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::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
crate_data.check_crate_config().unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -410,7 +410,7 @@ fn it_lists_license_files_in_files_field_of_package_json() { |
|
|
|
let fixture = fixture::dual_license(); |
|
|
|
let fixture = fixture::dual_license(); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
|
|
|
|
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); |
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
license::copy_from_crate(&crate_data, &fixture.path, &out_dir).unwrap(); |
|
|
|
license::copy_from_crate(&crate_data, &fixture.path, &out_dir).unwrap(); |
|
|
|