-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathconfig.test.ts
More file actions
153 lines (145 loc) · 4.99 KB
/
config.test.ts
File metadata and controls
153 lines (145 loc) · 4.99 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import { ConfigurationReader, ExtensionConfigurationSettings } from '@cmt/config';
import { expect } from '@test/util';
function createConfig(conf: Partial<ExtensionConfigurationSettings>): ConfigurationReader {
const ret = new ConfigurationReader({
autoSelectActiveFolder: false,
defaultActiveFolder: null,
cmakePath: '',
buildDirectory: '',
installPrefix: null,
sourceDirectory: '',
saveBeforeBuild: true,
buildBeforeRun: true,
clearOutputBeforeBuild: true,
configureSettings: {},
cacheInit: null,
preferredGenerators: [],
generator: null,
toolset: null,
platform: null,
configureArgs: [],
buildArgs: [],
buildToolArgs: [],
parallelJobs: 0,
ctestPath: '',
cpackPath: '',
ctest: {
parallelJobs: 0,
allowParallelJobs: false,
testExplorerIntegrationEnabled: true,
testSuiteDelimiter: '',
debugLaunchTarget: null
},
parseBuildDiagnostics: true,
enabledOutputParsers: [],
debugConfig: {},
defaultVariants: {},
ctestArgs: [],
cpackArgs: [],
ctestDefaultArgs: [],
environment: {},
configureEnvironment: {},
buildEnvironment: {},
testEnvironment: {},
cpackEnvironment: {},
mingwSearchDirs: [], // Deprecated in 1.14, replaced by additionalCompilerSearchDirs, but kept for backwards compatibility
additionalCompilerSearchDirs: [],
emscriptenSearchDirs: [],
mergedCompileCommands: null,
copyCompileCommands: null,
loadCompileCommands: true,
configureOnOpen: true,
configureOnEdit: true,
deleteBuildDirOnCleanConfigure: false,
skipConfigureIfCachePresent: null,
useCMakeServer: true,
cmakeCommunicationMode: 'automatic',
showSystemKits: true,
ignoreKitEnv: false,
additionalKits: [],
pinnedCommands: [],
buildTask: false,
outputLogEncoding: 'auto',
enableTraceLogging: false,
loggingLevel: 'info',
touchbar: {
visibility: "default"
},
options: {
advanced: {},
statusBarVisibility: "visible"
},
useCMakePresets: 'never',
useVsDeveloperEnvironment: 'auto',
allowCommentsInPresetsFile: false,
allowUnsupportedPresetsVersions: false,
launchBehavior: 'reuseTerminal',
ignoreCMakeListsMissing: false,
automaticReconfigure: false,
enableAutomaticKitScan: true,
enableLanguageServices: true,
preRunCoverageTarget: null,
postRunCoverageTarget: null,
coverageInfoFiles: []
});
ret.updatePartial(conf);
return ret;
}
suite('Configuration', () => {
test('Create a read from a configuration', () => {
const conf = createConfig({ parallelJobs: 13 });
expect(conf.parallelJobs).to.eq(13);
});
test('Update a configuration', () => {
const conf = createConfig({ parallelJobs: 22 });
expect(conf.parallelJobs).to.eq(22);
conf.updatePartial({ parallelJobs: 4 });
expect(conf.parallelJobs).to.eq(4);
});
test('Listen for config changes', async () => {
const conf = createConfig({ parallelJobs: 22 });
let jobs = conf.parallelJobs;
expect(jobs).to.eq(22);
await new Promise<void>(resolve => {
conf.onChange('parallelJobs', j => {
jobs = j;
resolve();
});
conf.updatePartial({ parallelJobs: 3 });
});
expect(jobs).to.eq(3);
});
async function didItComplete(promise: Promise<any>, timeout: number): Promise<boolean> {
try {
await new Promise<void>((resolve, reject) => {
setTimeout(() => {
reject();
}, timeout);
void promise.then(() => {
resolve();
});
});
return true;
} catch {
return false;
}
}
test('Listen only fires for changing properties', async () => {
const conf = createConfig({ parallelJobs: 3 });
let changed = new Promise<void>(_ => {}); // never resolves
conf.onChange('parallelJobs', _ => {
changed = Promise.resolve(); // resolved
});
conf.updatePartial({ buildDirectory: 'foo' });
let completed = await didItComplete(changed, 1000);
expect(!completed, 'Update event should not fire');
conf.updatePartial({ parallelJobs: 4 });
completed = await didItComplete(changed, 1000);
expect(completed, 'Update event should fire');
});
test('Unchanged values in partial update are unaffected', () => {
const conf = createConfig({ parallelJobs: 5 });
conf.updatePartial({ buildDirectory: 'Foo' });
expect(conf.parallelJobs).to.eq(5);
});
});