Skip to content

Commit 56648ad

Browse files
authored
Merge pull request #20763 from Microsoft/vfs
Update harness to use single robust virtual file system for tests.
2 parents 24e58c3 + 66c11c5 commit 56648ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5678
-2259
lines changed

.vscode/tasks.json

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
// Available variables which can be used inside of strings.
2-
// ${workspaceRoot}: the root folder of the team
3-
// ${file}: the current opened file
4-
// ${fileBasename}: the current opened file's basename
5-
// ${fileDirname}: the current opened file's dirname
6-
// ${fileExtname}: the current opened file's extension
7-
// ${cwd}: the current working directory of the spawned process
81
{
9-
"version": "0.1.0",
10-
"command": "gulp",
11-
"isShellCommand": true,
12-
"showOutput": "silent",
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
135
"tasks": [
146
{
15-
"taskName": "local",
16-
"isBuildCommand": true,
17-
"showOutput": "silent",
18-
"problemMatcher": [
19-
"$tsc"
20-
]
7+
"type": "shell",
8+
"identifier": "local",
9+
"label": "gulp: local",
10+
"command": "gulp",
11+
"args": ["local"],
12+
"group": { "kind": "build", "isDefault": true },
13+
"problemMatcher": ["$gulp-tsc"]
2114
},
2215
{
23-
"taskName": "tests",
24-
"showOutput": "silent",
25-
"problemMatcher": [
26-
"$tsc"
27-
]
16+
"type": "shell",
17+
"identifier": "tsc",
18+
"label": "gulp: tsc",
19+
"command": "gulp",
20+
"args": ["tsc"],
21+
"group": "build",
22+
"problemMatcher": ["$gulp-tsc"]
23+
},
24+
{
25+
"type": "shell",
26+
"identifier": "tests",
27+
"label": "gulp: tests",
28+
"command": "gulp",
29+
"args": ["tests"],
30+
"group": "build",
31+
"problemMatcher": ["$gulp-tsc"]
2832
}
2933
]
3034
}

Gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ const nodeServerOutFile = "tests/webTestServer.js";
761761
const nodeServerInFile = "tests/webTestServer.ts";
762762
gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
763763
/** @type {tsc.Settings} */
764-
const settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ true);
764+
const settings = getCompilerSettings({ module: "commonjs", target: "es2015" }, /*useBuiltCompiler*/ true);
765765
return gulp.src(nodeServerInFile)
766766
.pipe(newer(nodeServerOutFile))
767767
.pipe(sourcemaps.init())

Jakefile.js

+29-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This file contains the build logic for the public repo
22
// @ts-check
3+
/// <reference types="jake" />
34

45
var fs = require("fs");
56
var os = require("os");
@@ -171,35 +172,34 @@ var compilerFilename = "tsc.js";
171172
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
172173
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
173174

174-
/* Compiles a file from a list of sources
175-
* @param outFile: the target file name
176-
* @param sources: an array of the names of the source files
177-
* @param prereqs: prerequisite tasks to compiling the file
178-
* @param prefixes: a list of files to prepend to the target file
179-
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
180-
* @parap {Object} opts - property bag containing auxiliary options
181-
* @param {boolean} opts.noOutFile: true to compile without using --out
182-
* @param {boolean} opts.generateDeclarations: true to compile using --declaration
183-
* @param {string} opts.outDir: value for '--outDir' command line option
184-
* @param {boolean} opts.keepComments: false to compile using --removeComments
185-
* @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code
186-
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
187-
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
188-
* @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap
189-
* @param {Array} opts.types: array of types to include in compilation
190-
* @param callback: a function to execute after the compilation process ends
191-
*/
175+
/**
176+
* Compiles a file from a list of sources
177+
* @param {string} outFile the target file name
178+
* @param {string[]} sources an array of the names of the source files
179+
* @param {string[]} prereqs prerequisite tasks to compiling the file
180+
* @param {string[]} prefixes a list of files to prepend to the target file
181+
* @param {boolean} useBuiltCompiler true to use the built compiler, false to use the LKG
182+
* @param {object} [opts] property bag containing auxiliary options
183+
* @param {boolean} [opts.noOutFile] true to compile without using --out
184+
* @param {boolean} [opts.generateDeclarations] true to compile using --declaration
185+
* @param {string} [opts.outDir] value for '--outDir' command line option
186+
* @param {boolean} [opts.keepComments] false to compile using --removeComments
187+
* @param {boolean} [opts.preserveConstEnums] true if compiler should keep const enums in code
188+
* @param {boolean} [opts.noResolve] true if compiler should not include non-rooted files in compilation
189+
* @param {boolean} [opts.stripInternal] true if compiler should remove declarations marked as internal
190+
* @param {boolean} [opts.inlineSourceMap] true if compiler should inline sourceMap
191+
* @param {string[]} [opts.types] array of types to include in compilation
192+
* @param {string} [opts.lib] explicit libs to include.
193+
* @param {function(): void} [callback] a function to execute after the compilation process ends
194+
*/
192195
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
193196
file(outFile, prereqs, function() {
194-
if (process.env.USE_TRANSFORMS === "false") {
195-
useBuiltCompiler = false;
196-
}
197197
var startCompileTime = mark();
198198
opts = opts || {};
199199
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
200-
var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError --types ";
200+
var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError";
201201
if (opts.types) {
202-
options += opts.types.join(",");
202+
options += " --types " + opts.types.join(",");
203203
}
204204
options += " --pretty";
205205
// Keep comments when specifically requested
@@ -236,15 +236,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
236236
options += " --inlineSourceMap --inlineSources";
237237
}
238238
else {
239-
options += " -sourcemap";
239+
options += " --sourcemap";
240240
}
241241
}
242242
options += " --newLine LF";
243243

244244
if (opts.stripInternal) {
245245
options += " --stripInternal";
246246
}
247-
options += " --target es5";
247+
options += " --target es5";
248248
if (opts.lib) {
249249
options += " --lib " + opts.lib;
250250
}
@@ -362,7 +362,6 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
362362
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
363363
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
364364
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
365-
var typesMapJson = path.join(builtLocalDirectory, "typesMap.json");
366365

367366
file(buildProtocolTs);
368367

@@ -540,7 +539,7 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js");
540539
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
541540
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
542541
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
543-
file(typesMapOutputPath, function() {
542+
file(typesMapOutputPath, /** @type {*} */(function() {
544543
var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json'));
545544
// Validate that it's valid JSON
546545
try {
@@ -549,7 +548,7 @@ file(typesMapOutputPath, function() {
549548
console.log("Parse error in typesMap.json: " + e);
550549
}
551550
fs.writeFileSync(typesMapOutputPath, content);
552-
});
551+
}));
553552
compileFile(
554553
tsserverLibraryFile,
555554
languageServiceLibrarySources,
@@ -693,7 +692,7 @@ desc("Builds the test infrastructure using the built compiler");
693692
task("tests", ["local", run].concat(libraryTargets));
694693

695694
function exec(cmd, completeHandler, errorHandler) {
696-
var ex = jake.createExec([cmd], { windowsVerbatimArguments: true, interactive: true });
695+
var ex = jake.createExec([cmd], /** @type {jake.ExecOptions} */({ windowsVerbatimArguments: true, interactive: true }));
697696
// Add listeners for output and error
698697
ex.addListener("stdout", function (output) {
699698
process.stdout.write(output);
@@ -1170,7 +1169,7 @@ task("lint", ["build-rules"], () => {
11701169
function lint(project, cb) {
11711170
const cmd = `node node_modules/tslint/bin/tslint --project ${project} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
11721171
console.log("Linting: " + cmd);
1173-
jake.exec([cmd], { interactive: true, windowsVerbatimArguments: true }, cb);
1172+
jake.exec([cmd], cb, /** @type {jake.ExecOptions} */({ interactive: true, windowsVerbatimArguments: true }));
11741173
}
11751174
lint("scripts/tslint/tsconfig.json", () => lint("src/tsconfig-base.json", () => {
11761175
if (fold.isTravis()) console.log(fold.end("lint"));

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/gulp-help": "latest",
4040
"@types/gulp-newer": "latest",
4141
"@types/gulp-sourcemaps": "latest",
42+
"@types/jake": "latest",
4243
"@types/merge2": "latest",
4344
"@types/minimatch": "latest",
4445
"@types/minimist": "latest",
@@ -47,6 +48,7 @@
4748
"@types/node": "8.5.5",
4849
"@types/q": "latest",
4950
"@types/run-sequence": "latest",
51+
"@types/source-map-support": "latest",
5052
"@types/through2": "latest",
5153
"@types/travis-fold": "latest",
5254
"@types/xml2js": "^0.4.0",

src/compiler/commandLineParser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ namespace ts {
18201820
}
18211821

18221822
function getDefaultCompilerOptions(configFileName?: string) {
1823-
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json"
1823+
const options: CompilerOptions = configFileName && getBaseFileName(configFileName) === "jsconfig.json"
18241824
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
18251825
: {};
18261826
return options;
@@ -1835,7 +1835,7 @@ namespace ts {
18351835
}
18361836

18371837
function getDefaultTypeAcquisition(configFileName?: string): TypeAcquisition {
1838-
return { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
1838+
return { enable: configFileName && getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
18391839
}
18401840

18411841
function convertTypeAcquisitionFromJsonWorker(jsonOptions: any,

0 commit comments

Comments
 (0)