Skip to content

Commit cfe7fa6

Browse files
committed
fix: Linux tests and build errors
1 parent 2b4b2d6 commit cfe7fa6

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

src/common/base-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ export abstract class BaseCommand extends Command {
125125
})
126126
}
127127

128-
protected async exit(code: number): Promise<never> {
129-
await this.reporter.hide();
128+
exit(code: number): never {
129+
this.reporter.hide();
130130

131131
process.exit(code);
132132
}

test/orchestrator/apply/apply.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import path from 'path';
2-
import { DestroyOrchestrator } from '../../../src/orchestrators/destroy.js';
32

43
import { describe, it, vi, afterEach, expect } from 'vitest';
54
import { MockOs } from '../mocks/system.js';
65
import { Plan } from '../../../src/entities/plan.js';
76
import { ResourceOperation } from 'codify-schemas';
87
import { MockReporter } from '../mocks/reporter.js';
98
import { ApplyOrchestrator } from '../../../src/orchestrators/apply';
9+
import {OsUtils} from "../../../src/utils/os-utils.js";
1010

1111
vi.mock('../../../src/plugins/plugin.js', async () => {
1212
const { MockPlugin } = await import('../mocks/plugin.js');
@@ -18,10 +18,15 @@ describe('Apply orchestrator tests', () => {
1818
it('Can apply a resource (create)', async () => {
1919
const reporter = new MockReporter({
2020
validatePlan(plan: Plan) {
21-
// Xcode-tools will always show up in the plan
22-
expect(plan.getResourcePlan('xcode-tools')).toMatchObject({
23-
operation: ResourceOperation.NOOP
24-
})
21+
if (OsUtils.isMacOS()) {
22+
// Xcode-tools will always show up in the plan
23+
expect(plan.getResourcePlan('xcode-tools')).toMatchObject({
24+
operation: ResourceOperation.NOOP
25+
})
26+
} else {
27+
// Xcode-tools should not be in linux or other os
28+
expect(plan.getResourcePlan('xcode-tools')).toMatchObject(null);
29+
}
2530
expect(plan.getResourcePlan('mock')).toMatchObject({
2631
operation: ResourceOperation.CREATE,
2732
});
@@ -56,7 +61,7 @@ describe('Apply orchestrator tests', () => {
5661
})
5762
});
5863

59-
it('Installs xcode-tools if it doesnt exist', async () => {
64+
it('Installs xcode-tools if it doesnt exist', { skip: !OsUtils.isMacOS() }, async () => {
6065
const reporter = new MockReporter({
6166
validatePlan(plan: Plan) {
6267
expect(plan.getResourcePlan('xcode-tools')).toMatchObject({

test/orchestrator/plan/plan.test.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import path from 'path';
2-
import { DestroyOrchestrator } from '../../../src/orchestrators/destroy.js';
32

43
import { describe, it, vi, afterEach, expect } from 'vitest';
54
import { MockOs } from '../mocks/system.js';
65
import { Plan } from '../../../src/entities/plan.js';
76
import { ResourceOperation } from 'codify-schemas';
87
import { MockReporter } from '../mocks/reporter.js';
9-
import { ApplyOrchestrator } from '../../../src/orchestrators/apply';
108
import { PlanOrchestrator } from '../../../src/orchestrators/plan';
9+
import {OsUtils} from "../../../src/utils/os-utils.js";
1110

1211
vi.mock('../../../src/plugins/plugin.js', async () => {
1312
const { MockPlugin } = await import('../mocks/plugin.js');
@@ -16,7 +15,7 @@ vi.mock('../../../src/plugins/plugin.js', async () => {
1615

1716
// The apply orchestrator directly calls plan so this will test both
1817
describe('Plan orchestrator tests', () => {
19-
it('Can plan a resource (create) including xcode-tools', async () => {
18+
it('Can plan a resource (create) including xcode-tools', { skip: !OsUtils.isMacOS() }, async () => {
2019
const reporter = new MockReporter({
2120
validatePlan(plan: Plan) {
2221
// Xcode-tools will always show up in the plan
@@ -56,10 +55,15 @@ describe('Plan orchestrator tests', () => {
5655
it('Prioritizes xcode-tools in front of other resources', async () => {
5756
const reporter = new MockReporter({
5857
validatePlan(plan: Plan) {
59-
// Xcode-tools will always show up in the plan
60-
expect(plan.getResourcePlan('xcode-tools')).toMatchObject({
61-
operation: ResourceOperation.CREATE
62-
})
58+
if (OsUtils.isMacOS()) {
59+
// Xcode-tools will always show up in the plan
60+
expect(plan.getResourcePlan('xcode-tools')).toMatchObject({
61+
operation: ResourceOperation.CREATE
62+
})
63+
} else {
64+
// Xcode-tools should not be in the plan for linux or other OS
65+
expect(plan.getResourcePlan('xcode-tools')).to.be.null;
66+
}
6367
expect(plan.getResourcePlan('mock.0')).toMatchObject({
6468
operation: ResourceOperation.CREATE,
6569
});
@@ -84,8 +88,13 @@ describe('Plan orchestrator tests', () => {
8488
expect(project).to.exist;
8589
expect(pluginManager).to.exist;
8690

87-
expect(project.evaluationOrder.length).to.eq(7);
88-
expect(project.evaluationOrder[0]).to.eq('xcode-tools');
91+
if (OsUtils.isMacOS()) {
92+
expect(project.evaluationOrder.length).to.eq(7);
93+
expect(project.evaluationOrder[0]).to.eq('xcode-tools');
94+
} else {
95+
expect(project.evaluationOrder.length).to.eq(6);
96+
expect(project.evaluationOrder[0]).to.not.eq('xcode-tools');
97+
}
8998

9099
// Nothing should be changed in the plan
91100
expect(MockOs.get('xcode-tools')).to.be.undefined;

0 commit comments

Comments
 (0)