Skip to content

Commit a628d09

Browse files
fix(tests): isolate fixtures from codemod rewrites and bump Windows debug stack (#613)
Copy fixtures into a per-test temp dir before invoking ado-aw compile so the pool_object_form codemod cannot race-rewrite tests/fixtures/*.md under parallel cargo test, which was tripping the lost-update guard with 'source file ... changed during compilation' on CI. Also add .cargo/config.toml setting /STACK:8388608 on Windows MSVC to match the Linux/macOS 8 MiB default. Debug builds of ado-aw compile overflow the 1 MiB Windows main-thread stack because #[tokio::main] polls the top-level future on main and the deeply-nested async fns produce very large unoptimised state machines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 93735b3 commit a628d09

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

.cargo/config.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Windows MSVC: bump the main-thread stack from the default 1 MiB to 8 MiB.
2+
#
3+
# Rust debug builds produce very large async state machines (no optimisation
4+
# collapses them), and `#[tokio::main]` polls the top-level future on the main
5+
# thread. The compile path nests many async fns whose combined Future state
6+
# easily exceeds 1 MiB, crashing with `thread 'main' has overflowed its stack`
7+
# on a stock `cargo build` + `target\debug\ado-aw.exe compile <fixture>` run.
8+
#
9+
# 8 MiB matches the Linux default and is what the binary already gets on
10+
# Linux/macOS, so applying it on Windows just restores parity rather than
11+
# introducing a platform-specific quirk. Release builds work either way; this
12+
# only matters in practice for debug/test builds.
13+
[target.'cfg(all(windows, target_env = "msvc"))']
14+
rustflags = ["-C", "link-arg=/STACK:8388608"]

tests/compiler_tests.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,11 +851,17 @@ fn test_1es_compiled_output_no_unreplaced_markers() {
851851
));
852852
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");
853853

854-
let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
854+
let fixture_src = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
855855
.join("tests")
856856
.join("fixtures")
857857
.join("1es-test-agent.md");
858858

859+
// Copy the fixture into the temp dir before compiling so codemods
860+
// (e.g. pool_object_form) can never rewrite the source tree, and
861+
// parallel test runs cannot race on the same input file.
862+
let fixture_path = temp_dir.join("1es-test-agent.md");
863+
fs::copy(&fixture_src, &fixture_path).expect("Failed to copy 1ES fixture into temp dir");
864+
859865
let output_path = temp_dir.join("1es-test-agent.yml");
860866

861867
// Run the compiler binary
@@ -3520,11 +3526,20 @@ fn compile_fixture_with_flags(fixture_name: &str, extra_flags: &[&str]) -> Strin
35203526
));
35213527
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");
35223528

3523-
let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
3529+
let fixture_src = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
35243530
.join("tests")
35253531
.join("fixtures")
35263532
.join(fixture_name);
35273533

3534+
// Copy the fixture into the temp dir before compiling. Codemods
3535+
// (e.g. pool_object_form) may rewrite the source on disk; copying
3536+
// keeps the canonical fixture under tests/fixtures pristine and
3537+
// prevents parallel tests that target the same fixture from
3538+
// racing on the lost-update guard in compile.
3539+
let fixture_path = temp_dir.join(fixture_name);
3540+
fs::copy(&fixture_src, &fixture_path)
3541+
.unwrap_or_else(|e| panic!("Failed to copy fixture {fixture_name} into temp dir: {e}"));
3542+
35283543
let output_path = temp_dir.join(fixture_name.replace(".md", ".yml"));
35293544

35303545
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));

0 commit comments

Comments
 (0)