]>
git.proxmox.com Git - rustc.git/blob - src/tools/cargotest/main.rs
3 use std
::path
::{Path, PathBuf}
;
4 use std
::process
::Command
;
10 lock
: Option
<&'
static str>,
11 packages
: &'
static [&'
static str],
14 const TEST_REPOS
: &'
static [Test
] = &[
17 repo
: "https://github.com/iron/iron",
18 sha
: "cf056ea5e8052c1feea6141e40ab0306715a2c33",
24 repo
: "https://github.com/BurntSushi/ripgrep",
25 sha
: "ad9befbc1d3b5c695e7f6b6734ee1b8e683edd41",
31 repo
: "https://github.com/XAMPPRocky/tokei",
32 sha
: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
38 repo
: "https://github.com/dzamlo/treeify",
39 sha
: "999001b223152441198f117a68fb81f57bc086dd",
45 repo
: "https://github.com/BurntSushi/xsv",
46 sha
: "66956b6bfd62d6ac767a6b6499c982eae20a2c9f",
52 repo
: "https://github.com/servo/servo",
53 sha
: "caac107ae8145ef2fd20365e2b8fadaf09c2eb3b",
55 // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox.
56 // This takes much less time to build than all of Servo and supports stable Rust.
57 packages
: &["selectors"],
62 let args
= env
::args().collect
::<Vec
<_
>>();
63 let ref cargo
= args
[1];
64 let out_dir
= Path
::new(&args
[2]);
65 let ref cargo
= Path
::new(cargo
);
67 for test
in TEST_REPOS
.iter().rev() {
68 test_repo(cargo
, out_dir
, test
);
72 fn test_repo(cargo
: &Path
, out_dir
: &Path
, test
: &Test
) {
73 println
!("testing {}", test
.repo
);
74 let dir
= clone_repo(test
, out_dir
);
75 if let Some(lockfile
) = test
.lock
{
76 fs
::write(&dir
.join("Cargo.lock"), lockfile
).unwrap();
78 if !run_cargo_test(cargo
, &dir
, test
.packages
) {
79 panic
!("tests failed for {}", test
.repo
);
83 fn clone_repo(test
: &Test
, out_dir
: &Path
) -> PathBuf
{
84 let out_dir
= out_dir
.join(test
.name
);
86 if !out_dir
.join(".git").is_dir() {
87 let status
= Command
::new("git").arg("init").arg(&out_dir
).status().expect("");
88 assert
!(status
.success());
91 // Try progressively deeper fetch depths to find the commit
92 let mut found
= false;
93 for depth
in &[0, 1, 10, 100, 1000, 100000] {
95 let status
= Command
::new("git")
99 .arg(&format
!("--depth={}", depth
))
100 .current_dir(&out_dir
)
103 assert
!(status
.success());
106 let status
= Command
::new("git")
110 .current_dir(&out_dir
)
114 if status
.success() {
121 panic
!("unable to find commit {}", test
.sha
)
124 Command
::new("git").arg("clean").arg("-fdx").current_dir(&out_dir
).status().unwrap();
125 assert
!(status
.success());
130 fn run_cargo_test(cargo_path
: &Path
, crate_path
: &Path
, packages
: &[&str]) -> bool
{
131 let mut command
= Command
::new(cargo_path
);
133 for name
in packages
{
134 command
.arg("-p").arg(name
);
137 // Disable rust-lang/cargo's cross-compile tests
138 .env("CFG_DISABLE_CROSS_TESTS", "1")
139 // Relax #![deny(warnings)] in some crates
140 .env("RUSTFLAGS", "--cap-lints warn")
141 .current_dir(crate_path
)