@@ -1021,13 +1021,18 @@ const a: string = "hello";`),
1021
1021
} ) ;
1022
1022
} ) ;
1023
1023
1024
- describe ( "unittests:: tsbuild:: watchMode:: persistentResolutions" , ( ) => {
1025
- verifyTscWatch ( {
1026
- scenario : "persistResolutions" ,
1027
- subScenario : "saves resolution and uses it for new program" ,
1028
- sys : ( ) => createWatchedSystem ( [
1024
+ describe ( "unittests:: tsbuild:: watchMode:: persistResolutions" , ( ) => {
1025
+ function getSys ( outFile ?: string ) {
1026
+ return createWatchedSystem ( [
1029
1027
{
1030
1028
path : `${ projectRoot } /src/main.ts` ,
1029
+ content : Utils . dedent `
1030
+ import { something } from "./filePresent";
1031
+ import { something as something1 } from "./filePresent";
1032
+ import { something2 } from "./fileNotFound";` ,
1033
+ } ,
1034
+ {
1035
+ path : `${ projectRoot } /src/anotherFileReusingResolution.ts` ,
1031
1036
content : Utils . dedent `
1032
1037
import { something } from "./filePresent";
1033
1038
import { something2 } from "./fileNotFound";` ,
@@ -1044,12 +1049,42 @@ const a: string = "hello";`),
1044
1049
composite : true ,
1045
1050
persistResolutions : true ,
1046
1051
traceResolution : true ,
1052
+ outFile
1047
1053
} ,
1048
1054
include : [ "src/**/*.ts" ]
1049
1055
} ) ,
1050
1056
} ,
1051
1057
libFile
1052
- ] , { currentDirectory : projectRoot } ) ,
1058
+ ] , { currentDirectory : projectRoot } ) ;
1059
+ }
1060
+
1061
+ function getSysWithSavedResolutions ( outFile ?: string ) {
1062
+ const sys = getSys ( outFile ) ;
1063
+ const exit = sys . exit ;
1064
+ sys . exit = noop ;
1065
+ fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => executeCommandLine ( sys , noop , [ "--b" , "." ] ) ) ;
1066
+ sys . exit = exit ;
1067
+ sys . clearOutput ( ) ;
1068
+ return sys ;
1069
+ }
1070
+
1071
+ function getSysWithClearedResolutions ( outFile ?: string ) {
1072
+ const sys = getSys ( outFile ) ;
1073
+ const exit = sys . exit ;
1074
+ sys . exit = noop ;
1075
+ fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => {
1076
+ executeCommandLine ( sys , noop , [ "--b" , "." ] ) ;
1077
+ executeCommandLine ( sys , noop , [ "--b" , "." , "--cleanPersistedProgram" ] ) ;
1078
+ } ) ;
1079
+ sys . exit = exit ;
1080
+ sys . clearOutput ( ) ;
1081
+ return sys ;
1082
+ }
1083
+
1084
+ verifyTscWatch ( {
1085
+ scenario : "persistResolutions" ,
1086
+ subScenario : "saves resolution and uses it for new program" ,
1087
+ sys : getSys ,
1053
1088
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1054
1089
changes : [
1055
1090
{
@@ -1078,39 +1113,7 @@ const a: string = "hello";`),
1078
1113
verifyTscWatch ( {
1079
1114
scenario : "persistResolutions" ,
1080
1115
subScenario : "can build after resolutions have been saved in tsbuildinfo file" ,
1081
- sys : ( ) => {
1082
- const sys = createWatchedSystem ( [
1083
- {
1084
- path : `${ projectRoot } /src/main.ts` ,
1085
- content : Utils . dedent `
1086
- import { something } from "./filePresent";
1087
- import { something2 } from "./fileNotFound";` ,
1088
- } ,
1089
- {
1090
- path : `${ projectRoot } /src/filePresent.ts` ,
1091
- content : `export function something() { return 10; }` ,
1092
- } ,
1093
- {
1094
- path : `${ projectRoot } /tsconfig.json` ,
1095
- content : JSON . stringify ( {
1096
- compilerOptions : {
1097
- module : "amd" ,
1098
- composite : true ,
1099
- persistResolutions : true ,
1100
- traceResolution : true ,
1101
- } ,
1102
- include : [ "src/**/*.ts" ]
1103
- } ) ,
1104
- } ,
1105
- libFile
1106
- ] , { currentDirectory : projectRoot } ) ;
1107
- const exit = sys . exit ;
1108
- sys . exit = noop ;
1109
- fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => executeCommandLine ( sys , noop , [ "--b" , "." ] ) ) ;
1110
- sys . exit = exit ;
1111
- sys . clearOutput ( ) ;
1112
- return sys ;
1113
- } ,
1116
+ sys : getSysWithSavedResolutions ,
1114
1117
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1115
1118
changes : [
1116
1119
{
@@ -1139,42 +1142,7 @@ const a: string = "hello";`),
1139
1142
verifyTscWatch ( {
1140
1143
scenario : "persistResolutions" ,
1141
1144
subScenario : "can build after resolutions are cleaned" ,
1142
- sys : ( ) => {
1143
- const sys = createWatchedSystem ( [
1144
- {
1145
- path : `${ projectRoot } /src/main.ts` ,
1146
- content : Utils . dedent `
1147
- import { something } from "./filePresent";
1148
- import { something2 } from "./fileNotFound";` ,
1149
- } ,
1150
- {
1151
- path : `${ projectRoot } /src/filePresent.ts` ,
1152
- content : `export function something() { return 10; }` ,
1153
- } ,
1154
- {
1155
- path : `${ projectRoot } /tsconfig.json` ,
1156
- content : JSON . stringify ( {
1157
- compilerOptions : {
1158
- module : "amd" ,
1159
- composite : true ,
1160
- persistResolutions : true ,
1161
- traceResolution : true ,
1162
- } ,
1163
- include : [ "src/**/*.ts" ]
1164
- } ) ,
1165
- } ,
1166
- libFile
1167
- ] , { currentDirectory : projectRoot } ) ;
1168
- const exit = sys . exit ;
1169
- sys . exit = noop ;
1170
- fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => {
1171
- executeCommandLine ( sys , noop , [ "--b" , "." ] ) ;
1172
- executeCommandLine ( sys , noop , [ "--b" , "." , "--cleanPersistedProgram" ] ) ;
1173
- } ) ;
1174
- sys . exit = exit ;
1175
- sys . clearOutput ( ) ;
1176
- return sys ;
1177
- } ,
1145
+ sys : getSysWithClearedResolutions ,
1178
1146
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1179
1147
changes : [
1180
1148
{
@@ -1204,32 +1172,7 @@ const a: string = "hello";`),
1204
1172
verifyTscWatch ( {
1205
1173
scenario : "persistResolutions" ,
1206
1174
subScenario : "saves resolution and uses it for new program with outFile" ,
1207
- sys : ( ) => createWatchedSystem ( [
1208
- {
1209
- path : `${ projectRoot } /src/main.ts` ,
1210
- content : Utils . dedent `
1211
- import { something } from "./filePresent";
1212
- import { something2 } from "./fileNotFound";` ,
1213
- } ,
1214
- {
1215
- path : `${ projectRoot } /src/filePresent.ts` ,
1216
- content : `export function something() { return 10; }` ,
1217
- } ,
1218
- {
1219
- path : `${ projectRoot } /tsconfig.json` ,
1220
- content : JSON . stringify ( {
1221
- compilerOptions : {
1222
- module : "amd" ,
1223
- composite : true ,
1224
- persistResolutions : true ,
1225
- traceResolution : true ,
1226
- outFile : "outFile.js"
1227
- } ,
1228
- include : [ "src/**/*.ts" ]
1229
- } ) ,
1230
- } ,
1231
- libFile
1232
- ] , { currentDirectory : projectRoot } ) ,
1175
+ sys : ( ) => getSys ( "outFile.js" ) ,
1233
1176
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1234
1177
changes : [
1235
1178
{
@@ -1258,40 +1201,7 @@ const a: string = "hello";`),
1258
1201
verifyTscWatch ( {
1259
1202
scenario : "persistResolutions" ,
1260
1203
subScenario : "can build after resolutions have been saved in tsbuildinfo file with outFile" ,
1261
- sys : ( ) => {
1262
- const sys = createWatchedSystem ( [
1263
- {
1264
- path : `${ projectRoot } /src/main.ts` ,
1265
- content : Utils . dedent `
1266
- import { something } from "./filePresent";
1267
- import { something2 } from "./fileNotFound";` ,
1268
- } ,
1269
- {
1270
- path : `${ projectRoot } /src/filePresent.ts` ,
1271
- content : `export function something() { return 10; }` ,
1272
- } ,
1273
- {
1274
- path : `${ projectRoot } /tsconfig.json` ,
1275
- content : JSON . stringify ( {
1276
- compilerOptions : {
1277
- module : "amd" ,
1278
- composite : true ,
1279
- persistResolutions : true ,
1280
- traceResolution : true ,
1281
- outFile : "outFile.js"
1282
- } ,
1283
- include : [ "src/**/*.ts" ]
1284
- } ) ,
1285
- } ,
1286
- libFile
1287
- ] , { currentDirectory : projectRoot } ) ;
1288
- const exit = sys . exit ;
1289
- sys . exit = noop ;
1290
- fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => executeCommandLine ( sys , noop , [ "--b" , "." ] ) ) ;
1291
- sys . exit = exit ;
1292
- sys . clearOutput ( ) ;
1293
- return sys ;
1294
- } ,
1204
+ sys : ( ) => getSysWithSavedResolutions ( "outFile.js" ) ,
1295
1205
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1296
1206
changes : [
1297
1207
{
@@ -1320,43 +1230,7 @@ const a: string = "hello";`),
1320
1230
verifyTscWatch ( {
1321
1231
scenario : "persistResolutions" ,
1322
1232
subScenario : "can build after resolutions are cleaned with outFile" ,
1323
- sys : ( ) => {
1324
- const sys = createWatchedSystem ( [
1325
- {
1326
- path : `${ projectRoot } /src/main.ts` ,
1327
- content : Utils . dedent `
1328
- import { something } from "./filePresent";
1329
- import { something2 } from "./fileNotFound";` ,
1330
- } ,
1331
- {
1332
- path : `${ projectRoot } /src/filePresent.ts` ,
1333
- content : `export function something() { return 10; }` ,
1334
- } ,
1335
- {
1336
- path : `${ projectRoot } /tsconfig.json` ,
1337
- content : JSON . stringify ( {
1338
- compilerOptions : {
1339
- module : "amd" ,
1340
- composite : true ,
1341
- persistResolutions : true ,
1342
- traceResolution : true ,
1343
- outFile : "outFile.js"
1344
- } ,
1345
- include : [ "src/**/*.ts" ]
1346
- } ) ,
1347
- } ,
1348
- libFile
1349
- ] , { currentDirectory : projectRoot } ) ;
1350
- const exit = sys . exit ;
1351
- sys . exit = noop ;
1352
- fakes . withTemporaryPatchingForBuildinfoReadWrite ( sys , sys => {
1353
- executeCommandLine ( sys , noop , [ "--b" , "." ] ) ;
1354
- executeCommandLine ( sys , noop , [ "--b" , "." , "--cleanPersistedProgram" ] ) ;
1355
- } ) ;
1356
- sys . exit = exit ;
1357
- sys . clearOutput ( ) ;
1358
- return sys ;
1359
- } ,
1233
+ sys : ( ) => getSysWithClearedResolutions ( "outFile.js" ) ,
1360
1234
commandLineArgs : [ "--b" , "." , "-w" , "--extendedDiagnostics" ] ,
1361
1235
changes : [
1362
1236
{
0 commit comments