@@ -21,6 +21,7 @@ import * as Queue from "effect/Queue";
2121import * as Schema from "effect/Schema" ;
2222import * as Sink from "effect/Sink" ;
2323import * as Stream from "effect/Stream" ;
24+ import * as TestClock from "effect/testing/TestClock" ;
2425import { HttpClient , HttpClientResponse } from "effect/http" ;
2526import * as ChildProcess from "effect/process/ChildProcess" ;
2627import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner" ;
@@ -726,54 +727,54 @@ it.layer(layerTest)("CodexDriver", (it) => {
726727 } ) . pipe ( Effect . scoped ) ,
727728 { skip : windowsHost } ,
728729 ) ;
729- } ) ;
730730
731- // Live: the auth watcher debounces on the real clock.
732- it . live ( "probes again when auth.json in the Codex home changes" , ( ) =>
733- Effect . gen ( function * ( ) {
734- const fs = yield * FileSystem . FileSystem ;
735- const codexHome = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-codex-auth-watch-" } ) ;
736- const watchedPath = yield * Deferred . make < string > ( ) ;
737- const homeEvents = yield * Queue . unbounded < FileSystem . WatchEvent > ( ) ;
738- const probes = yield * Queue . unbounded < void > ( ) ;
739- yield * CodexDriver . create ( {
740- instanceId : ProviderInstanceId . make ( "codex- auth- watch") ,
741- displayName : "Codex auth watch" ,
742- enabled : true ,
743- environment : [ ] ,
744- config : { ... CodexDriver . defaultConfig ( ) , homePath : codexHome } ,
745- } ) . pipe (
746- // OS watchers can miss events written right after they start, so the test supplies them.
747- Effect . provideService ( FileSystem . FileSystem , {
748- ... fs ,
749- watch : ( path ) =>
750- Stream . unwrap (
751- Deferred . succeed ( watchedPath , path ) . pipe ( Effect . as ( Stream . fromQueue ( homeEvents ) ) ) ,
752- ) ,
753- } ) ,
754- Effect . provideService (
755- ChildProcessSpawner . ChildProcessSpawner ,
756- ChildProcessSpawner . make ( ( command ) =>
757- ( ChildProcess . isStandardCommand ( command ) && command . args . includes ( "app-server" )
758- ? Queue . offer ( probes , undefined )
759- : Effect . void
760- ) . pipe (
761- Effect . andThen (
762- PlatformError . badArgument ( {
763- module : "ChildProcessSpawner " ,
764- method : "spawn " ,
765- description : "The fixture has no Codex executable" ,
766- } ) ,
731+ it . effect ( "probes again when auth.json in the Codex home changes" , ( ) =>
732+ Effect . gen ( function * ( ) {
733+ const fs = yield * FileSystem . FileSystem ;
734+ const codexHome = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-codex-auth-watch-" } ) ;
735+ const watchedPath = yield * Deferred . make < string > ( ) ;
736+ const homeEvents = yield * Queue . unbounded < FileSystem . WatchEvent > ( ) ;
737+ const probes = yield * Queue . unbounded < void > ( ) ;
738+ yield * CodexDriver . create ( {
739+ instanceId : ProviderInstanceId . make ( "codex-auth-watch" ) ,
740+ displayName : "Codex auth watch",
741+ enabled : true ,
742+ environment : [ ] ,
743+ config : { ... CodexDriver . defaultConfig ( ) , homePath : codexHome } ,
744+ } ) . pipe (
745+ // OS watchers can miss events written right after they start, so the test supplies them.
746+ Effect . provideService ( FileSystem . FileSystem , {
747+ ... fs ,
748+ watch : ( path ) =>
749+ Stream . unwrap (
750+ Deferred . succeed ( watchedPath , path ) . pipe ( Effect . as ( Stream . fromQueue ( homeEvents ) ) ) ,
751+ ) ,
752+ } ) ,
753+ Effect . provideService (
754+ ChildProcessSpawner . ChildProcessSpawner ,
755+ ChildProcessSpawner . make ( ( command ) =>
756+ ( ChildProcess . isStandardCommand ( command ) && command . args . includes ( "app-server" )
757+ ? Queue . offer ( probes , undefined )
758+ : Effect . void
759+ ) . pipe (
760+ Effect . andThen (
761+ PlatformError . badArgument ( {
762+ module : "ChildProcessSpawner" ,
763+ method : "spawn " ,
764+ description : "The fixture has no Codex executable " ,
765+ } ) ,
766+ ) ,
767767 ) ,
768768 ) ,
769769 ) ,
770- ) ,
771- ) ;
772- expect ( yield * Deferred . await ( watchedPath ) ) . toBe ( codexHome ) ;
773- yield * Queue . take ( probes ) ;
770+ ) ;
771+ expect ( yield * Deferred . await ( watchedPath ) ) . toBe ( codexHome ) ;
772+ yield * Queue . take ( probes ) ;
774773
775- yield * Queue . offer ( homeEvents , { _tag : "Update" , path : "auth.json" } ) ;
774+ yield * Queue . offer ( homeEvents , { _tag : "Update" , path : "auth.json" } ) ;
775+ yield * TestClock . adjust ( "250 millis" ) ;
776776
777- yield * Queue . take ( probes ) ;
778- } ) . pipe ( Effect . scoped , Effect . provide ( layerTest ) ) ,
779- ) ;
777+ yield * Queue . take ( probes ) ;
778+ } ) . pipe ( Effect . scoped ) ,
779+ ) ;
780+ } ) ;
0 commit comments