Extend cargotest to specify packages to test (within a Cargo workspace).
This commit is contained in:
parent
4c053db233
commit
5167aac3c4
@ -19,6 +19,7 @@ struct Test {
|
|||||||
name: &'static str,
|
name: &'static str,
|
||||||
sha: &'static str,
|
sha: &'static str,
|
||||||
lock: Option<&'static str>,
|
lock: Option<&'static str>,
|
||||||
|
packages: &'static [&'static str],
|
||||||
}
|
}
|
||||||
|
|
||||||
const TEST_REPOS: &'static [Test] = &[
|
const TEST_REPOS: &'static [Test] = &[
|
||||||
@ -27,30 +28,35 @@ const TEST_REPOS: &'static [Test] = &[
|
|||||||
repo: "https://github.com/iron/iron",
|
repo: "https://github.com/iron/iron",
|
||||||
sha: "21c7dae29c3c214c08533c2a55ac649b418f2fe3",
|
sha: "21c7dae29c3c214c08533c2a55ac649b418f2fe3",
|
||||||
lock: Some(include_str!("lockfiles/iron-Cargo.lock")),
|
lock: Some(include_str!("lockfiles/iron-Cargo.lock")),
|
||||||
|
packages: &[],
|
||||||
},
|
},
|
||||||
Test {
|
Test {
|
||||||
name: "ripgrep",
|
name: "ripgrep",
|
||||||
repo: "https://github.com/BurntSushi/ripgrep",
|
repo: "https://github.com/BurntSushi/ripgrep",
|
||||||
sha: "b65bb37b14655e1a89c7cd19c8b011ef3e312791",
|
sha: "b65bb37b14655e1a89c7cd19c8b011ef3e312791",
|
||||||
lock: None,
|
lock: None,
|
||||||
|
packages: &[],
|
||||||
},
|
},
|
||||||
Test {
|
Test {
|
||||||
name: "tokei",
|
name: "tokei",
|
||||||
repo: "https://github.com/Aaronepower/tokei",
|
repo: "https://github.com/Aaronepower/tokei",
|
||||||
sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
|
sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
|
||||||
lock: None,
|
lock: None,
|
||||||
|
packages: &[],
|
||||||
},
|
},
|
||||||
Test {
|
Test {
|
||||||
name: "treeify",
|
name: "treeify",
|
||||||
repo: "https://github.com/dzamlo/treeify",
|
repo: "https://github.com/dzamlo/treeify",
|
||||||
sha: "999001b223152441198f117a68fb81f57bc086dd",
|
sha: "999001b223152441198f117a68fb81f57bc086dd",
|
||||||
lock: None,
|
lock: None,
|
||||||
|
packages: &[],
|
||||||
},
|
},
|
||||||
Test {
|
Test {
|
||||||
name: "xsv",
|
name: "xsv",
|
||||||
repo: "https://github.com/BurntSushi/xsv",
|
repo: "https://github.com/BurntSushi/xsv",
|
||||||
sha: "4b308adbe48ac81657fd124b90b44f7c3263f771",
|
sha: "4b308adbe48ac81657fd124b90b44f7c3263f771",
|
||||||
lock: None,
|
lock: None,
|
||||||
|
packages: &[],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -74,7 +80,7 @@ fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) {
|
|||||||
.write_all(lockfile.as_bytes())
|
.write_all(lockfile.as_bytes())
|
||||||
.expect("");
|
.expect("");
|
||||||
}
|
}
|
||||||
if !run_cargo_test(cargo, &dir) {
|
if !run_cargo_test(cargo, &dir, test.packages) {
|
||||||
panic!("tests failed for {}", test.repo);
|
panic!("tests failed for {}", test.repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,9 +140,13 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
|
|||||||
out_dir
|
out_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cargo_test(cargo_path: &Path, crate_path: &Path) -> bool {
|
fn run_cargo_test(cargo_path: &Path, crate_path: &Path, packages: &[&str]) -> bool {
|
||||||
let status = Command::new(cargo_path)
|
let mut command = Command::new(cargo_path);
|
||||||
.arg("test")
|
command.arg("test");
|
||||||
|
for name in packages {
|
||||||
|
command.arg("-p").arg(name);
|
||||||
|
}
|
||||||
|
let status = command
|
||||||
// Disable rust-lang/cargo's cross-compile tests
|
// Disable rust-lang/cargo's cross-compile tests
|
||||||
.env("CFG_DISABLE_CROSS_TESTS", "1")
|
.env("CFG_DISABLE_CROSS_TESTS", "1")
|
||||||
.current_dir(crate_path)
|
.current_dir(crate_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user