From 99b9602d3102f350152e6f6c5e7e3fb29ed2c0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20H=C3=A5kansson?= Date: Wed, 7 Nov 2018 21:43:50 +0100 Subject: [PATCH] chore: Run latest rustfmt --- src/bindgen.rs | 6 ++- tests/all/bindgen.rs | 8 ++-- tests/all/build.rs | 28 ++++++++----- tests/all/lockfile.rs | 18 +++++--- tests/all/manifest.rs | 86 ++++++++++++++++---------------------- tests/all/test.rs | 6 ++- tests/all/utils/fixture.rs | 6 ++- 7 files changed, 80 insertions(+), 78 deletions(-) diff --git a/src/bindgen.rs b/src/bindgen.rs index 15be7ec..951a104 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -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) } diff --git a/tests/all/bindgen.rs b/tests/all/bindgen.rs index 5f6b481..e1077c5 100644 --- a/tests/all/bindgen.rs +++ b/tests/all/bindgen.rs @@ -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))); } diff --git a/tests/all/build.rs b/tests/all/build.rs index 7cb2136..91a15e0 100644 --- a/tests/all/build.rs +++ b/tests/all/build.rs @@ -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] @@ -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(); } @@ -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] @@ -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; @@ -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(); } @@ -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; @@ -116,6 +121,7 @@ fn renamed_crate_name_works() { "wasm-pack", "build", &fixture.path.display().to_string(), - ]).unwrap(); + ]) + .unwrap(); fixture.run(cli.cmd).unwrap(); } diff --git a/tests/all/lockfile.rs b/tests/all/lockfile.rs index 4c1fb36..01876ba 100644 --- a/tests/all/lockfile.rs +++ b/tests/all/lockfile.rs @@ -30,7 +30,8 @@ fn it_gets_wasm_bindgen_version_in_crate_inside_workspace() { [workspace] members = ["./blah"] "#, - ).file( + ) + .file( "blah/Cargo.toml", r#" [package] @@ -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; @@ -73,7 +75,8 @@ fn it_gets_wasm_bindgen_version_from_dependencies() { [workspace] members = ["./parent", "./child"] "#, - ).file( + ) + .file( "child/Cargo.toml", r#" [package] @@ -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; @@ -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] @@ -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`. diff --git a/tests/all/manifest.rs b/tests/all/manifest.rs index 9734f2c..2c60f78 100644 --- a/tests/all/manifest.rs +++ b/tests/all/manifest.rs @@ -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(); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -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(); diff --git a/tests/all/test.rs b/tests/all/test.rs index 323cc2e..718f275 100644 --- a/tests/all/test.rs +++ b/tests/all/test.rs @@ -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 { @@ -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; diff --git a/tests/all/utils/fixture.rs b/tests/all/utils/fixture.rs index b361865..b916c6b 100644 --- a/tests/all/utils/fixture.rs +++ b/tests/all/utils/fixture.rs @@ -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; @@ -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;