From 4415c72828167f9bbfe50b4c8496055d1ad40623 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 6 Sep 2018 01:12:53 +0100 Subject: [PATCH 1/4] Remove/reworksome redundant .cwd(p.root()) in tests --- tests/testsuite/install.rs | 11 ++++------- tests/testsuite/metadata.rs | 2 -- tests/testsuite/package.rs | 11 ++++------- tests/testsuite/read_manifest.rs | 1 - tests/testsuite/verify_project.rs | 1 - tests/testsuite/workspaces.rs | 3 +-- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index e1933c73d35..0189beff2b3 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -225,8 +225,7 @@ fn install_path() { cargo_process("install --path").arg(p.root()).run(); assert_has_installed_exe(cargo_home(), "foo"); - cargo_process("install --path .") - .cwd(p.root()) + p.cargo("install --path .") .with_status(101) .with_stderr( "\ @@ -692,8 +691,7 @@ fn subcommand_works_out_of_the_box() { fn installs_from_cwd_by_default() { let p = project().file("src/main.rs", "fn main() {}").build(); - cargo_process("install") - .cwd(p.root()) + p.cargo("install") .with_stderr_contains( "warning: Using `cargo install` to install the binaries for the \ project in current working directory is deprecated, \ @@ -725,8 +723,7 @@ fn installs_from_cwd_with_2018_warnings() { ).file("src/main.rs", "fn main() {}") .build(); - cargo_process("install") - .cwd(p.root()) + p.cargo("install") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr_contains( @@ -1262,6 +1259,6 @@ fn install_ignores_cargo_config() { .file("src/main.rs", "fn main() {}") .build(); - cargo_process("install bar").cwd(p.root()).with_status(0).run(); + cargo_process("install bar").with_status(0).run(); assert_has_installed_exe(cargo_home(), "bar"); } diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 2cd9db41562..7abddf77856 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -903,7 +903,6 @@ fn cargo_metadata_no_deps_cwd() { .build(); p.cargo("metadata --no-deps") - .cwd(p.root()) .with_json(MANIFEST_OUTPUT) .run(); } @@ -916,7 +915,6 @@ fn cargo_metadata_bad_version() { .build(); p.cargo("metadata --no-deps --format-version 2") - .cwd(p.root()) .with_status(1) .with_stderr_contains( "\ diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 3a8503c7d06..f6c081750ae 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -490,8 +490,7 @@ fn package_git_submodule() { None, ).unwrap(); - cargo_process("package --no-verify -v") - .cwd(project.root()) + project.cargo("package --no-verify -v") .with_stderr_contains("[ARCHIVING] bar/Makefile") .run(); } @@ -507,9 +506,8 @@ fn no_duplicates_from_modified_tracked_files() { .unwrap() .write_all(br#"fn main() { println!("A change!"); }"#) .unwrap(); - cargo_process("build").cwd(p.root()).run(); - cargo_process("package --list --allow-dirty") - .cwd(p.root()) + p.cargo("build").run(); + p.cargo("package --list --allow-dirty") .with_stdout( "\ Cargo.toml @@ -625,8 +623,7 @@ fn repackage_on_source_change() { std::mem::drop(file); // Check that cargo rebuilds the tarball - cargo_process("package") - .cwd(p.root()) + p.cargo("package") .with_stderr( "\ [WARNING] [..] diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index 51c24fc176b..c116f2a1638 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -98,7 +98,6 @@ fn cargo_read_manifest_cwd() { .build(); p.cargo("read-manifest") - .cwd(p.root()) .with_json(MANIFEST_OUTPUT) .run(); } diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs index a943dc4ead7..d368b7c9fb4 100644 --- a/tests/testsuite/verify_project.rs +++ b/tests/testsuite/verify_project.rs @@ -39,7 +39,6 @@ fn cargo_verify_project_cwd() { .build(); p.cargo("verify-project") - .cwd(p.root()) .with_stdout(verify_project_success_output()) .run(); } diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 17c28009ffd..c27cd983975 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -699,7 +699,7 @@ fn explicit_package_argument_works_with_virtual_manifest() { ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); - p.cargo("build --package bar").cwd(p.root()).run(); + p.cargo("build --package bar").run(); assert!(p.root().join("Cargo.lock").is_file()); assert!(p.bin("bar").is_file()); assert!(!p.root().join("bar/Cargo.lock").is_file()); @@ -1222,7 +1222,6 @@ fn relative_path_for_root_works() { let p = p.build(); p.cargo("build --manifest-path ./Cargo.toml") - .cwd(p.root()) .run(); p.cargo("build --manifest-path ../Cargo.toml") From 7bda434a5776e942c2291c9521d0549967792b3b Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 6 Sep 2018 07:33:24 +0100 Subject: [PATCH 2/4] support::git::Repository doesn't support .cargo (yet?) --- tests/testsuite/package.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index f6c081750ae..991b07fef08 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -506,8 +506,9 @@ fn no_duplicates_from_modified_tracked_files() { .unwrap() .write_all(br#"fn main() { println!("A change!"); }"#) .unwrap(); - p.cargo("build").run(); - p.cargo("package --list --allow-dirty") + cargo_process("build").cwd(p.root()).run(); + cargo_process("package --list --allow-dirty") + .cwd(p.root()) .with_stdout( "\ Cargo.toml From d0360240003a30ef6b254ed6bc00140a62237a2b Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 6 Sep 2018 07:36:54 +0100 Subject: [PATCH 3/4] Fix change in install::install_ignores_cargo_config --- tests/testsuite/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 0189beff2b3..ab0b3165d19 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1259,6 +1259,6 @@ fn install_ignores_cargo_config() { .file("src/main.rs", "fn main() {}") .build(); - cargo_process("install bar").with_status(0).run(); + p.cargo("install bar").with_status(0).run(); assert_has_installed_exe(cargo_home(), "bar"); } From 3b786a0dfdca41849eb16d7e28d3e77e18b48411 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 6 Sep 2018 07:37:01 +0100 Subject: [PATCH 4/4] Simplify test::install_ignores_cargo_config --- tests/testsuite/install.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index ab0b3165d19..d64e15444ef 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1240,15 +1240,6 @@ fn install_ignores_cargo_config() { pkg("bar", "0.0.1"); let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.1.0" - authors = [] - "#, - ) .file( ".cargo/config", r#" @@ -1259,6 +1250,6 @@ fn install_ignores_cargo_config() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("install bar").with_status(0).run(); + p.cargo("install bar").run(); assert_has_installed_exe(cargo_home(), "bar"); }