-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun-tests-command.ts
More file actions
93 lines (84 loc) · 2.87 KB
/
Copy pathrun-tests-command.ts
File metadata and controls
93 lines (84 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { TestRunner } from '../services/test-runner.js';
import { ConfigLoader } from '../conf/config-loader.js';
// Type declaration for CVL loader
declare const cvlLoader: () => Promise<[{ default: any }]>;
export class RunCommand {
private testRunner: TestRunner;
constructor() {
this.testRunner = new TestRunner();
}
async execute(options: { config: string; output: string; validate?: boolean; quick?: boolean }): Promise<void> {
const config = new ConfigLoader(options.config);
const outputPath = options.output || config.Tests.ResultsPath;
// Convert ConfigLoader to the format expected by TestRunner
const configData = this.convertConfigToData(config, options.quick);
// Run tests using the shared TestRunner
const results = await this.testRunner.runTests(configData);
// Validate before saving if validation option is enabled
if (options.validate) {
console.log('Validating results before saving...');
const isValid = await results.validate();
if (isValid) {
console.log('Results file validation passed');
} else {
console.log('Results file validation failed, but continuing to save file...');
}
}
results._testsRunDescription = configData.Build.testsRunDescription;
results.save(outputPath);
// Always run validation after saving (existing behavior)
await results.validate();
}
private convertConfigToData(config: ConfigLoader, quick?: boolean): any {
return {
FhirServer: {
BaseUrl: config.FhirServer.BaseUrl,
CqlOperation: config.FhirServer.CqlOperation,
},
Build: {
CqlFileVersion: config.Build.CqlFileVersion,
CqlOutputPath: config.Build.CqlOutputPath,
CqlVersion: config.Build.CqlVersion,
testsRunDescription: config.Build?.testsRunDescription,
cqlTranslator: config.Build?.cqlTranslator,
cqlTranslatorVersion: config.Build?.cqlTranslatorVersion,
cqlEngine: config.Build?.cqlEngine,
cqlEngineVersion: config.Build?.cqlEngineVersion
},
Tests: {
ResultsPath: config.Tests.ResultsPath,
SkipList: (() => {
const env = process.env.SKIP_LIST;
if (env !== undefined) {
try {
const parsed = JSON.parse(env);
return Array.isArray(parsed) ? parsed : [];
} catch {
console.warn(
'Failed to parse SKIP_LIST environment variable. Falling back to SkipList in config file.'
);
}
}
return config.Tests.SkipList;
})(),
OnlyList: (() => {
const env = process.env.ONLY_LIST;
if (env !== undefined) {
try {
const parsed = JSON.parse(env);
return Array.isArray(parsed) ? parsed : [];
} catch {
console.warn(
'Failed to parse ONLY_LIST environment variable. Falling back to OnlyList in config file.'
);
}
}
return config.Tests.OnlyList || [];
})()
},
Debug: {
QuickTest: quick !== undefined ? quick : config.Debug.QuickTest,
},
};
}
}