Skip to content

Commit 99a33b3

Browse files
committedDec 1, 2020
Adding diesel to the cargetest suite
This was proposed in rust-lang#79459 and rust-lang#79560. Diesel stresses the trait system implementation quite a lot and there have been various regressions regarding that in the past.
1 parent 2b17f02 commit 99a33b3

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed
 

‎src/tools/cargotest/main.rs

+48-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ struct Test {
99
sha: &'static str,
1010
lock: Option<&'static str>,
1111
packages: &'static [&'static str],
12+
features: Option<&'static [&'static str]>,
13+
manifest_path: Option<&'static str>,
1214
}
1315

1416
const TEST_REPOS: &[Test] = &[
@@ -18,27 +20,35 @@ const TEST_REPOS: &[Test] = &[
1820
sha: "cf056ea5e8052c1feea6141e40ab0306715a2c33",
1921
lock: None,
2022
packages: &[],
23+
features: None,
24+
manifest_path: None,
2125
},
2226
Test {
2327
name: "ripgrep",
2428
repo: "https://github.com/BurntSushi/ripgrep",
2529
sha: "3de31f752729525d85a3d1575ac1978733b3f7e7",
2630
lock: None,
2731
packages: &[],
32+
features: None,
33+
manifest_path: None,
2834
},
2935
Test {
3036
name: "tokei",
3137
repo: "https://github.com/XAMPPRocky/tokei",
3238
sha: "fdf3f8cb279a7aeac0696c87e5d8b0cd946e4f9e",
3339
lock: None,
3440
packages: &[],
41+
features: None,
42+
manifest_path: None,
3543
},
3644
Test {
3745
name: "xsv",
3846
repo: "https://github.com/BurntSushi/xsv",
3947
sha: "66956b6bfd62d6ac767a6b6499c982eae20a2c9f",
4048
lock: None,
4149
packages: &[],
50+
features: None,
51+
manifest_path: None,
4252
},
4353
Test {
4454
name: "servo",
@@ -48,6 +58,23 @@ const TEST_REPOS: &[Test] = &[
4858
// Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox.
4959
// This takes much less time to build than all of Servo and supports stable Rust.
5060
packages: &["selectors"],
61+
features: None,
62+
manifest_path: None,
63+
},
64+
Test {
65+
name: "diesel",
66+
repo: "https://github.com/diesel-rs/diesel",
67+
sha: "91493fe47175076f330ce5fc518f0196c0476f56",
68+
lock: None,
69+
packages: &[],
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"),
5178
},
5279
];
5380

@@ -68,7 +95,7 @@ fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) {
6895
if let Some(lockfile) = test.lock {
6996
fs::write(&dir.join("Cargo.lock"), lockfile).unwrap();
7097
}
71-
if !run_cargo_test(cargo, &dir, test.packages) {
98+
if !run_cargo_test(cargo, &dir, test.packages, test.features, test.manifest_path) {
7299
panic!("tests failed for {}", test.repo);
73100
}
74101
}
@@ -120,12 +147,31 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
120147
out_dir
121148
}
122149

123-
fn run_cargo_test(cargo_path: &Path, crate_path: &Path, packages: &[&str]) -> bool {
150+
fn run_cargo_test(
151+
cargo_path: &Path,
152+
crate_path: &Path,
153+
packages: &[&str],
154+
features: Option<&[&str]>,
155+
manifest_path: Option<&str>,
156+
) -> bool {
124157
let mut command = Command::new(cargo_path);
125158
command.arg("test");
159+
160+
if let Some(path) = manifest_path {
161+
command.arg(format!("--manifest-path={}", path));
162+
}
163+
164+
if let Some(features) = features {
165+
command.arg("--no-default-features");
166+
for feature in features {
167+
command.arg(format!("--features={}", feature));
168+
}
169+
}
170+
126171
for name in packages {
127172
command.arg("-p").arg(name);
128173
}
174+
129175
let status = command
130176
// Disable rust-lang/cargo's cross-compile tests
131177
.env("CFG_DISABLE_CROSS_TESTS", "1")

0 commit comments

Comments
 (0)
Please sign in to comment.