Skip to content

Commit dcdfdfc

Browse files
authored
ci: parallelize e2e suite re-emit loop (#786)
1 parent e318ada commit dcdfdfc

3 files changed

Lines changed: 48 additions & 29 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ emit = { package = "lisette-emit", path = "../crates/emit" }
1515
stdlib = { package = "lisette-stdlib", path = "../crates/stdlib" }
1616
deps = { package = "lisette-deps", path = "../crates/deps" }
1717
rustc-hash.workspace = true
18+
rayon.workspace = true
1819
insta.workspace = true
1920
miette.workspace = true
2021
serde.workspace = true

tests/e2e_suite.rs

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ mod harness;
66
use std::fs;
77
use std::process::Command;
88

9+
use rayon::prelude::*;
10+
911
use harness::{
1012
EmittedTest, HarvestedTest, compile_e2e_suite_test, harvest_snapshots, prelude_dir,
1113
read_go_version, read_skip_list, run_go_test, run_go_vet, skip_reason_for_imports,
@@ -38,40 +40,55 @@ fn e2e_suite() {
3840

3941
let skip_list = read_skip_list();
4042

43+
enum Outcome {
44+
Denylist(String),
45+
SkippedImport(String, String),
46+
EmitFailure(String, String),
47+
Included(String),
48+
BuildOnly(String),
49+
}
50+
51+
let outcomes: Vec<Outcome> = harvested
52+
.par_iter()
53+
.map(
54+
|HarvestedTest {
55+
name,
56+
input,
57+
snap_body,
58+
}| {
59+
if skip_list.contains(name) {
60+
return Outcome::Denylist(name.clone());
61+
}
62+
if let Some(reason) = skip_reason_for_imports(snap_body) {
63+
return Outcome::SkippedImport(name.clone(), reason);
64+
}
65+
let EmittedTest { go_code, entry } =
66+
match compile_e2e_suite_test(input, &format!("test_{name}")) {
67+
Ok(emitted) => emitted,
68+
Err(error) => return Outcome::EmitFailure(name.clone(), error),
69+
};
70+
write_subpackage(&target, name, &go_code, entry).expect("write subpackage");
71+
if entry.is_some() {
72+
Outcome::Included(name.clone())
73+
} else {
74+
Outcome::BuildOnly(name.clone())
75+
}
76+
},
77+
)
78+
.collect();
79+
4180
let mut emit_failures = Vec::new();
4281
let mut skipped_imports = Vec::new();
4382
let mut skipped_denylist = Vec::new();
4483
let mut build_only = Vec::new();
4584
let mut included = Vec::new();
46-
47-
for HarvestedTest {
48-
name,
49-
input,
50-
snap_body,
51-
} in &harvested
52-
{
53-
if skip_list.contains(name) {
54-
skipped_denylist.push(name.clone());
55-
continue;
56-
}
57-
if let Some(reason) = skip_reason_for_imports(snap_body) {
58-
skipped_imports.push((name.clone(), reason));
59-
continue;
60-
}
61-
let result = match compile_e2e_suite_test(input, &format!("test_{name}")) {
62-
Ok(r) => r,
63-
Err(e) => {
64-
emit_failures.push((name.clone(), e));
65-
continue;
66-
}
67-
};
68-
let EmittedTest { go_code, entry } = result;
69-
70-
write_subpackage(&target, name, &go_code, entry).expect("write subpackage");
71-
if entry.is_some() {
72-
included.push(name.clone());
73-
} else {
74-
build_only.push(name.clone());
85+
for outcome in outcomes {
86+
match outcome {
87+
Outcome::Denylist(name) => skipped_denylist.push(name),
88+
Outcome::SkippedImport(name, reason) => skipped_imports.push((name, reason)),
89+
Outcome::EmitFailure(name, error) => emit_failures.push((name, error)),
90+
Outcome::Included(name) => included.push(name),
91+
Outcome::BuildOnly(name) => build_only.push(name),
7592
}
7693
}
7794

0 commit comments

Comments
 (0)