@@ -1093,9 +1093,9 @@ fn write_mock_agent_process_launcher(path: &Path) -> Result<(), AgentError> {
10931093 fs:: create_dir_all ( parent) ?;
10941094 }
10951095 let script = if cfg ! ( windows) {
1096- "@echo off\r \n sandbox-agent mock-agent-process %*\r \n "
1096+ "@echo off\r \n if not \" %SANDBOX_AGENT_BIN% \" == \" \" ( \r \n \" %SANDBOX_AGENT_BIN% \" mock-agent-process %* \r \n exit /b %errorlevel% \r \n ) \r \ n sandbox-agent mock-agent-process %*\r \n "
10971097 } else {
1098- "#!/usr/bin/env sh\n exec sandbox-agent mock-agent-process \" $@\" \n "
1098+ "#!/usr/bin/env sh\n if [ -n \" ${SANDBOX_AGENT_BIN:-} \" ]; then \n exec \" $SANDBOX_AGENT_BIN \" mock-agent-process \" $@ \" \n fi \ n exec sandbox-agent mock-agent-process \" $@\" \n "
10991099 } ;
11001100 write_text_file ( path, script)
11011101}
@@ -1969,6 +1969,34 @@ exit 0
19691969 assert_eq ! ( result. artifacts[ 0 ] . source, InstallSource :: Builtin ) ;
19701970 }
19711971
1972+ #[ test]
1973+ fn mock_launcher_prefers_sandbox_agent_bin ( ) {
1974+ let temp_dir = tempfile:: tempdir ( ) . expect ( "create tempdir" ) ;
1975+ let manager = AgentManager :: with_platform ( temp_dir. path ( ) , Platform :: LinuxX64 ) ;
1976+
1977+ manager
1978+ . install (
1979+ AgentId :: Mock ,
1980+ InstallOptions {
1981+ reinstall : true ,
1982+ version : None ,
1983+ agent_process_version : None ,
1984+ } ,
1985+ )
1986+ . expect ( "mock install" ) ;
1987+
1988+ let launcher = manager. agent_process_path ( AgentId :: Mock ) ;
1989+ let mut file = fs:: File :: open ( & launcher) . expect ( "open mock launcher" ) ;
1990+ let mut contents = String :: new ( ) ;
1991+ file. read_to_string ( & mut contents)
1992+ . expect ( "read mock launcher" ) ;
1993+
1994+ assert ! (
1995+ contents. contains( "SANDBOX_AGENT_BIN" ) ,
1996+ "mock launcher should reference SANDBOX_AGENT_BIN"
1997+ ) ;
1998+ }
1999+
19722000 #[ test]
19732001 fn install_pi_skips_native_and_installs_fallback_npm_launcher ( ) {
19742002 let _env_lock = env_lock ( ) . lock ( ) . expect ( "env lock" ) ;
0 commit comments