Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
chore: Run latest rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
drager committed Nov 7, 2018
1 parent b47dfa3 commit 99b9602
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 78 deletions.
6 changes: 4 additions & 2 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ fn wasm_bindgen_version_check(bindgen_path: &PathBuf, dep_version: &str, log: &L
dep_version
);
v == dep_version
}).unwrap_or(false)
}).unwrap_or(false)
})
.unwrap_or(false)
})
.unwrap_or(false)
}
8 changes: 3 additions & 5 deletions tests/all/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ fn downloading_prebuilt_wasm_bindgen_handles_http_errors() {
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(bad_version))
);
assert!(error
.iter_chain()
.any(|e| e.to_string().contains(bad_version)));
}
28 changes: 17 additions & 11 deletions tests/all/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ fn build_in_non_crate_directory_doesnt_panic() {
"wasm-pack",
"build",
&fixture.path.display().to_string(),
]).unwrap();
])
.unwrap();
let result = fixture.run(cli.cmd);
assert!(
result.is_err(),
"running wasm-pack in a non-crate directory should fail, but it should not panic"
);
let err = result.unwrap_err();
assert!(
err.iter_chain()
.any(|e| e.to_string().contains("missing a `Cargo.toml`"))
);
assert!(err
.iter_chain()
.any(|e| e.to_string().contains("missing a `Cargo.toml`")));
}

#[test]
Expand All @@ -31,7 +31,8 @@ fn it_should_build_js_hello_world_example() {
"wasm-pack",
"build",
&fixture.path.display().to_string(),
]).unwrap();
])
.unwrap();
fixture.run(cli.cmd).unwrap();
}

Expand All @@ -45,7 +46,8 @@ fn it_should_build_crates_in_a_workspace() {
[workspace]
members = ["blah"]
"#,
).file(
)
.file(
Path::new("blah").join("Cargo.toml"),
r#"
[package]
Expand All @@ -62,7 +64,8 @@ fn it_should_build_crates_in_a_workspace() {
[dependencies]
wasm-bindgen = "=0.2.21"
"#,
).file(
)
.file(
Path::new("blah").join("src").join("lib.rs"),
r#"
extern crate wasm_bindgen;
Expand All @@ -77,7 +80,8 @@ fn it_should_build_crates_in_a_workspace() {
"wasm-pack",
"build",
&fixture.path.join("blah").display().to_string(),
]).unwrap();
])
.unwrap();
fixture.run(cli.cmd).unwrap();
}

Expand All @@ -101,7 +105,8 @@ fn renamed_crate_name_works() {
[dependencies]
wasm-bindgen = "=0.2.21"
"#,
).file(
)
.file(
"src/lib.rs",
r#"
extern crate wasm_bindgen;
Expand All @@ -116,6 +121,7 @@ fn renamed_crate_name_works() {
"wasm-pack",
"build",
&fixture.path.display().to_string(),
]).unwrap();
])
.unwrap();
fixture.run(cli.cmd).unwrap();
}
18 changes: 12 additions & 6 deletions tests/all/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[workspace]
members = ["./blah"]
"#,
).file(
)
.file(
"blah/Cargo.toml",
r#"
[package]
Expand All @@ -47,7 +48,8 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() {
[dependencies]
wasm-bindgen = "=0.2.21"
"#,
).file(
)
.file(
"blah/src/lib.rs",
r#"
extern crate wasm_bindgen;
Expand All @@ -73,7 +75,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[workspace]
members = ["./parent", "./child"]
"#,
).file(
)
.file(
"child/Cargo.toml",
r#"
[package]
Expand All @@ -90,7 +93,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[dependencies]
wasm-bindgen = "=0.2.21"
"#,
).file(
)
.file(
"child/src/lib.rs",
r#"
extern crate wasm_bindgen;
Expand All @@ -99,7 +103,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
#[wasm_bindgen]
pub fn hello() -> u32 { 42 }
"#,
).file(
)
.file(
"parent/Cargo.toml",
r#"
[package]
Expand All @@ -113,7 +118,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() {
[lib]
crate-type = ["cdylib"]
"#,
).file(
)
.file(
"parent/src/lib.rs",
r#"
// Just re-export all of `child`.
Expand Down
86 changes: 36 additions & 50 deletions tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ fn it_creates_a_package_json_default_path() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap();
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&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");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand All @@ -90,9 +88,9 @@ fn it_creates_a_package_json_default_path() {
"js_hello_world.d.ts",
"js_hello_world.js",
]
.iter()
.map(|&s| String::from(s))
.collect();
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

Expand All @@ -103,11 +101,9 @@ fn it_creates_a_package_json_provided_path() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap();
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&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");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand All @@ -121,9 +117,9 @@ fn it_creates_a_package_json_provided_path() {
"js_hello_world.d.ts",
"js_hello_world.js",
]
.iter()
.map(|&s| String::from(s))
.collect();
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

Expand All @@ -134,11 +130,9 @@ fn it_creates_a_package_json_provided_path_with_scope() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap();
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&out_dir, &Some("test".to_string()), false, "", &step)
.is_ok()
);
assert!(crate_data
.write_package_json(&out_dir, &Some("test".to_string()), false, "", &step)
.is_ok());
let package_json_path = &fixture.path.join("pkg").join("package.json");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand All @@ -152,9 +146,9 @@ fn it_creates_a_package_json_provided_path_with_scope() {
"js_hello_world.d.ts",
"js_hello_world.js",
]
.iter()
.map(|&s| String::from(s))
.collect();
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

Expand All @@ -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 step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&out_dir, &None, false, "nodejs", &step)
.is_ok()
);
assert!(crate_data
.write_package_json(&out_dir, &None, false, "nodejs", &step)
.is_ok());
let package_json_path = &out_dir.join("package.json");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand All @@ -190,9 +182,9 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
"js_hello_world.d.ts",
"js_hello_world.js",
]
.iter()
.map(|&s| String::from(s))
.collect();
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

Expand All @@ -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 step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&out_dir, &None, false, "no-modules", &step)
.is_ok()
);
assert!(crate_data
.write_package_json(&out_dir, &None, false, "no-modules", &step)
.is_ok());
let package_json_path = &out_dir.join("package.json");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand All @@ -227,9 +217,9 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() {
"js_hello_world.js",
"js_hello_world.d.ts",
]
.iter()
.map(|&s| String::from(s))
.collect();
.iter()
.map(|&s| String::from(s))
.collect();
assert_eq!(actual_files, expected_files);
}

Expand All @@ -240,11 +230,9 @@ fn it_creates_a_pkg_json_in_out_dir() {
let crate_data = manifest::CrateData::new(&fixture.path).unwrap();
let step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&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");
fs::metadata(package_json_path).unwrap();
Expand All @@ -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 step = wasm_pack::progressbar::Step::new(1);
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap();
assert!(
crate_data
.write_package_json(&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");
fs::metadata(package_json_path).unwrap();
utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap();
Expand Down
6 changes: 4 additions & 2 deletions tests/all/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ fn complains_about_missing_wasm_bindgen_test_dependency() {
[dev-dependencies]
# no wasm-bindgen-test dep here!
"#,
).hello_world_src_lib()
)
.hello_world_src_lib()
.install_local_wasm_bindgen();

let cmd = Command::Test(test::TestOptions {
Expand Down Expand Up @@ -265,7 +266,8 @@ fn renamed_crate_name_works() {
[dev-dependencies]
wasm-bindgen-test = "=0.2.21"
"#,
).file(
)
.file(
"src/lib.rs",
r#"
extern crate wasm_bindgen;
Expand Down
6 changes: 4 additions & 2 deletions tests/all/utils/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "0.2.19"
"#,
).file(
)
.file(
"src/lib.rs",
r#"
extern crate wasm_bindgen;
Expand All @@ -355,7 +356,8 @@ pub fn wbg_test_diff_versions() -> Fixture {
#[wasm_bindgen]
pub fn one() -> u32 { 1 }
"#,
).file(
)
.file(
"tests/node.rs",
r#"
extern crate wbg_test_diff_versions;
Expand Down

0 comments on commit 99b9602

Please sign in to comment.