Skip to content

Commit e5ffb57

Browse files
committed
Treat fuchsia like a normal git repo
1 parent 0f44eb3 commit e5ffb57

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

src/tools/cargotest/main.rs

+50-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct Test {
1313
manifest_path: Option<&'static str>,
1414
/// `filters` are passed to libtest (i.e., after a `--` in the `cargo test` invocation).
1515
filters: &'static [&'static str],
16+
override_script: Option<&'static Path>,
17+
run_by_default: bool,
1618
}
1719

1820
const TEST_REPOS: &[Test] = &[
@@ -25,6 +27,8 @@ const TEST_REPOS: &[Test] = &[
2527
features: None,
2628
manifest_path: None,
2729
filters: &[],
30+
override_script: None,
31+
run_by_default: true,
2832
},
2933
Test {
3034
name: "ripgrep",
@@ -35,6 +39,8 @@ const TEST_REPOS: &[Test] = &[
3539
features: None,
3640
manifest_path: None,
3741
filters: &[],
42+
override_script: None,
43+
run_by_default: true,
3844
},
3945
Test {
4046
name: "tokei",
@@ -45,6 +51,8 @@ const TEST_REPOS: &[Test] = &[
4551
features: None,
4652
manifest_path: None,
4753
filters: &[],
54+
override_script: None,
55+
run_by_default: true,
4856
},
4957
Test {
5058
name: "xsv",
@@ -69,6 +77,8 @@ const TEST_REPOS: &[Test] = &[
6977
"test_stats::",
7078
"test_table::",
7179
],
80+
override_script: None,
81+
run_by_default: true,
7282
},
7383
Test {
7484
name: "servo",
@@ -81,6 +91,8 @@ const TEST_REPOS: &[Test] = &[
8191
features: None,
8292
manifest_path: None,
8393
filters: &[],
94+
override_script: None,
95+
run_by_default: true,
8496
},
8597
Test {
8698
name: "diesel",
@@ -97,6 +109,21 @@ const TEST_REPOS: &[Test] = &[
97109
// (This is required to set the feature flags above)
98110
manifest_path: Some("diesel/Cargo.toml"),
99111
filters: &[],
112+
override_script: None,
113+
run_by_default: true,
114+
},
115+
Test {
116+
name: "fuchsia",
117+
repo: "https://fuchsia.googlesource.com/fuchsia.git",
118+
// TODO
119+
sha: "refs/changes/58/938058/1",
120+
lock: None,
121+
packages: &[],
122+
features: None,
123+
manifest_path: None,
124+
filters: &[],
125+
override_script: Some(Path::new("scripts/rust/build_fuchsia_from_rust_ci.sh")),
126+
run_by_default: false,
100127
},
101128
];
102129

@@ -107,7 +134,10 @@ fn main() {
107134
let cargo = &Path::new(cargo);
108135

109136
for test in TEST_REPOS.iter().rev() {
110-
if args[3..].is_empty() || args[3..].iter().any(|s| s.contains(test.name)) {
137+
// TODO: uninvert run_by_default below
138+
if (args[3..].is_empty() && !test.run_by_default)
139+
|| args[3..].iter().any(|s| s.contains(test.name))
140+
{
111141
test_repo(cargo, out_dir, test);
112142
}
113143
}
@@ -119,8 +149,18 @@ fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) {
119149
if let Some(lockfile) = test.lock {
120150
fs::write(&dir.join("Cargo.lock"), lockfile).unwrap();
121151
}
122-
if !run_cargo_test(cargo, &dir, test.packages, test.features, test.manifest_path, test.filters)
123-
{
152+
let success = match test.override_script {
153+
Some(script) => run_script(&dir, script),
154+
None => run_cargo_test(
155+
cargo,
156+
&dir,
157+
test.packages,
158+
test.features,
159+
test.manifest_path,
160+
test.filters,
161+
),
162+
};
163+
if !success {
124164
panic!("tests failed for {}", test.repo);
125165
}
126166
}
@@ -148,9 +188,10 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
148188
assert!(status.success());
149189
}
150190

191+
let reset_to = if test.sha.contains('/') { "FETCH_HEAD" } else { test.sha };
151192
let status = Command::new("git")
152193
.arg("reset")
153-
.arg(test.sha)
194+
.arg(reset_to)
154195
.arg("--hard")
155196
.current_dir(&out_dir)
156197
.status()
@@ -165,6 +206,7 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf {
165206
if !found {
166207
panic!("unable to find commit {}", test.sha)
167208
}
209+
168210
let status =
169211
Command::new("git").arg("clean").arg("-fdx").current_dir(&out_dir).status().unwrap();
170212
assert!(status.success());
@@ -216,3 +258,7 @@ fn run_cargo_test(
216258

217259
status.success()
218260
}
261+
262+
fn run_script(crate_path: &Path, script: &'static Path) -> bool {
263+
Command::new(&crate_path.join(script)).status().unwrap().success()
264+
}

0 commit comments

Comments
 (0)