From 4a808aa417f00ee0e9f9e0901abbf7e42a102b50 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 18 Aug 2022 11:38:05 -0700 Subject: [PATCH] Add tests when realpath supresses the casing error --- src/testRunner/tsconfig.json | 1 + .../tsc/forceConsistentCasingInFileNames.ts | 18 ++++++ ...ative-and-non-relative-file-resolutions.js | 59 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts create mode 100644 tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-relative-and-non-relative-file-resolutions.js diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index c7f216ed298..8af0757080b 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -151,6 +151,7 @@ "unittests/tsc/cancellationToken.ts", "unittests/tsc/composite.ts", "unittests/tsc/declarationEmit.ts", + "unittests/tsc/forceConsistentCasingInFileNames.ts", "unittests/tsc/incremental.ts", "unittests/tsc/listFilesOnly.ts", "unittests/tsc/projectReferences.ts", diff --git a/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts b/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts new file mode 100644 index 00000000000..8718af088df --- /dev/null +++ b/src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts @@ -0,0 +1,18 @@ +namespace ts { + describe("unittests:: tsc:: forceConsistentCasingInFileNames::", () => { + verifyTsc({ + scenario: "forceConsistentCasingInFileNames", + subScenario: "with relative and non relative file resolutions", + commandLineArgs: ["/src/project/src/struct.d.ts", "--forceConsistentCasingInFileNames", "--explainFiles"], + fs: () => loadProjectFromFiles({ + "/src/project/src/struct.d.ts": Utils.dedent` + import * as xs1 from "fp-ts/lib/Struct"; + import * as xs2 from "fp-ts/lib/struct"; + import * as xs3 from "./Struct"; + import * as xs4 from "./struct"; + `, + "/src/project/node_modules/fp-ts/lib/struct.d.ts": `export function foo(): void`, + }), + }); + }); +} \ No newline at end of file diff --git a/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-relative-and-non-relative-file-resolutions.js b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-relative-and-non-relative-file-resolutions.js new file mode 100644 index 00000000000..a173cbbcb85 --- /dev/null +++ b/tests/baselines/reference/tsc/forceConsistentCasingInFileNames/with-relative-and-non-relative-file-resolutions.js @@ -0,0 +1,59 @@ +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/project/node_modules/fp-ts/lib/struct.d.ts] +export function foo(): void + +//// [/src/project/src/struct.d.ts] +import * as xs1 from "fp-ts/lib/Struct"; +import * as xs2 from "fp-ts/lib/struct"; +import * as xs3 from "./Struct"; +import * as xs4 from "./struct"; + + + + +Output:: +/lib/tsc /src/project/src/struct.d.ts --forceConsistentCasingInFileNames --explainFiles +src/project/src/struct.d.ts:3:22 - error TS1149: File name '/src/project/src/Struct.d.ts' differs from already included file name '/src/project/src/struct.d.ts' only in casing. + The file is in the program because: + Root file specified for compilation + Imported via "./Struct" from file '/src/project/src/struct.d.ts' + Imported via "./struct" from file '/src/project/src/struct.d.ts' + +3 import * as xs3 from "./Struct"; +   ~~~~~~~~~~ + + src/project/src/struct.d.ts:4:22 + 4 import * as xs4 from "./struct"; +    ~~~~~~~~~~ + File is included via import here. + +lib/lib.d.ts + Default library for target 'es3' +src/project/node_modules/fp-ts/lib/struct.d.ts + Imported via "fp-ts/lib/Struct" from file 'src/project/src/struct.d.ts' + Imported via "fp-ts/lib/struct" from file 'src/project/src/struct.d.ts' +src/project/src/struct.d.ts + Root file specified for compilation + Imported via "./Struct" from file 'src/project/src/struct.d.ts' + Imported via "./struct" from file 'src/project/src/struct.d.ts' + +Found 1 error in src/project/src/struct.d.ts:3 + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated + +