mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 10:34:35 -07:00
refactor(core): consolidate execute() arguments into ExecuteOptions (#25101)
This commit is contained in:
@@ -695,9 +695,9 @@ function doIt() {
|
||||
throw abortError;
|
||||
});
|
||||
|
||||
await expect(invocation.execute(abortController.signal)).rejects.toBe(
|
||||
abortError,
|
||||
);
|
||||
await expect(
|
||||
invocation.execute({ abortSignal: abortController.signal }),
|
||||
).rejects.toBe(abortError);
|
||||
|
||||
calculateSpy.mockRestore();
|
||||
});
|
||||
@@ -714,7 +714,9 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.llmContent).toMatch(/Successfully modified file/);
|
||||
expect(fs.readFileSync(filePath, 'utf8')).toBe(newContent);
|
||||
@@ -737,7 +739,9 @@ function doIt() {
|
||||
new_string: 'replacement',
|
||||
};
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
expect(result.llmContent).toMatch(/0 occurrences found for old_string/);
|
||||
expect(result.returnDisplay).toMatch(
|
||||
/Failed to edit, could not find the string to replace./,
|
||||
@@ -768,7 +772,9 @@ function doIt() {
|
||||
});
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.llmContent).toMatch(/Successfully modified file/);
|
||||
@@ -788,7 +794,7 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
await invocation.execute(new AbortController().signal);
|
||||
await invocation.execute({ abortSignal: new AbortController().signal });
|
||||
|
||||
const finalContent = fs.readFileSync(filePath, 'utf8');
|
||||
expect(finalContent).toBe(newContent);
|
||||
@@ -804,7 +810,7 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
await invocation.execute(new AbortController().signal);
|
||||
await invocation.execute({ abortSignal: new AbortController().signal });
|
||||
|
||||
const finalContent = fs.readFileSync(filePath, 'utf8');
|
||||
expect(finalContent).toBe(newContentWithCRLF);
|
||||
@@ -832,7 +838,9 @@ function doIt() {
|
||||
});
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.error?.type).toBe(
|
||||
ToolErrorType.EDIT_NO_CHANGE_LLM_JUDGEMENT,
|
||||
@@ -876,7 +884,7 @@ function doIt() {
|
||||
.mockResolvedValueOnce(externallyModifiedContent); // Second call in `attemptSelfCorrection`
|
||||
|
||||
const invocation = tool.build(params);
|
||||
await invocation.execute(new AbortController().signal);
|
||||
await invocation.execute({ abortSignal: new AbortController().signal });
|
||||
|
||||
// Assert that the file was read twice (initial read, then re-read for hash comparison).
|
||||
expect(readTextFileSpy).toHaveBeenCalledTimes(2);
|
||||
@@ -938,7 +946,9 @@ function doIt() {
|
||||
instruction: 'test',
|
||||
...params,
|
||||
});
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
expect(result.error?.type).toBe(expectedError);
|
||||
},
|
||||
);
|
||||
@@ -1020,7 +1030,9 @@ function doIt() {
|
||||
...(allow_multiple !== undefined && { allow_multiple }),
|
||||
};
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
if (shouldSucceed) {
|
||||
expect(result.error).toBeUndefined();
|
||||
@@ -1162,7 +1174,9 @@ function doIt() {
|
||||
ai_proposed_content: '',
|
||||
};
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
if (
|
||||
result.returnDisplay &&
|
||||
@@ -1215,7 +1229,9 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.error?.type).toBe(ToolErrorType.EDIT_NO_OCCURRENCE_FOUND);
|
||||
expect(mockFixLLMEditWithInstruction).not.toHaveBeenCalled();
|
||||
@@ -1236,7 +1252,7 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
await invocation.execute(new AbortController().signal);
|
||||
await invocation.execute({ abortSignal: new AbortController().signal });
|
||||
|
||||
expect(mockFixLLMEditWithInstruction).toHaveBeenCalled();
|
||||
});
|
||||
@@ -1265,7 +1281,9 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(discoverJitContext).toHaveBeenCalled();
|
||||
expect(result.llmContent).toContain('Newly Discovered Project Context');
|
||||
@@ -1294,7 +1312,9 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.llmContent).not.toContain(
|
||||
'Newly Discovered Project Context',
|
||||
@@ -1329,7 +1349,9 @@ function doIt() {
|
||||
};
|
||||
|
||||
const invocation = tool.build(params);
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
const result = await invocation.execute({
|
||||
abortSignal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(result.llmContent).toMatch(/Successfully modified file/);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user