11#![ allow( clippy:: disallowed_macros) ]
22use spacetimedb_guard:: ensure_binaries_built;
3- use spacetimedb_smoketests:: { require_dotnet, workspace_root} ;
3+ use spacetimedb_smoketests:: { have_emscripten , require_dotnet, workspace_root} ;
44use std:: process:: Command ;
55
66/// Test NativeAOT-LLVM build path for C# modules.
@@ -18,8 +18,8 @@ fn test_build_csharp_module_aot() {
1818 }
1919
2020 // Check for emscripten - fail with helpful message if not available
21- let emscripten_check = Command :: new ( "emcc" ) . arg ( "--version" ) . output ( ) ;
22- if emscripten_check . is_err ( ) || !emscripten_check . unwrap ( ) . status . success ( ) {
21+ // Uses have_emscripten() which checks for both `emcc` and `emcc.bat` on Windows
22+ if ! have_emscripten ( ) {
2323 panic ! (
2424 "NativeAOT-LLVM test requires emscripten but it was not found.\n \
2525 Install from: https://emscripten.org/docs/getting_started/downloads.html\n \
@@ -30,23 +30,33 @@ fn test_build_csharp_module_aot() {
3030 let workspace = workspace_root ( ) ;
3131 let _cli_path = ensure_binaries_built ( ) ;
3232
33+ // Create isolated NuGet packages folder to avoid file lock conflicts
34+ // NativeAOT-LLVM packages contain DLLs that stay locked and interfere with other tests
35+ let nuget_packages_dir = tempfile:: tempdir ( ) . expect ( "Failed to create temp directory for NuGet packages" ) ;
36+
3337 // Set EXPERIMENTAL_WASM_AOT=1 for this specific build
3438 // Build sdk-test-cs with NativeAOT-LLVM
3539 let mut cmd = Command :: new ( "dotnet" ) ;
3640 cmd. arg ( "publish" )
3741 . arg ( "-c" )
3842 . arg ( "Release" )
3943 . current_dir ( workspace. join ( "modules/sdk-test-cs" ) )
40- . env ( "EXPERIMENTAL_WASM_AOT" , "1" ) ;
44+ . env ( "EXPERIMENTAL_WASM_AOT" , "1" )
45+ . env ( "NUGET_PACKAGES" , nuget_packages_dir. path ( ) ) ;
4146
4247 let output = cmd. output ( ) . expect ( "Failed to run dotnet publish" ) ;
48+
4349 assert ! (
4450 output. status. success( ) ,
4551 "NativeAOT-LLVM publish failed:\n stdout: {}\n stderr: {}" ,
4652 String :: from_utf8_lossy( & output. stdout) ,
4753 String :: from_utf8_lossy( & output. stderr)
4854 ) ;
4955
56+ // Clean up temp dir explicitly to verify no file locks remain
57+ // This ensures subsequent tests can clear NuGet locals without conflicts
58+ drop ( nuget_packages_dir) ;
59+
5060 // Verify StdbModule.wasm was produced
5161 let wasm_path = workspace. join ( "modules/sdk-test-cs/bin/Release/net8.0/wasi-wasm/publish/StdbModule.wasm" ) ;
5262 assert ! ( wasm_path. exists( ) , "StdbModule.wasm not found at {:?}" , wasm_path) ;
0 commit comments