@@ -18,6 +18,8 @@ import * as Scope from "effect/Scope";
1818import * as Sink from "effect/Sink" ;
1919import * as Stream from "effect/Stream" ;
2020import { HttpClient , HttpClientResponse } from "effect/http" ;
21+ import * as ChildProcess from "effect/process/ChildProcess" ;
22+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner" ;
2123
2224import * as AntigravityInstallation from "./AntigravityInstallation.ts" ;
2325import { type AntigravityReleaseAsset } from "./antigravityRelease.ts" ;
@@ -121,6 +123,7 @@ interface HarnessOptions {
121123 readonly path ?: string ;
122124 readonly previous ?: boolean ;
123125 readonly fileSystem ?: FileSystem . FileSystem ;
126+ readonly spawner ?: ChildProcessSpawner . ChildProcessSpawner [ "Service" ] ;
124127 readonly validate ?: AntigravityInstallation . AntigravityInstallationOptions [ "validate" ] ;
125128 readonly useDefaultValidation ?: boolean ;
126129}
@@ -175,6 +178,9 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* (
175178 ) ,
176179 } ) ,
177180 } ) . pipe (
181+ options . spawner
182+ ? Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , options . spawner )
183+ : ( effect ) => effect ,
178184 Effect . provideService ( FileSystem . FileSystem , trackedFs ) ,
179185 Effect . provideService ( HostProcess . Platform , platform ) ,
180186 Effect . provideService ( HostProcess . Architecture , arch ) ,
@@ -571,6 +577,58 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
571577 } ) ,
572578 ) ;
573579
580+ it . effect ( "re-signs the Intel Mac runtime ad hoc and records the signed sizes" , ( ) =>
581+ Effect . gen ( function * ( ) {
582+ const fs = yield * FileSystem . FileSystem ;
583+ const signed : Array < ReadonlyArray < string > > = [ ] ;
584+ const spawner = ChildProcessSpawner . make ( ( command ) =>
585+ Effect . gen ( function * ( ) {
586+ if ( ! ChildProcess . isStandardCommand ( command ) )
587+ return yield * Effect . die ( "Unexpected spawn." ) ;
588+ const args = command . args . map ( String ) ;
589+ signed . push ( [ String ( command . command ) , ...args ] ) ;
590+ // codesign rewrites the signature, which changes each file's size.
591+ for ( const file of args . slice ( 3 ) ) {
592+ yield * fs . writeFileString ( file , "signature" , { flag : "a" } ) ;
593+ }
594+ return ChildProcessSpawner . makeHandle ( {
595+ pid : ChildProcessSpawner . ProcessId ( 900_000_301 ) ,
596+ exitCode : Effect . succeed ( ChildProcessSpawner . ExitCode ( 0 ) ) ,
597+ isRunning : Effect . succeed ( false ) ,
598+ kill : ( ) => Effect . void ,
599+ unref : Effect . succeed ( Effect . void ) ,
600+ stdin : Sink . drain ,
601+ stdout : Stream . empty ,
602+ stderr : Stream . empty ,
603+ all : Stream . empty ,
604+ getInputFd : ( ) => Sink . drain ,
605+ getOutputFd : ( ) => Stream . empty ,
606+ } ) ;
607+ } ) . pipe ( Effect . orDie ) ,
608+ ) ;
609+ const { installation, validations } = yield * makeHarness ( {
610+ platform : "darwin" ,
611+ arch : "x64" ,
612+ spawner,
613+ } ) ;
614+ yield * installation . start ;
615+ expect ( ( yield * terminalState ( installation ) ) . phase ) . toBe ( "succeeded" ) ;
616+ const validated = validations [ 0 ] ?. executable ;
617+ expect ( signed ) . toEqual ( [
618+ [
619+ "/usr/bin/codesign" ,
620+ "--force" ,
621+ "--sign" ,
622+ "-" ,
623+ validated ?. executablePath ,
624+ validated ?. harnessPath ,
625+ ] ,
626+ ] ) ;
627+ const selected = yield * installation . resolve ( ) ;
628+ expect ( yield * fs . readFileString ( selected . executablePath ) ) . toBe ( `${ serverContents } signature` ) ;
629+ } ) ,
630+ ) ;
631+
574632 // The mocked Linux PATH walk needs POSIX paths; Windows temp paths contain colons.
575633 it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) === "win32" ) (
576634 "honors explicit paths and reports invalid overrides without falling back" ,
0 commit comments