diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-09-15 16:13:48 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2017-10-23 13:11:12 +0200 |
| commit | 5167aac3c43fb3e727831658b780acde49b42ff7 (patch) | |
| tree | f706c82b8cd321ded7f0cff9d2d759e7fc333d61 | |
| parent | 4c053db233d69519b548e5b8ed7192d0783e582a (diff) | |
| download | rust-5167aac3c43fb3e727831658b780acde49b42ff7.tar.gz rust-5167aac3c43fb3e727831658b780acde49b42ff7.zip | |
Extend cargotest to specify packages to test (within a Cargo workspace).
| -rw-r--r-- | src/tools/cargotest/main.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 0a9da26d996..6faf307ad02 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -19,6 +19,7 @@ struct Test { name: &'static str, sha: &'static str, lock: Option<&'static str>, + packages: &'static [&'static str], } const TEST_REPOS: &'static [Test] = &[ @@ -27,30 +28,35 @@ const TEST_REPOS: &'static [Test] = &[ repo: "https://github.com/iron/iron", sha: "21c7dae29c3c214c08533c2a55ac649b418f2fe3", lock: Some(include_str!("lockfiles/iron-Cargo.lock")), + packages: &[], }, Test { name: "ripgrep", repo: "https://github.com/BurntSushi/ripgrep", sha: "b65bb37b14655e1a89c7cd19c8b011ef3e312791", lock: None, + packages: &[], }, Test { name: "tokei", repo: "https://github.com/Aaronepower/tokei", sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928", lock: None, + packages: &[], }, Test { name: "treeify", repo: "https://github.com/dzamlo/treeify", sha: "999001b223152441198f117a68fb81f57bc086dd", lock: None, + packages: &[], }, Test { name: "xsv", repo: "https://github.com/BurntSushi/xsv", sha: "4b308adbe48ac81657fd124b90b44f7c3263f771", lock: None, + packages: &[], }, ]; @@ -74,7 +80,7 @@ fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) { .write_all(lockfile.as_bytes()) .expect(""); } - if !run_cargo_test(cargo, &dir) { + if !run_cargo_test(cargo, &dir, test.packages) { panic!("tests failed for {}", test.repo); } } @@ -134,9 +140,13 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf { out_dir } -fn run_cargo_test(cargo_path: &Path, crate_path: &Path) -> bool { - let status = Command::new(cargo_path) - .arg("test") +fn run_cargo_test(cargo_path: &Path, crate_path: &Path, packages: &[&str]) -> bool { + let mut command = Command::new(cargo_path); + command.arg("test"); + for name in packages { + command.arg("-p").arg(name); + } + let status = command // Disable rust-lang/cargo's cross-compile tests .env("CFG_DISABLE_CROSS_TESTS", "1") .current_dir(crate_path) |
