@@ -291,6 +291,43 @@ it.layer(NodeServices.layer)("manual server installation ownership", (it) => {
291291 } ) ,
292292 ) ;
293293
294+ it . effect ( "names the launcher symlink that started a downloaded runtime" , ( ) =>
295+ Effect . gen ( function * ( ) {
296+ const fs = yield * FileSystem . FileSystem ;
297+ const path = yield * Path . Path ;
298+ const root = yield * fs . realPath ( yield * fs . makeTempDirectoryScoped ( ) ) ;
299+ // The install script's launcher names ~/.t3, which here links to a home elsewhere.
300+ const executable = path . join ( root , "data/t3/runtime/versions/1.0.0/t3" ) ;
301+ const launcher = path . join ( root , "bin/t3" ) ;
302+ const copy = path . join ( root , "bin/t3-copy" ) ;
303+ yield * fs . makeDirectory ( path . dirname ( executable ) , { recursive : true } ) ;
304+ yield * fs . makeDirectory ( path . dirname ( launcher ) , { recursive : true } ) ;
305+ yield * fs . writeFileString ( executable , "" , { mode : 0o755 } ) ;
306+ yield * fs . writeFileString ( copy , "" , { mode : 0o755 } ) ;
307+ yield * fs . symlink ( path . join ( root , "data/t3" ) , path . join ( root , ".t3" ) ) ;
308+ yield * fs . symlink ( path . join ( root , ".t3/runtime/versions/1.0.0/t3" ) , launcher ) ;
309+ // Earlier PATH entries hold a directory and a non-executable file named t3.
310+ yield * fs . makeDirectory ( path . join ( root , "shadow-dir/t3" ) , { recursive : true } ) ;
311+ yield * fs . makeDirectory ( path . join ( root , "shadow-file" ) ) ;
312+ yield * fs . writeFileString ( path . join ( root , "shadow-file/t3" ) , "" ) ;
313+ const resolve = ( invokedAs : string ) =>
314+ resolveServerInstallation . pipe (
315+ Effect . provideService ( HostProcess . ExecutablePath , executable ) ,
316+ Effect . provideService ( HostProcess . IsExecutable , true ) ,
317+ Effect . provideService ( HostProcess . InvokedAs , invokedAs ) ,
318+ Effect . provideService ( HostProcess . WorkingDirectory , root ) ,
319+ Effect . provideService ( HostProcess . Environment , { PATH : "shadow-dir:shadow-file:bin" } ) ,
320+ Effect . provideService ( HostProcess . Platform , "linux" ) ,
321+ ) ;
322+ const baseDir = path . join ( root , ".t3" ) ;
323+
324+ expect ( yield * resolve ( "t3" ) ) . toEqual ( { kind : "t3-launcher" , launcher, baseDir } ) ;
325+ expect ( yield * resolve ( launcher ) ) . toEqual ( { kind : "t3-launcher" , launcher, baseDir } ) ;
326+ expect ( yield * resolve ( executable ) ) . toBeNull ( ) ;
327+ expect ( yield * resolve ( copy ) ) . toBeNull ( ) ;
328+ } ) ,
329+ ) ;
330+
294331 it . effect ( "leaves local, standalone, missing and unreadable installs unknown" , ( ) =>
295332 Effect . gen ( function * ( ) {
296333 const fs = yield * FileSystem . FileSystem ;
0 commit comments