3 use std::path::{Path, PathBuf};
4 use std::process::Command;
10 lock: Option<&'static str>,
11 packages: &'static [&'static str],
12 features: Option<&'static [&'static str]>,
13 manifest_path: Option<&'static str>,
16 const TEST_REPOS: &[Test] = &[
19 repo: "https://github.com/iron/iron",
20 sha: "cf056ea5e8052c1feea6141e40ab0306715a2c33",
28 repo: "https://github.com/BurntSushi/ripgrep",
29 sha: "3de31f752729525d85a3d1575ac1978733b3f7e7",
37 repo: "https://github.com/XAMPPRocky/tokei",
38 sha: "fdf3f8cb279a7aeac0696c87e5d8b0cd946e4f9e",
46 repo: "https://github.com/BurntSushi/xsv",
47 sha: "3de6c04269a7d315f7e9864b9013451cd9580a08",
55 repo: "https://github.com/servo/servo",
56 sha: "caac107ae8145ef2fd20365e2b8fadaf09c2eb3b",
58 // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox.
59 // This takes much less time to build than all of Servo and supports stable Rust.
60 packages: &["selectors"],
66 repo: "https://github.com/diesel-rs/diesel",
67 sha: "91493fe47175076f330ce5fc518f0196c0476f56",
70 // Test the embeded sqlite variant of diesel
71 // This does not require any dependency to be present,
72 // sqlite will be compiled as part of the build process
73 features: Some(&["sqlite", "libsqlite3-sys/bundled"]),
74 // We are only interested in testing diesel itself
75 // not any other crate present in the diesel workspace
76 // (This is required to set the feature flags above)
77 manifest_path: Some("diesel/Cargo.toml"),
82 let args = env::args().collect::<Vec<_>>();
84 let out_dir = Path::new(&args[2]);
85 let cargo = &Path::new(cargo);
87 for test in TEST_REPOS.iter().rev() {
88 test_repo(cargo, out_dir, test);
92 fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) {
93 println!("testing {}", test.repo);
94 let dir = clone_repo(test, out_dir);
95 if let Some(lockfile) = test.lock {
96 fs::write(&dir.join("Cargo.lock"), lockfile).unwrap();
98 if !run_cargo_test(cargo, &dir, test.packages, test.features, test.manifest_path) {
99 panic!("tests failed for {}", test.repo);
103 fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
104 let out_dir = out_dir.join(test.name);
106 if !out_dir.join(".git").is_dir() {
107 let status = Command::new("git").arg("init").arg(&out_dir).status().unwrap();
108 assert!(status.success());
111 // Try progressively deeper fetch depths to find the commit
112 let mut found = false;
113 for depth in &[0, 1, 10, 100, 1000, 100000] {
115 let status = Command::new("git")
119 .arg(&format!("--depth={}", depth))
120 .current_dir(&out_dir)
123 assert!(status.success());
126 let status = Command::new("git")
130 .current_dir(&out_dir)
134 if status.success() {
141 panic!("unable to find commit {}", test.sha)
144 Command::new("git").arg("clean").arg("-fdx").current_dir(&out_dir).status().unwrap();
145 assert!(status.success());
154 features: Option<&[&str]>,
155 manifest_path: Option<&str>,
157 let mut command = Command::new(cargo_path);
160 if let Some(path) = manifest_path {
161 command.arg(format!("--manifest-path={}", path));
164 if let Some(features) = features {
165 command.arg("--no-default-features");
166 for feature in features {
167 command.arg(format!("--features={}", feature));
171 for name in packages {
172 command.arg("-p").arg(name);
176 // Disable rust-lang/cargo's cross-compile tests
177 .env("CFG_DISABLE_CROSS_TESTS", "1")
178 // Relax #![deny(warnings)] in some crates
179 .env("RUSTFLAGS", "--cap-lints warn")
180 .current_dir(crate_path)