Skip to content

Commit

Permalink
Merge pull request #20763 from Microsoft/vfs
Browse files Browse the repository at this point in the history
Update harness to use single robust virtual file system for tests.
  • Loading branch information
rbuckton authored May 3, 2018
2 parents 24e58c3 + 66c11c5 commit 56648ad
Show file tree
Hide file tree
Showing 62 changed files with 5,678 additions and 2,259 deletions.
48 changes: 26 additions & 22 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"showOutput": "silent",
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "local",
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": [
"$tsc"
]
"type": "shell",
"identifier": "local",
"label": "gulp: local",
"command": "gulp",
"args": ["local"],
"group": { "kind": "build", "isDefault": true },
"problemMatcher": ["$gulp-tsc"]
},
{
"taskName": "tests",
"showOutput": "silent",
"problemMatcher": [
"$tsc"
]
"type": "shell",
"identifier": "tsc",
"label": "gulp: tsc",
"command": "gulp",
"args": ["tsc"],
"group": "build",
"problemMatcher": ["$gulp-tsc"]
},
{
"type": "shell",
"identifier": "tests",
"label": "gulp: tests",
"command": "gulp",
"args": ["tests"],
"group": "build",
"problemMatcher": ["$gulp-tsc"]
}
]
}
2 changes: 1 addition & 1 deletion Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ const nodeServerOutFile = "tests/webTestServer.js";
const nodeServerInFile = "tests/webTestServer.ts";
gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
/** @type {tsc.Settings} */
const settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ true);
const settings = getCompilerSettings({ module: "commonjs", target: "es2015" }, /*useBuiltCompiler*/ true);
return gulp.src(nodeServerInFile)
.pipe(newer(nodeServerOutFile))
.pipe(sourcemaps.init())
Expand Down
59 changes: 29 additions & 30 deletions Jakefile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file contains the build logic for the public repo
// @ts-check
/// <reference types="jake" />

var fs = require("fs");
var os = require("os");
Expand Down Expand Up @@ -171,35 +172,34 @@ var compilerFilename = "tsc.js";
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);

/* Compiles a file from a list of sources
* @param outFile: the target file name
* @param sources: an array of the names of the source files
* @param prereqs: prerequisite tasks to compiling the file
* @param prefixes: a list of files to prepend to the target file
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
* @parap {Object} opts - property bag containing auxiliary options
* @param {boolean} opts.noOutFile: true to compile without using --out
* @param {boolean} opts.generateDeclarations: true to compile using --declaration
* @param {string} opts.outDir: value for '--outDir' command line option
* @param {boolean} opts.keepComments: false to compile using --removeComments
* @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
* @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap
* @param {Array} opts.types: array of types to include in compilation
* @param callback: a function to execute after the compilation process ends
*/
/**
* Compiles a file from a list of sources
* @param {string} outFile the target file name
* @param {string[]} sources an array of the names of the source files
* @param {string[]} prereqs prerequisite tasks to compiling the file
* @param {string[]} prefixes a list of files to prepend to the target file
* @param {boolean} useBuiltCompiler true to use the built compiler, false to use the LKG
* @param {object} [opts] property bag containing auxiliary options
* @param {boolean} [opts.noOutFile] true to compile without using --out
* @param {boolean} [opts.generateDeclarations] true to compile using --declaration
* @param {string} [opts.outDir] value for '--outDir' command line option
* @param {boolean} [opts.keepComments] false to compile using --removeComments
* @param {boolean} [opts.preserveConstEnums] true if compiler should keep const enums in code
* @param {boolean} [opts.noResolve] true if compiler should not include non-rooted files in compilation
* @param {boolean} [opts.stripInternal] true if compiler should remove declarations marked as internal
* @param {boolean} [opts.inlineSourceMap] true if compiler should inline sourceMap
* @param {string[]} [opts.types] array of types to include in compilation
* @param {string} [opts.lib] explicit libs to include.
* @param {function(): void} [callback] a function to execute after the compilation process ends
*/
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
file(outFile, prereqs, function() {
if (process.env.USE_TRANSFORMS === "false") {
useBuiltCompiler = false;
}
var startCompileTime = mark();
opts = opts || {};
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError --types ";
var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError";
if (opts.types) {
options += opts.types.join(",");
options += " --types " + opts.types.join(",");
}
options += " --pretty";
// Keep comments when specifically requested
Expand Down Expand Up @@ -236,15 +236,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
options += " --inlineSourceMap --inlineSources";
}
else {
options += " -sourcemap";
options += " --sourcemap";
}
}
options += " --newLine LF";

if (opts.stripInternal) {
options += " --stripInternal";
}
options += " --target es5";
options += " --target es5";
if (opts.lib) {
options += " --lib " + opts.lib;
}
Expand Down Expand Up @@ -362,7 +362,6 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
var typesMapJson = path.join(builtLocalDirectory, "typesMap.json");

file(buildProtocolTs);

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

function exec(cmd, completeHandler, errorHandler) {
var ex = jake.createExec([cmd], { windowsVerbatimArguments: true, interactive: true });
var ex = jake.createExec([cmd], /** @type {jake.ExecOptions} */({ windowsVerbatimArguments: true, interactive: true }));
// Add listeners for output and error
ex.addListener("stdout", function (output) {
process.stdout.write(output);
Expand Down Expand Up @@ -1170,7 +1169,7 @@ task("lint", ["build-rules"], () => {
function lint(project, cb) {
const cmd = `node node_modules/tslint/bin/tslint --project ${project} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
console.log("Linting: " + cmd);
jake.exec([cmd], { interactive: true, windowsVerbatimArguments: true }, cb);
jake.exec([cmd], cb, /** @type {jake.ExecOptions} */({ interactive: true, windowsVerbatimArguments: true }));
}
lint("scripts/tslint/tsconfig.json", () => lint("src/tsconfig-base.json", () => {
if (fold.isTravis()) console.log(fold.end("lint"));
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@types/gulp-help": "latest",
"@types/gulp-newer": "latest",
"@types/gulp-sourcemaps": "latest",
"@types/jake": "latest",
"@types/merge2": "latest",
"@types/minimatch": "latest",
"@types/minimist": "latest",
Expand All @@ -47,6 +48,7 @@
"@types/node": "8.5.5",
"@types/q": "latest",
"@types/run-sequence": "latest",
"@types/source-map-support": "latest",
"@types/through2": "latest",
"@types/travis-fold": "latest",
"@types/xml2js": "^0.4.0",
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ namespace ts {
}

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

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

function convertTypeAcquisitionFromJsonWorker(jsonOptions: any,
Expand Down
Loading

0 comments on commit 56648ad

Please sign in to comment.