diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..5d8c2cd4 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,14 @@ +# Windows MSVC: bump the main-thread stack from the default 1 MiB to 8 MiB. +# +# Rust debug builds produce very large async state machines (no optimisation +# collapses them), and `#[tokio::main]` polls the top-level future on the main +# thread. The compile path nests many async fns whose combined Future state +# easily exceeds 1 MiB, crashing with `thread 'main' has overflowed its stack` +# on a stock `cargo build` + `target\debug\ado-aw.exe compile ` run. +# +# 8 MiB matches the Linux default and is what the binary already gets on +# Linux/macOS, so applying it on Windows just restores parity rather than +# introducing a platform-specific quirk. Release builds work either way; this +# only matters in practice for debug/test builds. +[target.'cfg(all(windows, target_env = "msvc"))'] +rustflags = ["-C", "link-arg=/STACK:8388608"] diff --git a/tests/compiler_tests.rs b/tests/compiler_tests.rs index 78d350a7..85de086e 100644 --- a/tests/compiler_tests.rs +++ b/tests/compiler_tests.rs @@ -851,11 +851,17 @@ fn test_1es_compiled_output_no_unreplaced_markers() { )); fs::create_dir_all(&temp_dir).expect("Failed to create temp directory"); - let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + let fixture_src = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests") .join("fixtures") .join("1es-test-agent.md"); + // Copy the fixture into the temp dir before compiling so codemods + // (e.g. pool_object_form) can never rewrite the source tree, and + // parallel test runs cannot race on the same input file. + let fixture_path = temp_dir.join("1es-test-agent.md"); + fs::copy(&fixture_src, &fixture_path).expect("Failed to copy 1ES fixture into temp dir"); + let output_path = temp_dir.join("1es-test-agent.yml"); // Run the compiler binary @@ -3520,11 +3526,20 @@ fn compile_fixture_with_flags(fixture_name: &str, extra_flags: &[&str]) -> Strin )); fs::create_dir_all(&temp_dir).expect("Failed to create temp directory"); - let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + let fixture_src = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("tests") .join("fixtures") .join(fixture_name); + // Copy the fixture into the temp dir before compiling. Codemods + // (e.g. pool_object_form) may rewrite the source on disk; copying + // keeps the canonical fixture under tests/fixtures pristine and + // prevents parallel tests that target the same fixture from + // racing on the lost-update guard in compile. + let fixture_path = temp_dir.join(fixture_name); + fs::copy(&fixture_src, &fixture_path) + .unwrap_or_else(|e| panic!("Failed to copy fixture {fixture_name} into temp dir: {e}")); + let output_path = temp_dir.join(fixture_name.replace(".md", ".yml")); let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));