Skip to content

Commit 5e105ea

Browse files
authored
Use correct current directory for calculation for tests for reusable program tests (#59303)
1 parent edd08a5 commit 5e105ea

25 files changed

+434
-433
lines changed

src/testRunner/unittests/helpers.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,24 @@ export function createTestCompilerHost(texts: readonly NamedSourceText[], target
118118
});
119119
if (useCaseSensitiveFileNames === undefined) useCaseSensitiveFileNames = ts.sys && ts.sys.useCaseSensitiveFileNames;
120120
const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
121-
const filesByPath = ts.mapEntries(files, (fileName, file) => [ts.toPath(fileName, "", getCanonicalFileName), file]);
121+
const currentDirectory = "/";
122+
const filesByPath = ts.mapEntries(files, (fileName, file) => [ts.toPath(fileName, currentDirectory, getCanonicalFileName), file]);
122123
const trace: string[] = [];
123124
const result: TestCompilerHost = {
124125
trace: s => trace.push(s),
125126
getTrace: () => trace,
126127
clearTrace: () => trace.length = 0,
127-
getSourceFile: fileName => filesByPath.get(ts.toPath(fileName, "", getCanonicalFileName)),
128+
getSourceFile: fileName => filesByPath.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)),
128129
getDefaultLibFileName: () => "lib.d.ts",
129130
writeFile: ts.notImplemented,
130-
getCurrentDirectory: () => "",
131+
getCurrentDirectory: () => currentDirectory,
131132
getDirectories: () => [],
132133
getCanonicalFileName,
133134
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
134135
getNewLine: () => ts.sys ? ts.sys.newLine : newLine,
135-
fileExists: fileName => filesByPath.has(ts.toPath(fileName, "", getCanonicalFileName)),
136+
fileExists: fileName => filesByPath.has(ts.toPath(fileName, currentDirectory, getCanonicalFileName)),
136137
readFile: fileName => {
137-
const file = filesByPath.get(ts.toPath(fileName, "", getCanonicalFileName));
138+
const file = filesByPath.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
138139
return file && file.text;
139140
},
140141
};

tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.js

Lines changed: 101 additions & 101 deletions
Large diffs are not rendered by default.

tests/baselines/reference/reuseProgramStructure/change-affects-imports.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

@@ -50,7 +50,7 @@ var z = 1;
5050
resolvedModules:
5151
b: {
5252
"resolvedModule": {
53-
"resolvedFileName": "b.ts",
53+
"resolvedFileName": "/b.ts",
5454
"extension": ".ts",
5555
"isExternalLibraryImport": false,
5656
"resolvedUsingTsExtension": false
@@ -73,14 +73,14 @@ var x = 1
7373
resolvedTypeReferenceDirectiveNames:
7474
typerefs: {
7575
"failedLookupLocations": [
76-
"node_modules/@types/typerefs/package.json",
77-
"node_modules/@types/typerefs/index.d.ts",
78-
"node_modules/typerefs/package.json",
79-
"node_modules/typerefs.d.ts",
80-
"node_modules/typerefs/index.d.ts",
81-
"node_modules/@types/typerefs/package.json",
82-
"node_modules/@types/typerefs.d.ts",
83-
"node_modules/@types/typerefs/index.d.ts"
76+
"/node_modules/@types/typerefs/package.json",
77+
"/node_modules/@types/typerefs/index.d.ts",
78+
"/node_modules/typerefs/package.json",
79+
"/node_modules/typerefs.d.ts",
80+
"/node_modules/typerefs/index.d.ts",
81+
"/node_modules/@types/typerefs/package.json",
82+
"/node_modules/@types/typerefs.d.ts",
83+
"/node_modules/@types/typerefs/index.d.ts"
8484
]
8585
}
8686

tests/baselines/reference/reuseProgramStructure/change-affects-tripleslash-references.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

@@ -63,14 +63,14 @@ var x = 1
6363
resolvedTypeReferenceDirectiveNames:
6464
typerefs1: {
6565
"failedLookupLocations": [
66-
"node_modules/@types/typerefs1/package.json",
67-
"node_modules/@types/typerefs1/index.d.ts",
68-
"node_modules/typerefs1/package.json",
69-
"node_modules/typerefs1.d.ts",
70-
"node_modules/typerefs1/index.d.ts",
71-
"node_modules/@types/typerefs1/package.json",
72-
"node_modules/@types/typerefs1.d.ts",
73-
"node_modules/@types/typerefs1/index.d.ts"
66+
"/node_modules/@types/typerefs1/package.json",
67+
"/node_modules/@types/typerefs1/index.d.ts",
68+
"/node_modules/typerefs1/package.json",
69+
"/node_modules/typerefs1.d.ts",
70+
"/node_modules/typerefs1/index.d.ts",
71+
"/node_modules/@types/typerefs1/package.json",
72+
"/node_modules/@types/typerefs1.d.ts",
73+
"/node_modules/@types/typerefs1/index.d.ts"
7474
]
7575
}
7676

tests/baselines/reference/reuseProgramStructure/change-affects-type-references.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

3434
automaticTypeDirectiveResolutions:
3535
a: {
3636
"failedLookupLocations": [
37-
"node_modules/@types/a/package.json",
38-
"node_modules/@types/a/index.d.ts",
39-
"node_modules/a/package.json",
40-
"node_modules/a.d.ts",
41-
"node_modules/a/index.d.ts",
42-
"node_modules/@types/a/package.json",
43-
"node_modules/@types/a.d.ts",
44-
"node_modules/@types/a/index.d.ts"
37+
"/node_modules/@types/a/package.json",
38+
"/node_modules/@types/a/index.d.ts",
39+
"/node_modules/a/package.json",
40+
"/node_modules/a.d.ts",
41+
"/node_modules/a/index.d.ts",
42+
"/node_modules/@types/a/package.json",
43+
"/node_modules/@types/a.d.ts",
44+
"/node_modules/@types/a/index.d.ts"
4545
]
4646
}
4747

@@ -77,28 +77,28 @@ var x = 1
7777
resolvedTypeReferenceDirectiveNames:
7878
typerefs: {
7979
"failedLookupLocations": [
80-
"node_modules/@types/typerefs/package.json",
81-
"node_modules/@types/typerefs/index.d.ts",
82-
"node_modules/typerefs/package.json",
83-
"node_modules/typerefs.d.ts",
84-
"node_modules/typerefs/index.d.ts",
85-
"node_modules/@types/typerefs/package.json",
86-
"node_modules/@types/typerefs.d.ts",
87-
"node_modules/@types/typerefs/index.d.ts"
80+
"/node_modules/@types/typerefs/package.json",
81+
"/node_modules/@types/typerefs/index.d.ts",
82+
"/node_modules/typerefs/package.json",
83+
"/node_modules/typerefs.d.ts",
84+
"/node_modules/typerefs/index.d.ts",
85+
"/node_modules/@types/typerefs/package.json",
86+
"/node_modules/@types/typerefs.d.ts",
87+
"/node_modules/@types/typerefs/index.d.ts"
8888
]
8989
}
9090

9191
automaticTypeDirectiveResolutions:
9292
b: {
9393
"failedLookupLocations": [
94-
"node_modules/@types/b/package.json",
95-
"node_modules/@types/b/index.d.ts",
96-
"node_modules/b/package.json",
97-
"node_modules/b.d.ts",
98-
"node_modules/b/index.d.ts",
99-
"node_modules/@types/b/package.json",
100-
"node_modules/@types/b.d.ts",
101-
"node_modules/@types/b/index.d.ts"
94+
"/node_modules/@types/b/package.json",
95+
"/node_modules/@types/b/index.d.ts",
96+
"/node_modules/b/package.json",
97+
"/node_modules/b.d.ts",
98+
"/node_modules/b/index.d.ts",
99+
"/node_modules/@types/b/package.json",
100+
"/node_modules/@types/b.d.ts",
101+
"/node_modules/@types/b/index.d.ts"
102102
]
103103
}
104104

tests/baselines/reference/reuseProgramStructure/change-does-not-affect-imports-or-type-refs.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

@@ -64,14 +64,14 @@ var x = 100
6464
resolvedTypeReferenceDirectiveNames:
6565
typerefs: {
6666
"failedLookupLocations": [
67-
"node_modules/@types/typerefs/package.json",
68-
"node_modules/@types/typerefs/index.d.ts",
69-
"node_modules/typerefs/package.json",
70-
"node_modules/typerefs.d.ts",
71-
"node_modules/typerefs/index.d.ts",
72-
"node_modules/@types/typerefs/package.json",
73-
"node_modules/@types/typerefs.d.ts",
74-
"node_modules/@types/typerefs/index.d.ts"
67+
"/node_modules/@types/typerefs/package.json",
68+
"/node_modules/@types/typerefs/index.d.ts",
69+
"/node_modules/typerefs/package.json",
70+
"/node_modules/typerefs.d.ts",
71+
"/node_modules/typerefs/index.d.ts",
72+
"/node_modules/@types/typerefs/package.json",
73+
"/node_modules/@types/typerefs.d.ts",
74+
"/node_modules/@types/typerefs/index.d.ts"
7575
]
7676
}
7777

tests/baselines/reference/reuseProgramStructure/change-doesnot-affect-type-references.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ var x = 1
2020
resolvedTypeReferenceDirectiveNames:
2121
typerefs: {
2222
"failedLookupLocations": [
23-
"node_modules/@types/typerefs/package.json",
24-
"node_modules/@types/typerefs/index.d.ts",
25-
"node_modules/typerefs/package.json",
26-
"node_modules/typerefs.d.ts",
27-
"node_modules/typerefs/index.d.ts",
28-
"node_modules/@types/typerefs/package.json",
29-
"node_modules/@types/typerefs.d.ts",
30-
"node_modules/@types/typerefs/index.d.ts"
23+
"/node_modules/@types/typerefs/package.json",
24+
"/node_modules/@types/typerefs/index.d.ts",
25+
"/node_modules/typerefs/package.json",
26+
"/node_modules/typerefs.d.ts",
27+
"/node_modules/typerefs/index.d.ts",
28+
"/node_modules/@types/typerefs/package.json",
29+
"/node_modules/@types/typerefs.d.ts",
30+
"/node_modules/@types/typerefs/index.d.ts"
3131
]
3232
}
3333

3434
automaticTypeDirectiveResolutions:
3535
a: {
3636
"failedLookupLocations": [
37-
"node_modules/@types/a/package.json",
38-
"node_modules/@types/a/index.d.ts",
39-
"node_modules/a/package.json",
40-
"node_modules/a.d.ts",
41-
"node_modules/a/index.d.ts",
42-
"node_modules/@types/a/package.json",
43-
"node_modules/@types/a.d.ts",
44-
"node_modules/@types/a/index.d.ts"
37+
"/node_modules/@types/a/package.json",
38+
"/node_modules/@types/a/index.d.ts",
39+
"/node_modules/a/package.json",
40+
"/node_modules/a.d.ts",
41+
"/node_modules/a/index.d.ts",
42+
"/node_modules/@types/a/package.json",
43+
"/node_modules/@types/a.d.ts",
44+
"/node_modules/@types/a/index.d.ts"
4545
]
4646
}
4747

@@ -77,28 +77,28 @@ var x = 1
7777
resolvedTypeReferenceDirectiveNames:
7878
typerefs: {
7979
"failedLookupLocations": [
80-
"node_modules/@types/typerefs/package.json",
81-
"node_modules/@types/typerefs/index.d.ts",
82-
"node_modules/typerefs/package.json",
83-
"node_modules/typerefs.d.ts",
84-
"node_modules/typerefs/index.d.ts",
85-
"node_modules/@types/typerefs/package.json",
86-
"node_modules/@types/typerefs.d.ts",
87-
"node_modules/@types/typerefs/index.d.ts"
80+
"/node_modules/@types/typerefs/package.json",
81+
"/node_modules/@types/typerefs/index.d.ts",
82+
"/node_modules/typerefs/package.json",
83+
"/node_modules/typerefs.d.ts",
84+
"/node_modules/typerefs/index.d.ts",
85+
"/node_modules/@types/typerefs/package.json",
86+
"/node_modules/@types/typerefs.d.ts",
87+
"/node_modules/@types/typerefs/index.d.ts"
8888
]
8989
}
9090

9191
automaticTypeDirectiveResolutions:
9292
a: {
9393
"failedLookupLocations": [
94-
"node_modules/@types/a/package.json",
95-
"node_modules/@types/a/index.d.ts",
96-
"node_modules/a/package.json",
97-
"node_modules/a.d.ts",
98-
"node_modules/a/index.d.ts",
99-
"node_modules/@types/a/package.json",
100-
"node_modules/@types/a.d.ts",
101-
"node_modules/@types/a/index.d.ts"
94+
"/node_modules/@types/a/package.json",
95+
"/node_modules/@types/a/index.d.ts",
96+
"/node_modules/a/package.json",
97+
"/node_modules/a.d.ts",
98+
"/node_modules/a/index.d.ts",
99+
"/node_modules/@types/a/package.json",
100+
"/node_modules/@types/a.d.ts",
101+
"/node_modules/@types/a/index.d.ts"
102102
]
103103
}
104104

0 commit comments

Comments
 (0)