@@ -293,6 +293,25 @@ describe("the Brev Launchable fixture binds staging identity and workspace lifec
293293 expect ( ownership . id ) . toBe ( "owned-id" ) ;
294294 } ) ;
295295
296+ it ( "records the last failed Brev exec readiness attempt" , async ( ) => {
297+ const root = temporaryRoot ( ) ;
298+ const command = vi . fn ( ownedExecCommand ( "" , 1 , "ssh unavailable" ) ) ;
299+ const fixture = createFixture ( root , command ) ;
300+
301+ await expect ( fixture . waitForExec ( recordedOwnership ( ) , 10 ) ) . rejects . toThrow (
302+ "Brev exec readiness timed out" ,
303+ ) ;
304+ const evidence = JSON . parse (
305+ fs . readFileSync ( path . join ( root , "brev-exec-readiness-failure.json" ) , "utf8" ) ,
306+ ) ;
307+ expect ( evidence ) . toMatchObject ( {
308+ attempts : expect . any ( Number ) ,
309+ lastResult : { exitCode : 1 , stderr : "ssh unavailable" } ,
310+ workspaceId : "owned-id" ,
311+ workspaceName : "fixture-workspace" ,
312+ } ) ;
313+ } ) ;
314+
296315 it ( "refuses a replacement before Brev exec readiness without executing on it" , async ( ) => {
297316 const root = temporaryRoot ( ) ;
298317 const lifecycle = replaceableWorkspaceCommand ( ) ;
@@ -496,13 +515,15 @@ function recordedOwnership(): BrevWorkspaceOwnership {
496515
497516function ownedExecCommand (
498517 stdout : string ,
518+ exitCode = 0 ,
519+ stderr = "" ,
499520) : ( _binary : string , args : string [ ] , _options ?: ShellProbeRunOptions ) => Promise < ShellProbeResult > {
500521 return async ( _binary , args , _options ) => {
501522 switch ( args [ 0 ] ) {
502523 case "ls" :
503524 return workspaceResult ( "owned-id" ) ;
504525 case "exec" :
505- return result ( stdout ) ;
526+ return { ... result ( stdout ) , exitCode , stderr } ;
506527 default :
507528 throw new Error ( `unexpected command: ${ args . join ( " " ) } ` ) ;
508529 }
0 commit comments