|
1 | 1 | namespace ts.tscWatch {
|
2 |
| - function getDiagnosticWithoutFile(message: DiagnosticMessage, ..._args: (string | number)[]): Diagnostic { |
3 |
| - let text = getLocaleSpecificMessage(message); |
4 |
| - |
5 |
| - if (arguments.length > 1) { |
6 |
| - text = formatStringFromArgs(text, arguments, 1); |
7 |
| - } |
8 |
| - |
9 |
| - return getDiagnosticOfFileFrom(/*file*/ undefined, text, /*start*/ undefined, /*length*/ undefined, message); |
10 |
| - } |
11 |
| - |
12 |
| - function getDiagnosticOfFile(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ..._args: (string | number)[]): Diagnostic { |
13 |
| - let text = getLocaleSpecificMessage(message); |
14 |
| - |
15 |
| - if (arguments.length > 4) { |
16 |
| - text = formatStringFromArgs(text, arguments, 4); |
17 |
| - } |
18 |
| - |
19 |
| - return getDiagnosticOfFileFrom(file, text, start, length, message); |
20 |
| - } |
21 |
| - |
22 |
| - function getUnknownCompilerOption(program: Program, configFile: File, option: string) { |
23 |
| - const quotedOption = `"${option}"`; |
24 |
| - return getDiagnosticOfFile(program.getCompilerOptions().configFile!, configFile.content.indexOf(quotedOption), quotedOption.length, Diagnostics.Unknown_compiler_option_0, option); |
25 |
| - } |
26 |
| - |
27 |
| - describe("tsc-watch program updates", () => { |
| 2 | + describe("unittests:: tsc-watch:: program updates", () => { |
28 | 3 | it("create watch without config file", () => {
|
29 | 4 | const appFile: File = {
|
30 | 5 | path: "/a/b/c/app.ts",
|
@@ -1486,99 +1461,5 @@ interface Document {
|
1486 | 1461 | });
|
1487 | 1462 | });
|
1488 | 1463 |
|
1489 |
| - describe("tsc-watch console clearing", () => { |
1490 |
| - const currentDirectoryLog = "Current directory: / CaseSensitiveFileNames: false\n"; |
1491 |
| - const fileWatcherAddedLog = [ |
1492 |
| - "FileWatcher:: Added:: WatchInfo: /f.ts 250 Source file\n", |
1493 |
| - "FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n" |
1494 |
| - ]; |
1495 |
| - |
1496 |
| - const file: File = { |
1497 |
| - path: "/f.ts", |
1498 |
| - content: "" |
1499 |
| - }; |
1500 |
| - |
1501 |
| - function getProgramSynchronizingLog(options: CompilerOptions) { |
1502 |
| - return [ |
1503 |
| - "Synchronizing program\n", |
1504 |
| - "CreatingProgramWith::\n", |
1505 |
| - " roots: [\"/f.ts\"]\n", |
1506 |
| - ` options: ${JSON.stringify(options)}\n` |
1507 |
| - ]; |
1508 |
| - } |
1509 |
| - |
1510 |
| - function isConsoleClearDisabled(options: CompilerOptions) { |
1511 |
| - return options.diagnostics || options.extendedDiagnostics || options.preserveWatchOutput; |
1512 |
| - } |
1513 |
| - |
1514 |
| - function verifyCompilation(host: WatchedSystem, options: CompilerOptions, initialDisableOptions?: CompilerOptions) { |
1515 |
| - const disableConsoleClear = isConsoleClearDisabled(options); |
1516 |
| - const hasLog = options.extendedDiagnostics || options.diagnostics; |
1517 |
| - checkOutputErrorsInitial(host, emptyArray, initialDisableOptions ? isConsoleClearDisabled(initialDisableOptions) : disableConsoleClear, hasLog ? [ |
1518 |
| - currentDirectoryLog, |
1519 |
| - ...getProgramSynchronizingLog(options), |
1520 |
| - ...(options.extendedDiagnostics ? fileWatcherAddedLog : emptyArray) |
1521 |
| - ] : undefined); |
1522 |
| - host.modifyFile(file.path, "//"); |
1523 |
| - host.runQueuedTimeoutCallbacks(); |
1524 |
| - checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, hasLog ? [ |
1525 |
| - "FileWatcher:: Triggered with /f.ts 1:: WatchInfo: /f.ts 250 Source file\n", |
1526 |
| - "Scheduling update\n", |
1527 |
| - "Elapsed:: 0ms FileWatcher:: Triggered with /f.ts 1:: WatchInfo: /f.ts 250 Source file\n" |
1528 |
| - ] : undefined, hasLog ? getProgramSynchronizingLog(options) : undefined); |
1529 |
| - } |
1530 | 1464 |
|
1531 |
| - function checkConsoleClearingUsingCommandLineOptions(options: CompilerOptions = {}) { |
1532 |
| - const files = [file, libFile]; |
1533 |
| - const host = createWatchedSystem(files); |
1534 |
| - createWatchOfFilesAndCompilerOptions([file.path], host, options); |
1535 |
| - verifyCompilation(host, options); |
1536 |
| - } |
1537 |
| - |
1538 |
| - it("without --diagnostics or --extendedDiagnostics", () => { |
1539 |
| - checkConsoleClearingUsingCommandLineOptions(); |
1540 |
| - }); |
1541 |
| - it("with --diagnostics", () => { |
1542 |
| - checkConsoleClearingUsingCommandLineOptions({ |
1543 |
| - diagnostics: true, |
1544 |
| - }); |
1545 |
| - }); |
1546 |
| - it("with --extendedDiagnostics", () => { |
1547 |
| - checkConsoleClearingUsingCommandLineOptions({ |
1548 |
| - extendedDiagnostics: true, |
1549 |
| - }); |
1550 |
| - }); |
1551 |
| - it("with --preserveWatchOutput", () => { |
1552 |
| - checkConsoleClearingUsingCommandLineOptions({ |
1553 |
| - preserveWatchOutput: true, |
1554 |
| - }); |
1555 |
| - }); |
1556 |
| - |
1557 |
| - describe("when preserveWatchOutput is true in config file", () => { |
1558 |
| - const compilerOptions: CompilerOptions = { |
1559 |
| - preserveWatchOutput: true |
1560 |
| - }; |
1561 |
| - const configFile: File = { |
1562 |
| - path: "/tsconfig.json", |
1563 |
| - content: JSON.stringify({ compilerOptions }) |
1564 |
| - }; |
1565 |
| - const files = [file, configFile, libFile]; |
1566 |
| - it("using createWatchOfConfigFile ", () => { |
1567 |
| - const host = createWatchedSystem(files); |
1568 |
| - createWatchOfConfigFile(configFile.path, host); |
1569 |
| - // Initially console is cleared if --preserveOutput is not provided since the config file is yet to be parsed |
1570 |
| - verifyCompilation(host, compilerOptions, {}); |
1571 |
| - }); |
1572 |
| - it("when createWatchProgram is invoked with configFileParseResult on WatchCompilerHostOfConfigFile", () => { |
1573 |
| - const host = createWatchedSystem(files); |
1574 |
| - const reportDiagnostic = createDiagnosticReporter(host); |
1575 |
| - const optionsToExtend: CompilerOptions = {}; |
1576 |
| - const configParseResult = parseConfigFileWithSystem(configFile.path, optionsToExtend, host, reportDiagnostic)!; |
1577 |
| - const watchCompilerHost = createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath!, optionsToExtend, host, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(host)); |
1578 |
| - watchCompilerHost.configFileParsingResult = configParseResult; |
1579 |
| - createWatchProgram(watchCompilerHost); |
1580 |
| - verifyCompilation(host, compilerOptions); |
1581 |
| - }); |
1582 |
| - }); |
1583 |
| - }); |
1584 | 1465 | }
|
0 commit comments