Skip to content

Commit a7f0de0

Browse files
committed
Crate cargo workspace to speed up testcases crates builds
1 parent 1a32f26 commit a7f0de0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests-build/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ fn run_test(test_file: &Path, should_pass: bool) {
1616
.and_then(|s| s.to_str())
1717
.expect("Failed to get file stem")
1818
.to_string();
19-
let temp_dir = Path::new(env!("OUT_DIR")).join(test_name);
19+
let temp_dir = Path::new(env!("OUT_DIR")).join("cases").join(test_name);
2020
if !temp_dir.exists() {
2121
fs::create_dir_all(&temp_dir).expect("Failed to create temporary directory for test");
2222
}
2323

24+
// Create a cargo workspace, to have one shared target directory for all tests
25+
let workspace_manifest = Path::new(env!("OUT_DIR")).join("Cargo.toml");
26+
if !workspace_manifest.exists() {
27+
fs::write(
28+
&workspace_manifest,
29+
"[workspace]\nresolver = \"3\"\nmembers = [\"cases/*\"]\n",
30+
)
31+
.expect("Failed to create workspace manifest");
32+
}
33+
2434
let mut manifest = Manifest::from_rust_file(test_file).unwrap();
2535
manifest.fix(test_file).unwrap();
2636
let manifest_path = temp_dir.join("Cargo.toml");

tests-build/src/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl Manifest {
131131
.unwrap_or(true)
132132
{
133133
self.package = Some(Package {
134-
name: "embedded-test".to_string(),
134+
name: test_file.file_stem().unwrap().to_str().unwrap().to_string(),
135135
edition: "2024".to_string(),
136136
});
137137
}

0 commit comments

Comments
 (0)