@@ -60,6 +60,7 @@ function makeMockDetachedHandle(input: MockSpawnResult & { readonly onUnref?: ()
6060const layerTest = ( input : {
6161 readonly platform : NodeJS . Platform ;
6262 readonly env ?: Record < string , string > ;
63+ readonly path ?: Path . Path ;
6364 readonly resolveExecutable ?: ( command : string ) => string | undefined ;
6465 readonly onSpawn ?: ( command : ChildProcess . StandardCommand ) => void ;
6566 readonly onUnref ?: ( ) => void ;
@@ -85,7 +86,15 @@ const layerTest = (input: {
8586 ) ;
8687
8788 return Layer . mergeAll (
88- ExternalLauncher . layer . pipe ( Layer . provide ( Layer . merge ( NodeServices . layer , layerSpawner ) ) ) ,
89+ ExternalLauncher . layer . pipe (
90+ Layer . provide (
91+ Layer . mergeAll (
92+ NodeServices . layer ,
93+ layerSpawner ,
94+ input . path ? Layer . succeed ( Path . Path , input . path ) : Layer . empty ,
95+ ) ,
96+ ) ,
97+ ) ,
8998 Layer . succeed ( HostProcess . Platform , input . platform ) ,
9099 Layer . succeed (
91100 SpawnExecutableResolution ,
@@ -504,6 +513,18 @@ for (const { layout, pathNames, fallbackNames, expected } of [
504513 ) ;
505514}
506515
516+ // Linux editor discovery also probes fixed system directories; tests point them at a temp
517+ // directory so an editor installed on the host cannot satisfy the lookup.
518+ const withSystemBin = ( path : Path . Path , systemBin : string ) : Path . Path => ( {
519+ ...path ,
520+ join : ( ...parts ) =>
521+ path . join (
522+ ...parts . map ( ( part ) =>
523+ [ "/usr/local/bin" , "/usr/bin" , "/snap/bin" ] . includes ( part ) ? systemBin : part ,
524+ ) ,
525+ ) ,
526+ } ) ;
527+
507528it . effect . skipIf ( windowsHost ) ( "prefers zeditor in a later Linux fallback directory" , ( ) =>
508529 Effect . gen ( function * ( ) {
509530 const fs = yield * FileSystem . FileSystem ;
@@ -523,15 +544,7 @@ it.effect.skipIf(windowsHost)("prefers zeditor in a later Linux fallback directo
523544 const editor = EDITORS . find ( ( editor ) => editor . id === "zed" ) ! ;
524545 const resolve = resolveEditorCommand ( editor , { HOME : home , PATH : "" } ) . pipe (
525546 Effect . provideService ( HostProcess . Platform , "linux" ) ,
526- Effect . provideService ( Path . Path , {
527- ...path ,
528- join : ( ...parts ) =>
529- path . join (
530- ...parts . map ( ( part ) =>
531- [ "/usr/local/bin" , "/usr/bin" , "/snap/bin" ] . includes ( part ) ? systemBin : part ,
532- ) ,
533- ) ,
534- } ) ,
547+ Effect . provideService ( Path . Path , withSystemBin ( path , systemBin ) ) ,
535548 ) ;
536549 assert . deepEqual (
537550 yield * resolve ,
@@ -564,15 +577,7 @@ it.effect.skipIf(windowsHost)("does not offer the OpenZFS zed daemon as Zed on L
564577 const editor = EDITORS . find ( ( editor ) => editor . id === "zed" ) ! ;
565578 const resolve = resolveEditorCommand ( editor , { HOME : home , PATH : binDir } ) . pipe (
566579 Effect . provideService ( HostProcess . Platform , "linux" ) ,
567- Effect . provideService ( Path . Path , {
568- ...path ,
569- join : ( ...parts ) =>
570- path . join (
571- ...parts . map ( ( part ) =>
572- [ "/usr/local/bin" , "/usr/bin" , "/snap/bin" ] . includes ( part ) ? systemBin : part ,
573- ) ,
574- ) ,
575- } ) ,
580+ Effect . provideService ( Path . Path , withSystemBin ( path , systemBin ) ) ,
576581 ) ;
577582 assert . deepEqual ( yield * resolve , Option . none ( ) ) ;
578583
@@ -590,6 +595,7 @@ it.effect.skipIf(windowsHost)("does not open Zed with the OpenZFS zed daemon on
590595 const path = yield * Path . Path ;
591596 const home = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-zed-zfs-launch-" } ) ;
592597 const binDir = path . join ( home , "bin" ) ;
598+ const systemBin = path . join ( home , "system-bin" ) ;
593599 yield * fs . makeDirectory ( binDir , { recursive : true } ) ;
594600 yield * fs . writeFileString ( path . join ( binDir , "zed" ) , "#!/bin/sh\nexit 1\n" ) ;
595601 yield * fs . chmod ( path . join ( binDir , "zed" ) , 0o755 ) ;
@@ -603,6 +609,7 @@ it.effect.skipIf(windowsHost)("does not open Zed with the OpenZFS zed daemon on
603609 layerTest ( {
604610 platform : "linux" ,
605611 env : { HOME : home , PATH : binDir } ,
612+ path : withSystemBin ( path , systemBin ) ,
606613 onSpawn : ( command ) => spawned . push ( command ) ,
607614 spawnResult : ( command ) => ( command . args [ 0 ] === "--version" ? { exitCode : 1 } : undefined ) ,
608615 } ) ,
0 commit comments