-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
helpers.ts
573 lines (516 loc) · 25.8 KB
/
helpers.ts
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
namespace ts.tscWatch {
export const projects = `/user/username/projects`;
export const projectRoot = `${projects}/myproject`;
export import WatchedSystem = TestFSWithWatch.TestServerHost;
export type File = TestFSWithWatch.File;
export type SymLink = TestFSWithWatch.SymLink;
export import libFile = TestFSWithWatch.libFile;
export import createWatchedSystem = TestFSWithWatch.createWatchedSystem;
export import checkArray = TestFSWithWatch.checkArray;
export import checkWatchedFiles = TestFSWithWatch.checkWatchedFiles;
export import checkWatchedFilesDetailed = TestFSWithWatch.checkWatchedFilesDetailed;
export import checkWatchedDirectories = TestFSWithWatch.checkWatchedDirectories;
export import checkWatchedDirectoriesDetailed = TestFSWithWatch.checkWatchedDirectoriesDetailed;
export import checkOutputContains = TestFSWithWatch.checkOutputContains;
export import checkOutputDoesNotContain = TestFSWithWatch.checkOutputDoesNotContain;
export const commonFile1: File = {
path: "/a/b/commonFile1.ts",
content: "let x = 1"
};
export const commonFile2: File = {
path: "/a/b/commonFile2.ts",
content: "let y = 1"
};
export function checkProgramActualFiles(program: Program, expectedFiles: readonly string[]) {
checkArray(`Program actual files`, program.getSourceFiles().map(file => file.fileName), expectedFiles);
}
export function checkProgramRootFiles(program: Program, expectedFiles: readonly string[]) {
checkArray(`Program rootFileNames`, program.getRootFileNames(), expectedFiles);
}
export type Watch = WatchOfConfigFile<EmitAndSemanticDiagnosticsBuilderProgram> | WatchOfFilesAndCompilerOptions<EmitAndSemanticDiagnosticsBuilderProgram>;
export function createWatchOfConfigFile(configFileName: string, system: WatchedSystem, optionsToExtend?: CompilerOptions, watchOptionsToExtend?: WatchOptions) {
const compilerHost = createWatchCompilerHostOfConfigFile({ configFileName, optionsToExtend, watchOptionsToExtend, system });
return createWatchProgram(compilerHost);
}
export function createWatchOfFilesAndCompilerOptions(rootFiles: string[], system: WatchedSystem, options: CompilerOptions = {}, watchOptions?: WatchOptions) {
const compilerHost = createWatchCompilerHostOfFilesAndCompilerOptions({ rootFiles, options, watchOptions, system });
return createWatchProgram(compilerHost);
}
const elapsedRegex = /^Elapsed:: \d+(?:\.\d+)?ms/;
const buildVerboseLogRegEx = /^.+ \- /;
export enum HostOutputKind {
Log,
Diagnostic,
WatchDiagnostic
}
export interface HostOutputLog {
kind: HostOutputKind.Log;
expected: string;
caption?: string;
}
export interface HostOutputDiagnostic {
kind: HostOutputKind.Diagnostic;
diagnostic: Diagnostic | string;
}
export interface HostOutputWatchDiagnostic {
kind: HostOutputKind.WatchDiagnostic;
diagnostic: Diagnostic | string;
}
export type HostOutput = HostOutputLog | HostOutputDiagnostic | HostOutputWatchDiagnostic;
export function checkOutputErrors(
host: WatchedSystem,
expected: readonly HostOutput[],
disableConsoleClears?: boolean | undefined
) {
let screenClears = 0;
const outputs = host.getOutput();
assert.equal(outputs.length, expected.length, JSON.stringify(outputs));
let index = 0;
forEach(expected, expected => {
switch (expected.kind) {
case HostOutputKind.Log:
return assertLog(expected);
case HostOutputKind.Diagnostic:
return assertDiagnostic(expected);
case HostOutputKind.WatchDiagnostic:
return assertWatchDiagnostic(expected);
default:
return Debug.assertNever(expected);
}
});
assert.equal(host.screenClears.length, screenClears, "Expected number of screen clears");
host.clearOutput();
function isDiagnostic(diagnostic: Diagnostic | string): diagnostic is Diagnostic {
return !!(diagnostic as Diagnostic).messageText;
}
function assertDiagnostic({ diagnostic }: HostOutputDiagnostic) {
const expected = isDiagnostic(diagnostic) ? formatDiagnostic(diagnostic, host) : diagnostic;
assert.equal(outputs[index], expected, getOutputAtFailedMessage("Diagnostic", expected));
index++;
}
function getCleanLogString(log: string) {
return log.replace(elapsedRegex, "").replace(buildVerboseLogRegEx, "");
}
function assertLog({ caption, expected }: HostOutputLog) {
const actual = outputs[index];
assert.equal(getCleanLogString(actual), getCleanLogString(expected), getOutputAtFailedMessage(caption || "Log", expected));
index++;
}
function assertWatchDiagnostic({ diagnostic }: HostOutputWatchDiagnostic) {
if (isString(diagnostic)) {
assert.equal(outputs[index], diagnostic, getOutputAtFailedMessage("Diagnostic", diagnostic));
}
else {
const expected = getWatchDiagnosticWithoutDate(diagnostic);
if (!disableConsoleClears && contains(screenStartingMessageCodes, diagnostic.code)) {
assert.equal(host.screenClears[screenClears], index, `Expected screen clear at this diagnostic: ${expected}`);
screenClears++;
}
assert.isTrue(endsWith(outputs[index], expected), getOutputAtFailedMessage("Watch diagnostic", expected));
}
index++;
}
function getOutputAtFailedMessage(caption: string, expectedOutput: string) {
return `Expected ${caption}: ${JSON.stringify(expectedOutput)} at ${index} in ${JSON.stringify(outputs)}`;
}
function getWatchDiagnosticWithoutDate(diagnostic: Diagnostic) {
const newLines = contains(screenStartingMessageCodes, diagnostic.code)
? `${host.newLine}${host.newLine}`
: host.newLine;
return ` - ${flattenDiagnosticMessageText(diagnostic.messageText, host.newLine)}${newLines}`;
}
}
export function hostOutputLog(expected: string, caption?: string): HostOutputLog {
return { kind: HostOutputKind.Log, expected, caption };
}
export function hostOutputDiagnostic(diagnostic: Diagnostic | string): HostOutputDiagnostic {
return { kind: HostOutputKind.Diagnostic, diagnostic };
}
export function hostOutputWatchDiagnostic(diagnostic: Diagnostic | string): HostOutputWatchDiagnostic {
return { kind: HostOutputKind.WatchDiagnostic, diagnostic };
}
export function startingCompilationInWatchMode() {
return hostOutputWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Starting_compilation_in_watch_mode));
}
export function foundErrorsWatching(errors: readonly any[]) {
return hostOutputWatchDiagnostic(errors.length === 1 ?
createCompilerDiagnostic(Diagnostics.Found_1_error_Watching_for_file_changes) :
createCompilerDiagnostic(Diagnostics.Found_0_errors_Watching_for_file_changes, errors.length)
);
}
export function fileChangeDetected() {
return hostOutputWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation));
}
export function checkOutputErrorsInitial(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], disableConsoleClears?: boolean, logsBeforeErrors?: string[]) {
checkOutputErrors(
host,
[
startingCompilationInWatchMode(),
...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")),
...map(errors, hostOutputDiagnostic),
foundErrorsWatching(errors)
],
disableConsoleClears
);
}
export function checkOutputErrorsIncremental(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], disableConsoleClears?: boolean, logsBeforeWatchDiagnostic?: string[], logsBeforeErrors?: string[]) {
checkOutputErrors(
host,
[
...map(logsBeforeWatchDiagnostic || emptyArray, expected => hostOutputLog(expected, "logsBeforeWatchDiagnostic")),
fileChangeDetected(),
...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")),
...map(errors, hostOutputDiagnostic),
foundErrorsWatching(errors)
],
disableConsoleClears
);
}
export function checkOutputErrorsIncrementalWithExit(host: WatchedSystem, errors: readonly Diagnostic[] | readonly string[], expectedExitCode: ExitStatus, disableConsoleClears?: boolean, logsBeforeWatchDiagnostic?: string[], logsBeforeErrors?: string[]) {
checkOutputErrors(
host,
[
...map(logsBeforeWatchDiagnostic || emptyArray, expected => hostOutputLog(expected, "logsBeforeWatchDiagnostic")),
fileChangeDetected(),
...map(logsBeforeErrors || emptyArray, expected => hostOutputLog(expected, "logBeforeError")),
...map(errors, hostOutputDiagnostic),
],
disableConsoleClears
);
assert.equal(host.exitCode, expectedExitCode);
}
export function checkNormalBuildErrors(
host: WatchedSystem,
errors: readonly Diagnostic[] | readonly string[],
files: readonly ReportFileInError[],
reportErrorSummary?: boolean
) {
checkOutputErrors(
host,
[
...map(errors, hostOutputDiagnostic),
...reportErrorSummary ?
[hostOutputWatchDiagnostic(getErrorSummaryText(errors.length, files, host.newLine))] :
emptyArray
]
);
}
export function getDiagnosticMessageChain(message: DiagnosticMessage, args?: (string | number)[], next?: DiagnosticMessageChain[]): DiagnosticMessageChain {
let text = getLocaleSpecificMessage(message);
if (args?.length) {
text = formatStringFromArgs(text, args);
}
return {
messageText: text,
category: message.category,
code: message.code,
next
};
}
function isDiagnosticMessageChain(message: DiagnosticMessage | DiagnosticMessageChain): message is DiagnosticMessageChain {
return !!(message as DiagnosticMessageChain).messageText;
}
export function getDiagnosticOfFileFrom(file: SourceFile | undefined, start: number | undefined, length: number | undefined, message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
return {
file,
start,
length,
messageText: isDiagnosticMessageChain(message) ?
message :
getDiagnosticMessageChain(message, args).messageText,
category: message.category,
code: message.code,
};
}
export function getDiagnosticWithoutFile(message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
return getDiagnosticOfFileFrom(/*file*/ undefined, /*start*/ undefined, /*length*/ undefined, message, ...args);
}
export function getDiagnosticOfFile(file: SourceFile, start: number, length: number, message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
return getDiagnosticOfFileFrom(file, start, length, message, ...args);
}
export function getDiagnosticOfFileFromProgram(program: Program, filePath: string, start: number, length: number, message: DiagnosticMessage | DiagnosticMessageChain, ...args: (string | number)[]): Diagnostic {
return getDiagnosticOfFileFrom(program.getSourceFileByPath(toPath(filePath, program.getCurrentDirectory(), s => s.toLowerCase())),
start, length, message, ...args);
}
export function getUnknownCompilerOption(program: Program, configFile: File, option: string) {
const quotedOption = `"${option}"`;
return getDiagnosticOfFile(program.getCompilerOptions().configFile!, configFile.content.indexOf(quotedOption), quotedOption.length, Diagnostics.Unknown_compiler_option_0, option);
}
export function getUnknownDidYouMeanCompilerOption(program: Program, configFile: File, option: string, didYouMean: string) {
const quotedOption = `"${option}"`;
return getDiagnosticOfFile(program.getCompilerOptions().configFile!, configFile.content.indexOf(quotedOption), quotedOption.length, Diagnostics.Unknown_compiler_option_0_Did_you_mean_1, option, didYouMean);
}
export function getDiagnosticModuleNotFoundOfFile(program: Program, file: File, moduleName: string) {
const quotedModuleName = `"${moduleName}"`;
return getDiagnosticOfFileFromProgram(program, file.path, file.content.indexOf(quotedModuleName), quotedModuleName.length, Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option, moduleName);
}
export function runQueuedTimeoutCallbacks(sys: WatchedSystem) {
sys.runQueuedTimeoutCallbacks();
}
export function checkSingleTimeoutQueueLengthAndRun(sys: WatchedSystem) {
sys.checkTimeoutQueueLengthAndRun(1);
}
export function checkSingleTimeoutQueueLengthAndRunAndVerifyNoTimeout(sys: WatchedSystem) {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
}
export interface TscWatchCompileChange {
caption: string;
change: (sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles) => void;
timeouts: (
sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles,
programs: readonly CommandLineProgram[],
watchOrSolution: ReturnType<typeof executeCommandLine>
) => void;
}
export interface TscWatchCheckOptions {
baselineSourceMap?: boolean;
baselineDependencies?: boolean;
}
export interface TscWatchCompileBase extends TscWatchCheckOptions {
scenario: string;
subScenario: string;
commandLineArgs: readonly string[];
changes: readonly TscWatchCompileChange[];
}
export interface TscWatchCompile extends TscWatchCompileBase {
sys: () => WatchedSystem;
}
export const noopChange: TscWatchCompileChange = {
caption: "No change",
change: noop,
timeouts: sys => sys.checkTimeoutQueueLength(0),
};
export type SystemSnap = ReturnType<WatchedSystem["snap"]>;
function tscWatchCompile(input: TscWatchCompile) {
it("tsc-watch:: Generates files matching the baseline", () => {
const { sys, baseline, oldSnap } = createBaseline(input.sys());
const {
scenario, subScenario,
commandLineArgs, changes,
baselineSourceMap, baselineDependencies
} = input;
if (!isWatch(commandLineArgs)) sys.exit = exitCode => sys.exitCode = exitCode;
const { cb, getPrograms } = commandLineCallbacks(sys);
const watchOrSolution = executeCommandLine(
sys,
cb,
commandLineArgs,
);
runWatchBaseline({
scenario,
subScenario,
commandLineArgs,
sys,
baseline,
oldSnap,
getPrograms,
baselineSourceMap,
baselineDependencies,
changes,
watchOrSolution
});
});
}
export interface Baseline {
baseline: string[];
sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles;
oldSnap: SystemSnap;
}
export function createBaseline(system: WatchedSystem): Baseline {
const sys = TestFSWithWatch.changeToHostTrackingWrittenFiles(
fakes.patchHostForBuildInfoReadWrite(system)
);
const baseline: string[] = [];
baseline.push("Input::");
sys.diff(baseline);
return { sys, baseline, oldSnap: sys.snap() };
}
export function applyChange(sys: Baseline["sys"], baseline: Baseline["baseline"], change: TscWatchCompileChange["change"], caption?: TscWatchCompileChange["caption"]) {
const oldSnap = sys.snap();
baseline.push(`Change::${caption ? " " + caption : ""}`, "");
change(sys);
baseline.push("Input::");
sys.diff(baseline, oldSnap);
return sys.snap();
}
export interface RunWatchBaseline extends Baseline, TscWatchCompileBase {
sys: TestFSWithWatch.TestServerHostTrackingWrittenFiles;
getPrograms: () => readonly CommandLineProgram[];
watchOrSolution: ReturnType<typeof executeCommandLine>;
}
export function runWatchBaseline({
scenario, subScenario, commandLineArgs,
getPrograms, sys, baseline, oldSnap,
baselineSourceMap, baselineDependencies,
changes, watchOrSolution
}: RunWatchBaseline) {
baseline.push(`${sys.getExecutingFilePath()} ${commandLineArgs.join(" ")}`);
let programs = watchBaseline({
baseline,
getPrograms,
oldPrograms: emptyArray,
sys,
oldSnap,
baselineSourceMap,
baselineDependencies,
});
for (const { caption, change, timeouts } of changes) {
oldSnap = applyChange(sys, baseline, change, caption);
timeouts(sys, programs, watchOrSolution);
programs = watchBaseline({
baseline,
getPrograms,
oldPrograms: programs,
sys,
oldSnap,
baselineSourceMap,
baselineDependencies,
});
}
Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ?
isWatch(commandLineArgs) ? "tsbuild/watchMode" : "tsbuild" :
isWatch(commandLineArgs) ? "tscWatch" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n"));
}
function isWatch(commandLineArgs: readonly string[]) {
return forEach(commandLineArgs, arg => {
if (arg.charCodeAt(0) !== CharacterCodes.minus) return false;
const option = arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase();
return option === "watch" || option === "w";
});
}
export interface WatchBaseline extends Baseline, TscWatchCheckOptions {
oldPrograms: readonly (CommandLineProgram | undefined)[];
getPrograms: () => readonly CommandLineProgram[];
}
export function watchBaseline({ baseline, getPrograms, oldPrograms, sys, oldSnap, baselineSourceMap, baselineDependencies }: WatchBaseline) {
if (baselineSourceMap) generateSourceMapBaselineFiles(sys);
sys.serializeOutput(baseline);
const programs = baselinePrograms(baseline, getPrograms, oldPrograms, baselineDependencies);
sys.serializeWatches(baseline);
baseline.push(`exitCode:: ExitStatus.${ExitStatus[sys.exitCode as ExitStatus]}`, "");
sys.diff(baseline, oldSnap);
sys.writtenFiles.forEach((value, key) => {
assert.equal(value, 1, `Expected to write file ${key} only once`);
});
sys.writtenFiles.clear();
return programs;
}
export function baselinePrograms(baseline: string[], getPrograms: () => readonly CommandLineProgram[], oldPrograms: readonly (CommandLineProgram | undefined)[], baselineDependencies: boolean | undefined) {
const programs = getPrograms();
for (let i = 0; i < programs.length; i++) {
baselineProgram(baseline, programs[i], oldPrograms[i], baselineDependencies);
}
return programs;
}
function baselineProgram(baseline: string[], [program, builderProgram]: CommandLineProgram, oldProgram: CommandLineProgram | undefined, baselineDependencies: boolean | undefined) {
if (program !== oldProgram?.[0]) {
const options = program.getCompilerOptions();
baseline.push(`Program root files: ${JSON.stringify(program.getRootFileNames())}`);
baseline.push(`Program options: ${JSON.stringify(options)}`);
baseline.push(`Program structureReused: ${(ts as any).StructureIsReused[program.structureIsReused]}`);
baseline.push("Program files::");
for (const file of program.getSourceFiles()) {
baseline.push(file.fileName);
}
}
else {
baseline.push(`Program: Same as old program`);
}
baseline.push("");
if (!builderProgram) return;
if (builderProgram !== oldProgram?.[1]) {
const state = builderProgram.getState();
const internalState = state as unknown as BuilderState;
if (state.semanticDiagnosticsPerFile?.size) {
baseline.push("Semantic diagnostics in builder refreshed for::");
for (const file of program.getSourceFiles()) {
if (!state.semanticDiagnosticsFromOldState || !state.semanticDiagnosticsFromOldState.has(file.resolvedPath)) {
baseline.push(file.fileName);
}
}
}
else {
baseline.push("No cached semantic diagnostics in the builder::");
}
if (internalState) {
baseline.push("");
if (internalState.hasCalledUpdateShapeSignature?.size) {
baseline.push("Shape signatures in builder refreshed for::");
internalState.hasCalledUpdateShapeSignature.forEach((path: Path) => {
const info = state.fileInfos.get(path);
if(info?.version === info?.signature || !info?.signature) {
baseline.push(path + " (used version)");
}
else {
baseline.push(path + " (computed .d.ts)");
}
});
}
else {
baseline.push("No shapes updated in the builder::");
}
}
baseline.push("");
if (!baselineDependencies) return;
baseline.push("Dependencies for::");
for (const file of builderProgram.getSourceFiles()) {
baseline.push(`${file.fileName}:`);
for (const depenedency of builderProgram.getAllDependencies(file)) {
baseline.push(` ${depenedency}`);
}
}
}
else {
baseline.push(`BuilderProgram: Same as old builder program`);
}
baseline.push("");
}
export interface VerifyTscWatch extends TscWatchCompile {
baselineIncremental?: boolean;
}
export function verifyTscWatch(input: VerifyTscWatch) {
describe(input.scenario, () => {
describe(input.subScenario, () => {
tscWatchCompile(input);
});
if (input.baselineIncremental) {
describe(`${input.subScenario} with incremental`, () => {
tscWatchCompile({
...input,
subScenario: `${input.subScenario} with incremental`,
commandLineArgs: [...input.commandLineArgs, "--incremental"],
});
});
}
});
}
export function replaceFileText(sys: WatchedSystem, file: string, searchValue: string | RegExp, replaceValue: string) {
const content = Debug.checkDefined(sys.readFile(file));
sys.writeFile(file, content.replace(searchValue, replaceValue));
}
export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) {
const host = createSolutionBuilderHost(system);
return ts.createSolutionBuilder(host, rootNames, defaultOptions || {});
}
export function ensureErrorFreeBuild(host: WatchedSystem, rootNames: readonly string[]) {
// ts build should succeed
const solutionBuilder = createSolutionBuilder(host, rootNames, {});
solutionBuilder.build();
assert.equal(host.getOutput().length, 0, JSON.stringify(host.getOutput(), /*replacer*/ undefined, " "));
}
export function createSystemWithSolutionBuild(solutionRoots: readonly string[], files: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) {
const sys = createWatchedSystem(files, params);
const originalReadFile = sys.readFile;
const originalWrite = sys.write;
const originalWriteFile = sys.writeFile;
const solutionBuilder = createSolutionBuilder(TestFSWithWatch.changeToHostTrackingWrittenFiles(
fakes.patchHostForBuildInfoReadWrite(sys)
), solutionRoots, {});
solutionBuilder.build();
sys.readFile = originalReadFile;
sys.write = originalWrite;
sys.writeFile = originalWriteFile;
return sys;
}
}