chore: Run latest rustfmt

master
Jesper Håkansson 7 years ago
parent a558ea5e50
commit b47dfa3009
  1. 28
      tests/all/build.rs
  2. 18
      tests/all/lockfile.rs
  3. 86
      tests/all/manifest.rs

@ -10,17 +10,17 @@ fn build_in_non_crate_directory_doesnt_panic() {
"wasm-pack", "wasm-pack",
"build", "build",
&fixture.path.display().to_string(), &fixture.path.display().to_string(),
]) ]).unwrap();
.unwrap();
let result = fixture.run(cli.cmd); let result = fixture.run(cli.cmd);
assert!( assert!(
result.is_err(), result.is_err(),
"running wasm-pack in a non-crate directory should fail, but it should not panic" "running wasm-pack in a non-crate directory should fail, but it should not panic"
); );
let err = result.unwrap_err(); let err = result.unwrap_err();
assert!(err assert!(
.iter_chain() err.iter_chain()
.any(|e| e.to_string().contains("missing a `Cargo.toml`"))); .any(|e| e.to_string().contains("missing a `Cargo.toml`"))
);
} }
#[test] #[test]
@ -31,8 +31,7 @@ fn it_should_build_js_hello_world_example() {
"wasm-pack", "wasm-pack",
"build", "build",
&fixture.path.display().to_string(), &fixture.path.display().to_string(),
]) ]).unwrap();
.unwrap();
fixture.run(cli.cmd).unwrap(); fixture.run(cli.cmd).unwrap();
} }
@ -46,8 +45,7 @@ fn it_should_build_crates_in_a_workspace() {
[workspace] [workspace]
members = ["blah"] members = ["blah"]
"#, "#,
) ).file(
.file(
Path::new("blah").join("Cargo.toml"), Path::new("blah").join("Cargo.toml"),
r#" r#"
[package] [package]
@ -64,8 +62,7 @@ fn it_should_build_crates_in_a_workspace() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
) ).file(
.file(
Path::new("blah").join("src").join("lib.rs"), Path::new("blah").join("src").join("lib.rs"),
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -80,8 +77,7 @@ fn it_should_build_crates_in_a_workspace() {
"wasm-pack", "wasm-pack",
"build", "build",
&fixture.path.join("blah").display().to_string(), &fixture.path.join("blah").display().to_string(),
]) ]).unwrap();
.unwrap();
fixture.run(cli.cmd).unwrap(); fixture.run(cli.cmd).unwrap();
} }
@ -105,8 +101,7 @@ fn renamed_crate_name_works() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
) ).file(
.file(
"src/lib.rs", "src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -121,7 +116,6 @@ fn renamed_crate_name_works() {
"wasm-pack", "wasm-pack",
"build", "build",
&fixture.path.display().to_string(), &fixture.path.display().to_string(),
]) ]).unwrap();
.unwrap();
fixture.run(cli.cmd).unwrap(); fixture.run(cli.cmd).unwrap();
} }

@ -30,8 +30,7 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[workspace] [workspace]
members = ["./blah"] members = ["./blah"]
"#, "#,
) ).file(
.file(
"blah/Cargo.toml", "blah/Cargo.toml",
r#" r#"
[package] [package]
@ -48,8 +47,7 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
) ).file(
.file(
"blah/src/lib.rs", "blah/src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -75,8 +73,7 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[workspace] [workspace]
members = ["./parent", "./child"] members = ["./parent", "./child"]
"#, "#,
) ).file(
.file(
"child/Cargo.toml", "child/Cargo.toml",
r#" r#"
[package] [package]
@ -93,8 +90,7 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[dependencies] [dependencies]
wasm-bindgen = "=0.2.21" wasm-bindgen = "=0.2.21"
"#, "#,
) ).file(
.file(
"child/src/lib.rs", "child/src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -103,8 +99,7 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
#[wasm_bindgen] #[wasm_bindgen]
pub fn hello() -> u32 { 42 } pub fn hello() -> u32 { 42 }
"#, "#,
) ).file(
.file(
"parent/Cargo.toml", "parent/Cargo.toml",
r#" r#"
[package] [package]
@ -118,8 +113,7 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
"#, "#,
) ).file(
.file(
"parent/src/lib.rs", "parent/src/lib.rs",
r#" r#"
// Just re-export all of `child`. // Just re-export all of `child`.

@ -65,9 +65,11 @@ fn it_creates_a_package_json_default_path() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, false, "", &step) crate_data
.is_ok()); .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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
@ -88,9 +90,9 @@ fn it_creates_a_package_json_default_path() {
"js_hello_world.d.ts", "js_hello_world.d.ts",
"js_hello_world.js", "js_hello_world.js",
] ]
.iter() .iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -101,9 +103,11 @@ fn it_creates_a_package_json_provided_path() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, false, "", &step) crate_data
.is_ok()); .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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
@ -117,9 +121,9 @@ fn it_creates_a_package_json_provided_path() {
"js_hello_world.d.ts", "js_hello_world.d.ts",
"js_hello_world.js", "js_hello_world.js",
] ]
.iter() .iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -130,9 +134,11 @@ fn it_creates_a_package_json_provided_path_with_scope() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &Some("test".to_string()), false, "", &step) crate_data
.is_ok()); .write_package_json(&out_dir, &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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
@ -146,9 +152,9 @@ fn it_creates_a_package_json_provided_path_with_scope() {
"js_hello_world.d.ts", "js_hello_world.d.ts",
"js_hello_world.js", "js_hello_world.js",
] ]
.iter() .iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -159,9 +165,11 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, false, "nodejs", &step) crate_data
.is_ok()); .write_package_json(&out_dir, &None, false, "nodejs", &step)
.is_ok()
);
let package_json_path = &out_dir.join("package.json"); let package_json_path = &out_dir.join("package.json");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
@ -182,9 +190,9 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
"js_hello_world.d.ts", "js_hello_world.d.ts",
"js_hello_world.js", "js_hello_world.js",
] ]
.iter() .iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -195,9 +203,11 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, false, "no-modules", &step) crate_data
.is_ok()); .write_package_json(&out_dir, &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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
@ -217,9 +227,9 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() {
"js_hello_world.js", "js_hello_world.js",
"js_hello_world.d.ts", "js_hello_world.d.ts",
] ]
.iter() .iter()
.map(|&s| String::from(s)) .map(|&s| String::from(s))
.collect(); .collect();
assert_eq!(actual_files, expected_files); assert_eq!(actual_files, expected_files);
} }
@ -230,9 +240,11 @@ fn it_creates_a_pkg_json_in_out_dir() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, false, "", &step) crate_data
.is_ok()); .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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
@ -246,9 +258,11 @@ fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap(); let crate_data = manifest::CrateData::new(&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!(crate_data assert!(
.write_package_json(&out_dir, &None, true, "", &step) crate_data
.is_ok()); .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");
fs::metadata(package_json_path).unwrap(); fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();

Loading…
Cancel
Save