mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 05:00:46 +00:00
refactor(debug): replace ConsolePatcher with debugLogger and update error reporting
- Replace ConsolePatcher with centralized debugLogger utility - Refactor errorReporting to use debugLogger instead of file-based reporting - Remove user-facing console message components: - Delete ConsolePatcher.ts, useConsoleMessages.ts/hook - Delete ConsoleSummaryDisplay.tsx, DetailedMessagesDisplay.tsx - Update all tests in packages/core and packages/cli: - Mock debugLogger where needed - Remove assertions for console output on non-critical errors - Keep debugLogger assertions for fatal/network errors - Use HOME directory mocking for hermetic file system tests Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
135df54f27
commit
89e3c2cd7a
64 changed files with 1240 additions and 2416 deletions
|
|
@ -33,14 +33,12 @@ import { relaunchAppInChildProcess, relaunchOnExitCode } from './relaunch.js';
|
|||
|
||||
describe('relaunchOnExitCode', () => {
|
||||
let processExitSpy: MockInstance;
|
||||
let consoleErrorSpy: MockInstance;
|
||||
let stdinResumeSpy: MockInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
processExitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
||||
throw new Error('PROCESS_EXIT_CALLED');
|
||||
});
|
||||
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
stdinResumeSpy = vi
|
||||
.spyOn(process.stdin, 'resume')
|
||||
.mockImplementation(() => process.stdin);
|
||||
|
|
@ -49,7 +47,6 @@ describe('relaunchOnExitCode', () => {
|
|||
|
||||
afterEach(() => {
|
||||
processExitSpy.mockRestore();
|
||||
consoleErrorSpy.mockRestore();
|
||||
stdinResumeSpy.mockRestore();
|
||||
});
|
||||
|
||||
|
|
@ -90,10 +87,6 @@ describe('relaunchOnExitCode', () => {
|
|||
);
|
||||
|
||||
expect(runner).toHaveBeenCalledTimes(1);
|
||||
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
||||
'Fatal error: Failed to relaunch the CLI process.',
|
||||
error,
|
||||
);
|
||||
expect(stdinResumeSpy).toHaveBeenCalled();
|
||||
expect(processExitSpy).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
|
@ -101,7 +94,6 @@ describe('relaunchOnExitCode', () => {
|
|||
|
||||
describe('relaunchAppInChildProcess', () => {
|
||||
let processExitSpy: MockInstance;
|
||||
let consoleErrorSpy: MockInstance;
|
||||
let stdinPauseSpy: MockInstance;
|
||||
let stdinResumeSpy: MockInstance;
|
||||
|
||||
|
|
@ -124,7 +116,6 @@ describe('relaunchAppInChildProcess', () => {
|
|||
processExitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
||||
throw new Error('PROCESS_EXIT_CALLED');
|
||||
});
|
||||
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
stdinPauseSpy = vi
|
||||
.spyOn(process.stdin, 'pause')
|
||||
.mockImplementation(() => process.stdin);
|
||||
|
|
@ -140,7 +131,6 @@ describe('relaunchAppInChildProcess', () => {
|
|||
process.execPath = originalExecPath;
|
||||
|
||||
processExitSpy.mockRestore();
|
||||
consoleErrorSpy.mockRestore();
|
||||
stdinPauseSpy.mockRestore();
|
||||
stdinResumeSpy.mockRestore();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue