Skip to content

Commit 0095e62

Browse files
committed
fix: test fixes
1 parent bb78863 commit 0095e62

5 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎test/orchestrator/apply/apply.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import { MockReporter } from '../mocks/reporter.js';
88
import { ApplyOrchestrator } from '../../../src/orchestrators/apply';
99
import {OsUtils} from "../../../src/utils/os-utils.js";
1010

11+
// In-process MockPlugins spawn BackgroundPtys that are never killed between tests. On Linux their
12+
// pending writes can land in the pty validateShell spawns (fd reuse), causing spurious failures.
13+
vi.mock('../../../src/utils/shell.js', async (importOriginal) => {
14+
const actual = await importOriginal<typeof import('../../../src/utils/shell.js')>();
15+
return {
16+
...actual,
17+
ShellUtils: {
18+
...actual.ShellUtils,
19+
validateShell: vi.fn(async () => {}),
20+
},
21+
}
22+
})
23+
1124
vi.mock('../../../src/plugins/plugin.js', async () => {
1225
const { MockPlugin } = await import('../mocks/plugin.js');
1326
return { Plugin: MockPlugin };

‎test/orchestrator/destroy/destroy.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ vi.mock('../mocks/get-mock-resources.js', async () => {
2929
}
3030
})
3131

32+
// In-process MockPlugins spawn BackgroundPtys that are never killed between tests. On Linux their
33+
// pending writes can land in the pty validateShell spawns (fd reuse), causing spurious failures.
34+
vi.mock('../../../src/utils/shell.js', async (importOriginal) => {
35+
const actual = await importOriginal<typeof import('../../../src/utils/shell.js')>();
36+
return {
37+
...actual,
38+
ShellUtils: {
39+
...actual.ShellUtils,
40+
validateShell: vi.fn(async () => {}),
41+
},
42+
}
43+
})
44+
3245
vi.mock('../../../src/plugins/plugin.js', async () => {
3346
const { MockPlugin } = await import('../mocks/plugin.js');
3447
return { Plugin: MockPlugin };

‎test/orchestrator/import/import.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ vi.mock('../mocks/get-mock-resources.js', async () => {
111111
}
112112
})
113113

114+
// In-process MockPlugins spawn BackgroundPtys that are never killed between tests. On Linux their
115+
// pending writes can land in the pty validateShell spawns (fd reuse), causing spurious failures.
116+
vi.mock('../../../src/utils/shell.js', async (importOriginal) => {
117+
const actual = await importOriginal<typeof import('../../../src/utils/shell.js')>();
118+
return {
119+
...actual,
120+
ShellUtils: {
121+
...actual.ShellUtils,
122+
validateShell: vi.fn(async () => {}),
123+
},
124+
}
125+
})
126+
114127
vi.mock('../../../src/plugins/plugin.js', async () => {
115128
const { MockPlugin } = await import('../mocks/plugin.js');
116129
return { Plugin: MockPlugin };

‎test/orchestrator/plan/plan.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import { MockReporter } from '../mocks/reporter.js';
88
import { PlanOrchestrator } from '../../../src/orchestrators/plan';
99
import {OsUtils} from "../../../src/utils/os-utils.js";
1010

11+
// In-process MockPlugins spawn BackgroundPtys that are never killed between tests. On Linux their
12+
// pending writes can land in the pty validateShell spawns (fd reuse), causing spurious failures.
13+
vi.mock('../../../src/utils/shell.js', async (importOriginal) => {
14+
const actual = await importOriginal<typeof import('../../../src/utils/shell.js')>();
15+
return {
16+
...actual,
17+
ShellUtils: {
18+
...actual.ShellUtils,
19+
validateShell: vi.fn(async () => {}),
20+
},
21+
}
22+
})
23+
1124
vi.mock('../../../src/plugins/plugin.js', async () => {
1225
const { MockPlugin } = await import('../mocks/plugin.js');
1326
return { Plugin: MockPlugin };

‎test/orchestrator/refresh/refresh.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ vi.mock('../mocks/get-mock-resources.js', async () => {
112112
}
113113
})
114114

115+
// In-process MockPlugins spawn BackgroundPtys that are never killed between tests. On Linux their
116+
// pending writes can land in the pty validateShell spawns (fd reuse), causing spurious failures.
117+
vi.mock('../../../src/utils/shell.js', async (importOriginal) => {
118+
const actual = await importOriginal<typeof import('../../../src/utils/shell.js')>();
119+
return {
120+
...actual,
121+
ShellUtils: {
122+
...actual.ShellUtils,
123+
validateShell: vi.fn(async () => {}),
124+
},
125+
}
126+
})
127+
115128
vi.mock('../../../src/plugins/plugin.js', async () => {
116129
const { MockPlugin } = await import('../mocks/plugin.js');
117130
return { Plugin: MockPlugin };

0 commit comments

Comments
 (0)