mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 00:17:09 +00:00
test: isolate shared-state test suites for CI stability
- add dependency injection to export-command, binary-manager, codex-plan-compatibility, config-command, and usage-syncer - override process.exit in api-export test to prevent silent termination in Bun's parallel test runner - harden test-environment bootstrap with process.env isolation - fix auth middleware to avoid config upgrade during checks
This commit is contained in:
1 parent
58891d368d
commit
3af554275e
24 files changed
+764
-614
No files matched your search
@@ -49,6 +49,27 @@ afterEach(() => {
|
||||
// Use getCcsDir() for consistent path resolution with production code
|
||||
const getTestCursorDir = () => path.join(getCcsDir(), 'cursor');
|
||||
|
||||
async function waitForProcessReady(pid: number): Promise<void> {
|
||||
for (let attempt = 0; attempt < 10; attempt++) {
|
||||
try {
|
||||
process.kill(pid, 0);
|
||||
|
||||
if (process.platform !== 'linux') {
|
||||
return;
|
||||
}
|
||||
|
||||
const commandLine = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8').replace(/\0/g, '').trim();
|
||||
if (commandLine.length > 0) {
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// Process is still starting up.
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 25));
|
||||
}
|
||||
}
|
||||
|
||||
describe('getPidFromFile', () => {
|
||||
it('returns null when no PID file exists', () => {
|
||||
expect(getPidFromFile()).toBeNull();
|
||||
@@ -230,6 +251,7 @@ describe('stopDaemon', () => {
|
||||
throw new Error('Failed to spawn unrelated process');
|
||||
}
|
||||
|
||||
await waitForProcessReady(unrelatedPid);
|
||||
writePidToFile(unrelatedPid);
|
||||
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user