mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
test(integration): add failing test for stdin context with prompt (#6158)
This commit is contained in:
@@ -239,7 +239,37 @@ export async function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
await start_sandbox(sandboxConfig, memoryArgs, config);
|
||||
let stdinData = '';
|
||||
if (!process.stdin.isTTY) {
|
||||
stdinData = await readStdin();
|
||||
}
|
||||
|
||||
// This function is a copy of the one from sandbox.ts
|
||||
// It is moved here to decouple sandbox.ts from the CLI's argument structure.
|
||||
const injectStdinIntoArgs = (
|
||||
args: string[],
|
||||
stdinData?: string,
|
||||
): string[] => {
|
||||
const finalArgs = [...args];
|
||||
if (stdinData) {
|
||||
const promptIndex = finalArgs.findIndex(
|
||||
(arg) => arg === '--prompt' || arg === '-p',
|
||||
);
|
||||
if (promptIndex > -1 && finalArgs.length > promptIndex + 1) {
|
||||
// If there's a prompt argument, prepend stdin to it
|
||||
finalArgs[promptIndex + 1] =
|
||||
`${stdinData}\n\n${finalArgs[promptIndex + 1]}`;
|
||||
} else {
|
||||
// If there's no prompt argument, add stdin as the prompt
|
||||
finalArgs.push('--prompt', stdinData);
|
||||
}
|
||||
}
|
||||
return finalArgs;
|
||||
};
|
||||
|
||||
const sandboxArgs = injectStdinIntoArgs(process.argv, stdinData);
|
||||
|
||||
await start_sandbox(sandboxConfig, memoryArgs, config, sandboxArgs);
|
||||
process.exit(0);
|
||||
} else {
|
||||
// Not in a sandbox and not entering one, so relaunch with additional
|
||||
|
||||
Reference in New Issue
Block a user