Skip to content

Commit

Permalink
Fixes the tests that got disabled when generating config set es2016 e…
Browse files Browse the repository at this point in the history
…xpecting to find libFile and remove incorrect affects flag from listFilesOnly (#51243)

* Fix the existing test

* Remove affectsEmit from listFilesOnly
  • Loading branch information
sheetalkamat committed Oct 31, 2022
1 parent 18f559f commit cfa55f1
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 1,080 deletions.
9 changes: 4 additions & 5 deletions src/compiler/commandLineParser.ts
Expand Up @@ -436,9 +436,6 @@ namespace ts {
name: "listFilesOnly",
type: "boolean",
category: Diagnostics.Command_line_Options,
affectsSemanticDiagnostics: true,
affectsEmit: true,
affectsMultiFileEmitBuildInfo: true,
isCommandLineOnly: true,
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
defaultValueDescription: false,
Expand Down Expand Up @@ -2411,7 +2408,8 @@ namespace ts {
return config;
}

function optionMapToObject(optionMap: ESMap<string, CompilerOptionsValue>): object {
/*@internal*/
export function optionMapToObject(optionMap: ESMap<string, CompilerOptionsValue>): object {
return {
...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {}),
};
Expand Down Expand Up @@ -2464,7 +2462,8 @@ namespace ts {
});
}

function serializeCompilerOptions(
/* @internal */
export function serializeCompilerOptions(
options: CompilerOptions,
pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean }
): ESMap<string, CompilerOptionsValue> {
Expand Down
4 changes: 4 additions & 0 deletions src/testRunner/unittests/tsc/helpers.ts
Expand Up @@ -6,6 +6,10 @@ namespace ts {
storeFilesChangingSignatureDuringEmit?: boolean;
};

export function compilerOptionsToConfigJson(options: CompilerOptions) {
return optionMapToObject(serializeCompilerOptions(options));
}

export const noChangeRun: TestTscEdit = {
subScenario: "no-change-run",
modifyFs: noop
Expand Down
21 changes: 21 additions & 0 deletions src/testRunner/unittests/tsc/listFilesOnly.ts
Expand Up @@ -19,5 +19,26 @@ namespace ts {
}),
commandLineArgs: ["/src/test.ts", "--listFilesOnly"]
});

verifyTscWithEdits({
scenario: "listFilesOnly",
subScenario: "combined with incremental",
fs: () => loadProjectFromFiles({
"/src/test.ts": `export const x = 1;`,
"/src/tsconfig.json": "{}"
}),
commandLineArgs: ["-p", "/src", "--incremental", "--listFilesOnly"],
edits: [
{
...noChangeRun,
commandLineArgs: ["-p", "/src", "--incremental"],
},
noChangeRun,
{
...noChangeRun,
commandLineArgs: ["-p", "/src", "--incremental"],
}
]
});
});
}
4 changes: 3 additions & 1 deletion src/testRunner/unittests/tscWatch/programUpdates.ts
Expand Up @@ -1164,7 +1164,9 @@ declare const eval: any`
};
const tsconfig: File = {
path: `${projectRoot}/tsconfig.json`,
content: generateTSConfig(options, emptyArray, "\n")
content: JSON.stringify({
compilerOptions: compilerOptionsToConfigJson(options)
})
};
return createWatchedSystem([file1, file2, libFile, tsconfig], { currentDirectory: projectRoot });
},
Expand Down
@@ -0,0 +1,105 @@
Input::
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

//// [/src/test.ts]
export const x = 1;

//// [/src/tsconfig.json]
{}



Output::
/lib/tsc -p /src --incremental --listFilesOnly
/lib/lib.d.ts
/src/test.ts
exitCode:: ExitStatus.Success




Change:: no-change-run
Input::


Output::
/lib/tsc -p /src --incremental
exitCode:: ExitStatus.Success


//// [/src/test.js]
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x = 1;


//// [/src/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../lib/lib.d.ts","./test.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-12038591281-export const x = 1;"],"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"}

//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../lib/lib.d.ts",
"./test.ts"
],
"fileInfos": {
"../lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./test.ts": {
"version": "-12038591281-export const x = 1;",
"signature": "-12038591281-export const x = 1;"
}
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../lib/lib.d.ts",
"./test.ts"
]
},
"version": "FakeTSVersion",
"size": 689
}



Change:: no-change-run
Input::


Output::
/lib/tsc -p /src --incremental --listFilesOnly
/lib/lib.d.ts
/src/test.ts
exitCode:: ExitStatus.Success




Change:: no-change-run
Input::


Output::
/lib/tsc -p /src --incremental
exitCode:: ExitStatus.Success


0 comments on commit cfa55f1

Please sign in to comment.