test: make suites robust in restricted environments
This commit is contained in:
+22
-4
@@ -1033,8 +1033,18 @@ describe('skills CLI helpers', () => {
|
||||
expect(runner.run).toHaveBeenCalledWith(['brew install jq']);
|
||||
});
|
||||
|
||||
it('shell command runner reports succeeded command status', () => {
|
||||
const runner = createShellSkillInstallerCommandRunner();
|
||||
it('shell command runner reports succeeded command status', async () => {
|
||||
// This test must not rely on actually spawning a shell (some sandboxed
|
||||
// environments disallow spawnSync(/bin/sh) with EPERM).
|
||||
vi.resetModules();
|
||||
const mockSpawnSync = vi.fn(() => ({ status: 0, signal: null, error: undefined }));
|
||||
vi.doMock('child_process', async () => {
|
||||
const actual = await vi.importActual<typeof import('child_process')>('child_process');
|
||||
return { ...actual, spawnSync: mockSpawnSync };
|
||||
});
|
||||
|
||||
const mod = await import('./skills.js');
|
||||
const runner = mod.createShellSkillInstallerCommandRunner();
|
||||
|
||||
const results = runner.run(['node -e "process.exit(0)"']);
|
||||
|
||||
@@ -1046,8 +1056,16 @@ describe('skills CLI helpers', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('shell command runner reports failed command with exit code reason', () => {
|
||||
const runner = createShellSkillInstallerCommandRunner();
|
||||
it('shell command runner reports failed command with exit code reason', async () => {
|
||||
vi.resetModules();
|
||||
const mockSpawnSync = vi.fn(() => ({ status: 7, signal: null, error: undefined }));
|
||||
vi.doMock('child_process', async () => {
|
||||
const actual = await vi.importActual<typeof import('child_process')>('child_process');
|
||||
return { ...actual, spawnSync: mockSpawnSync };
|
||||
});
|
||||
|
||||
const mod = await import('./skills.js');
|
||||
const runner = mod.createShellSkillInstallerCommandRunner();
|
||||
|
||||
const results = runner.run(['node -e "process.exit(7)"']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user