chore: Run latest rustfmt

master
Jesper Håkansson 7 years ago
parent b47dfa3009
commit 99b9602d31
  1. 6
      src/bindgen.rs
  2. 8
      tests/all/bindgen.rs
  3. 28
      tests/all/build.rs
  4. 18
      tests/all/lockfile.rs
  5. 86
      tests/all/manifest.rs
  6. 6
      tests/all/test.rs
  7. 6
      tests/all/utils/fixture.rs

@ -207,6 +207,8 @@ fn wasm_bindgen_version_check(bindgen_path: &PathBuf, dep_version: &str, log: &L
dep_version dep_version
); );
v == dep_version v == dep_version
}).unwrap_or(false) })
}).unwrap_or(false) .unwrap_or(false)
})
.unwrap_or(false)
} }

@ -31,9 +31,7 @@ fn downloading_prebuilt_wasm_bindgen_handles_http_errors() {
let error = result.err().unwrap(); let error = result.err().unwrap();
assert!(error.iter_chain().any(|e| e.to_string().contains("404"))); assert!(error.iter_chain().any(|e| e.to_string().contains("404")));
assert!( assert!(error
error .iter_chain()
.iter_chain() .any(|e| e.to_string().contains(bad_version)));
.any(|e| e.to_string().contains(bad_version))
);
} }

@ -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!( assert!(err
err.iter_chain() .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,7 +31,8 @@ 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();
} }
@ -45,7 +46,8 @@ 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]
@ -62,7 +64,8 @@ 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;
@ -77,7 +80,8 @@ 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();
} }
@ -101,7 +105,8 @@ 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;
@ -116,6 +121,7 @@ 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,7 +30,8 @@ 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]
@ -47,7 +48,8 @@ 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;
@ -73,7 +75,8 @@ 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]
@ -90,7 +93,8 @@ 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;
@ -99,7 +103,8 @@ 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]
@ -113,7 +118,8 @@ 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,11 +65,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &None, false, "", &step)
.write_package_json(&out_dir, &None, false, "", &step) .is_ok());
.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();
@ -90,9 +88,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);
} }
@ -103,11 +101,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &None, false, "", &step)
.write_package_json(&out_dir, &None, false, "", &step) .is_ok());
.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();
@ -121,9 +117,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);
} }
@ -134,11 +130,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &Some("test".to_string()), false, "", &step)
.write_package_json(&out_dir, &Some("test".to_string()), false, "", &step) .is_ok());
.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();
@ -152,9 +146,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);
} }
@ -165,11 +159,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&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");
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();
@ -190,9 +182,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);
} }
@ -203,11 +195,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &None, false, "no-modules", &step)
.write_package_json(&out_dir, &None, false, "no-modules", &step) .is_ok());
.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();
@ -227,9 +217,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);
} }
@ -240,11 +230,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &None, false, "", &step)
.write_package_json(&out_dir, &None, false, "", &step) .is_ok());
.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();
@ -258,11 +246,9 @@ 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!( assert!(crate_data
crate_data .write_package_json(&out_dir, &None, true, "", &step)
.write_package_json(&out_dir, &None, true, "", &step) .is_ok());
.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();

@ -200,7 +200,8 @@ fn complains_about_missing_wasm_bindgen_test_dependency() {
[dev-dependencies] [dev-dependencies]
# no wasm-bindgen-test dep here! # no wasm-bindgen-test dep here!
"#, "#,
).hello_world_src_lib() )
.hello_world_src_lib()
.install_local_wasm_bindgen(); .install_local_wasm_bindgen();
let cmd = Command::Test(test::TestOptions { let cmd = Command::Test(test::TestOptions {
@ -265,7 +266,8 @@ fn renamed_crate_name_works() {
[dev-dependencies] [dev-dependencies]
wasm-bindgen-test = "=0.2.21" wasm-bindgen-test = "=0.2.21"
"#, "#,
).file( )
.file(
"src/lib.rs", "src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;

@ -346,7 +346,8 @@ pub fn wbg_test_diff_versions() -> Fixture {
# wasm-bindgen-test at 0.2.19, and everything should still work. # wasm-bindgen-test at 0.2.19, and everything should still work.
wasm-bindgen-test = "0.2.19" wasm-bindgen-test = "0.2.19"
"#, "#,
).file( )
.file(
"src/lib.rs", "src/lib.rs",
r#" r#"
extern crate wasm_bindgen; extern crate wasm_bindgen;
@ -355,7 +356,8 @@ pub fn wbg_test_diff_versions() -> Fixture {
#[wasm_bindgen] #[wasm_bindgen]
pub fn one() -> u32 { 1 } pub fn one() -> u32 { 1 }
"#, "#,
).file( )
.file(
"tests/node.rs", "tests/node.rs",
r#" r#"
extern crate wbg_test_diff_versions; extern crate wbg_test_diff_versions;

Loading…
Cancel
Save