4 use std::process::Command;
5 use std::path::{Path, PathBuf};
12 lock: Option<&'static str>,
13 packages: &'static [&'static str],
16 const TEST_REPOS: &'static [Test] = &[
19 repo: "https://github.com/iron/iron",
20 sha: "cf056ea5e8052c1feea6141e40ab0306715a2c33",
26 repo: "https://github.com/BurntSushi/ripgrep",
27 sha: "ad9befbc1d3b5c695e7f6b6734ee1b8e683edd41",
33 repo: "https://github.com/XAMPPRocky/tokei",
34 sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928",
40 repo: "https://github.com/dzamlo/treeify",
41 sha: "999001b223152441198f117a68fb81f57bc086dd",
47 repo: "https://github.com/BurntSushi/xsv",
48 sha: "66956b6bfd62d6ac767a6b6499c982eae20a2c9f",
54 repo: "https://github.com/servo/servo",
55 sha: "caac107ae8145ef2fd20365e2b8fadaf09c2eb3b",
57 // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox.
58 // This takes much less time to build than all of Servo and supports stable Rust.
59 packages: &["selectors"],
63 repo: "https://github.com/servo/webrender",
64 sha: "a3d6e6894c5a601fa547c6273eb963ca1321c2bb",
71 let args = env::args().collect::<Vec<_>>();
72 let ref cargo = args[1];
73 let out_dir = Path::new(&args[2]);
74 let ref cargo = Path::new(cargo);
76 for test in TEST_REPOS.iter().rev() {
77 test_repo(cargo, out_dir, test);
81 fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) {
82 println!("testing {}", test.repo);
83 let dir = clone_repo(test, out_dir);
84 if let Some(lockfile) = test.lock {
85 fs::write(&dir.join("Cargo.lock"), lockfile).unwrap();
87 if !run_cargo_test(cargo, &dir, test.packages) {
88 panic!("tests failed for {}", test.repo);
92 fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
93 let out_dir = out_dir.join(test.name);
95 if !out_dir.join(".git").is_dir() {
96 let status = Command::new("git")
101 assert!(status.success());
104 // Try progressively deeper fetch depths to find the commit
105 let mut found = false;
106 for depth in &[0, 1, 10, 100, 1000, 100000] {
108 let status = Command::new("git")
112 .arg(&format!("--depth={}", depth))
113 .current_dir(&out_dir)
116 assert!(status.success());
119 let status = Command::new("git")
123 .current_dir(&out_dir)
127 if status.success() {
134 panic!("unable to find commit {}", test.sha)
136 let status = Command::new("git")
139 .current_dir(&out_dir)
142 assert!(status.success());
147 fn run_cargo_test(cargo_path: &Path, crate_path: &Path, packages: &[&str]) -> bool {
148 let mut command = Command::new(cargo_path);
150 for name in packages {
151 command.arg("-p").arg(name);
154 // Disable rust-lang/cargo's cross-compile tests
155 .env("CFG_DISABLE_CROSS_TESTS", "1")
156 // Relax #![deny(warnings)] in some crates
157 .env("RUSTFLAGS", "--cap-lints warn")
158 .current_dir(crate_path)