@@ -1421,16 +1421,16 @@ export const namedPathsLine = ({ setup }: McpToolUseCase) => {
14211421/** The simulator's request: the machine, this sample's earlier calls, then the new call. */
14221422export const shellRequest = ( sample : Sample , call : Omit < ShellEntry , "output" > , model : string ) => {
14231423 const { testCase, base, repo, shell, devices } = sample ;
1424- const { world, context, shellMocks = [ ] } = testCase . setup ;
1424+ const { world, context } = testCase . setup ;
14251425 const { cwd, platform, date } = base . environment ;
14261426 const command = call . tool === "Bash" && isRecord ( call . input ) ? call . input . command : undefined ;
1427+ const mocks = shellMocksFor ( sample , typeof command === "string" ? command : undefined ) ;
14271428 const machine = [
14281429 `Working directory: ${ cwd } on ${ platform } , a git checkout of github.com/${ repo } .${ date ? ` Today is ${ date } .` : "" } ` ,
14291430 gitStatus ( testCase ) ,
14301431 `World: ${ valueText ( world ?? { } ) } ` ,
1431- // A read of a `secret: false` field's file gets an ordinary value, not a secret's mock.
1432- ...( shellMocks . length > 0 && ! ( typeof command === "string" && readsPlainFile ( sample , command ) )
1433- ? [ `Commands that match these regexes print exactly this output: ${ valueText ( shellMocks ) } ` ]
1432+ ...( mocks . length > 0
1433+ ? [ `Commands that match these regexes print exactly this output: ${ valueText ( mocks ) } ` ]
14341434 : [ ] ) ,
14351435 // Which device each launcher and session drives, and which of this call's opens are refused.
14361436 ...( devices ?. describe ( shell , typeof command === "string" ? command : undefined ) ?? [ ] ) ,
@@ -1497,16 +1497,23 @@ export const shellOutput = (content: ReadonlyArray<Block>) => {
14971497 } ) ;
14981498} ;
14991499
1500- /** A shell mock's output, when the command is one simple command that the mock matches. */
1501- const readsPlainFile = ( sample : Sample , command : string ) =>
1502- sample . plainFiles . some ( ( { file } ) => command . includes ( file . slice ( - 32 ) ) ) ;
1500+ /**
1501+ * The case's shell mocks for a command. A file for a `secret: false` field holds an ordinary
1502+ * value, so a command that reads one skips the mocks that print a secret file; others still apply.
1503+ */
1504+ const shellMocksFor = ( sample : Sample , command : string | undefined ) => {
1505+ const mocks = sample . testCase . setup . shellMocks ?? [ ] ;
1506+ const plain =
1507+ command !== undefined &&
1508+ sample . plainFiles . some ( ( { file } ) => command . includes ( file . slice ( - 32 ) ) ) ;
1509+ return plain ? mocks . filter ( ( mock ) => ! mock . match . includes ( "secrets/files" ) ) : mocks ;
1510+ } ;
15031511
1512+ /** A shell mock's output, when the command is one simple command that the mock matches. */
15041513export const mockOutput = ( sample : Sample , command : string ) =>
1505- // A file for a `secret: false` field holds an ordinary value, not what a secret's mock prints.
1506- / & & | \| \| | [ ; | \n ] / . test ( command . trim ( ) ) || readsPlainFile ( sample , command )
1514+ / & & | \| \| | [ ; | \n ] / . test ( command . trim ( ) )
15071515 ? undefined
1508- : sample . testCase . setup . shellMocks ?. find ( ( mock ) => new RegExp ( mock . match ) . test ( command ) )
1509- ?. output ;
1516+ : shellMocksFor ( sample , command ) . find ( ( mock ) => new RegExp ( mock . match ) . test ( command ) ) ?. output ;
15101517
15111518type Config = {
15121519 readonly apiKey : string ;
0 commit comments