@@ -122,8 +122,7 @@ describe("ssh tunnel scripts", () => {
122122 script ,
123123 'T3_LOCK="$HOME/.t3/runtime/versions/.$T3_ARCHIVE_VERSION.install.lock"' ,
124124 ) ;
125- assert . include ( script , 'while ! mkdir "$T3_LOCK" 2>/dev/null; do' ) ;
126- assert . include ( script , 'mv "$T3_LOCK/pid.tmp" "$T3_LOCK/pid"' ) ;
125+ assert . include ( script , 'while ! (set -C; printf \'%s\\n\' "$$" > "$T3_LOCK") 2>/dev/null; do' ) ;
127126 assert . include ( script , 'if ! kill -0 "$T3_LOCK_OWNER" 2>/dev/null; then' ) ;
128127 assert . include ( script , 'if [ "$T3_LOCK_UNOWNED" -ge 5 ]; then' ) ;
129128 assert . include ( script , 'if [ "$T3_LOCK_WAITED" -ge 360 ]; then' ) ;
@@ -231,7 +230,7 @@ describe("ssh tunnel scripts", () => {
231230
232231 it ( "embeds the runner in the launch script byte for byte" , ( ) => {
233232 const runner = SshTunnel . buildRemoteT3RunnerScript ( ARCHIVE ) ;
234- assert . include ( runner , 'printf \'%s\\n\' "$$" > "$T3_LOCK/pid.tmp "' ) ;
233+ assert . include ( runner , 'printf \'%s\\n\' "$$" > "$T3_LOCK"' ) ;
235234 assert . include ( SshTunnel . buildRemoteLaunchScript ( ARCHIVE ) , runner ) ;
236235 } ) ;
237236
@@ -818,12 +817,16 @@ describe("remote port picker", () => {
818817 ) ;
819818} ) ;
820819
821- const runScript = ( home : string , args : ReadonlyArray < string > ) =>
820+ const runScript = (
821+ home : string ,
822+ args : ReadonlyArray < string > ,
823+ path : string = process . env . PATH ?? "" ,
824+ ) =>
822825 Effect . gen ( function * ( ) {
823826 const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
824827 const child = yield * spawner . spawn (
825828 ChildProcess . make ( "sh" , args , {
826- env : { PATH : process . env . PATH ?? "" , HOME : home } ,
829+ env : { PATH : path , HOME : home } ,
827830 extendEnv : false ,
828831 } ) ,
829832 ) ;
@@ -856,7 +859,8 @@ describe("archive runner script", () => {
856859 const windowsHost = hostPlatform === "win32" ;
857860 const archiveVersion = "1.2.3-preview.20260911.4" ;
858861
859- const runRunner = ( home : string , runner : string ) => runScript ( home , [ runner , "--version" ] ) ;
862+ const runRunner = ( home : string , runner : string , path ?: string ) =>
863+ runScript ( home , [ runner , "--version" ] , path ) ;
860864
861865 const makeMirror = Effect . fn ( "makeMirror" ) ( function * ( root : string ) {
862866 const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
@@ -892,9 +896,24 @@ describe("archive runner script", () => {
892896 ) ;
893897 const home = `${ root } /home` ;
894898 yield * fs . makeDirectory ( home , { recursive : true } ) ;
899+ // uutils coreutils (Ubuntu's default) mkdir exits 0 when it loses the
900+ // race to create a directory. Shim that behavior so the race covers
901+ // such hosts wherever the test runs.
902+ const hostPath = process . env . PATH ?? "" ;
903+ yield * fs . makeDirectory ( `${ root } /bin` ) ;
904+ yield * fs . writeFileString (
905+ `${ root } /bin/mkdir` ,
906+ `#!/bin/sh\nPATH='${ hostPath } ' exec mkdir -p "$@"\n` ,
907+ ) ;
908+ yield * fs . chmod ( `${ root } /bin/mkdir` , 0o755 ) ;
909+ const racePath = `${ root } /bin:${ hostPath } ` ;
895910
896911 const results = yield * Effect . all (
897- [ runRunner ( home , runner ) , runRunner ( home , runner ) , runRunner ( home , runner ) ] ,
912+ [
913+ runRunner ( home , runner , racePath ) ,
914+ runRunner ( home , runner , racePath ) ,
915+ runRunner ( home , runner , racePath ) ,
916+ ] ,
898917 { concurrency : "unbounded" } ,
899918 ) ;
900919 for ( const result of results ) {
@@ -910,13 +929,12 @@ describe("archive runner script", () => {
910929
911930 const lock = `${ versionsDir } /.${ archiveVersion } .install.lock` ;
912931 yield * fs . remove ( `${ versionsDir } /${ archiveVersion } ` , { recursive : true } ) ;
913- yield * fs . makeDirectory ( lock ) ;
914- yield * fs . writeFileString ( `${ lock } /pid` , "999999\n" ) ;
932+ yield * fs . writeFileString ( lock , "999999\n" ) ;
915933 const afterDead = yield * runRunner ( home , runner ) ;
916934 assert . equal ( afterDead . exitCode , 0 , afterDead . stderr ) ;
917935
918936 yield * fs . remove ( `${ versionsDir } /${ archiveVersion } ` , { recursive : true } ) ;
919- yield * fs . makeDirectory ( lock ) ;
937+ yield * fs . writeFileString ( lock , "" ) ;
920938 const afterUnowned = yield * runRunner ( home , runner ) ;
921939 assert . equal ( afterUnowned . exitCode , 0 , afterUnowned . stderr ) ;
922940 assert . isFalse ( yield * fs . exists ( lock ) ) ;
0 commit comments