Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(build): extract module-list generation into a reusable function

Steven Enamakelc7c0f6f89aca
diff --git a/build.rs b/build.rs
index 235a3f37b5..8cb3fe34fa 100644
--- a/build.rs
+++ b/build.rs
@@ -55,7 +55,17 @@ fn main() {
);
warn_about_silently_skipped_test_targets(Path::new(&manifest_dir));
let tests_dir = repository_root.join("tests");
- let raw_dir = tests_dir.join("raw_coverage");
+ // Two aggregated targets, one directory each: `raw_coverage_all` (needs the
+ // `voice` + `inference` gates) and `in_process_all` (gate-free router and
+ // public-API suites).
+ write_module_list(&tests_dir, "raw_coverage", "raw_coverage_mods.rs");
+ write_module_list(&tests_dir, "in_process", "in_process_mods.rs");
+}
+
+/// Glob `tests/<subdir>/*.rs` and write `$OUT_DIR/<out_name>`: one
+/// `#[path = ...] mod <stem>;` per file, for an aggregated target to `include!`.
+fn write_module_list(tests_dir: &Path, subdir: &str, out_name: &str) {
+ let raw_dir = tests_dir.join(subdir);
// Re-run whenever a file is added to / removed from the directory.
println!("cargo:rerun-if-changed={}", raw_dir.display());
@@ -66,9 +76,9 @@ fn main() {
// Source-only builds (e.g. the Docker image copies `src/` but not
// `tests/`) never compile the integration targets, so there is nothing
// to aggregate — emit an empty module list rather than breaking the
- // build. But if `tests/` IS present and only `raw_coverage/` is missing,
- // that's an accidental deletion: fail loudly so the suite can't be
- // silently dropped.
+ // build. But if `tests/` IS present and only the subdirectory is
+ // missing, that's an accidental deletion: fail loudly so the suite
+ // can't be silently dropped.
Err(_) if !tests_dir.exists() => None,
Err(e) => panic!("failed to read {}: {e}", raw_dir.display()),
};
@@ -99,8 +109,8 @@ fn main() {
}
let out_dir = env::var("OUT_DIR").expect("OUT_DIR must be set");
- let out_path = Path::new(&out_dir).join("raw_coverage_mods.rs");
- fs::write(&out_path, generated).expect("failed to write raw_coverage_mods.rs");
+ let out_path = Path::new(&out_dir).join(out_name);
+ fs::write(&out_path, generated).unwrap_or_else(|e| panic!("failed to write {out_name}: {e}"));
}
/// The env var cargo sets for an enabled feature: upper-cased, `-` to `_`.