Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update harness to use single robust virtual file system for tests. #20763

Merged
merged 73 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5b4553d
Updated vfs
rbuckton Oct 10, 2017
41aeaae
Cleanup, add watch capabilities
rbuckton Oct 20, 2017
560cffd
Minor cleanup
rbuckton Oct 20, 2017
db6794a
Minor cleanup
rbuckton Oct 20, 2017
8ff9520
Merge branch 'master' into vfs
rbuckton Nov 7, 2017
8a70e17
Cleanup after merge
rbuckton Nov 7, 2017
07bb677
Cache comparers
rbuckton Nov 8, 2017
7d08d74
Merge branch 'master' into vfs
rbuckton Nov 8, 2017
8245f62
Update Harness.compileFiles to use vfs
rbuckton Nov 10, 2017
cf261c3
Retire Harness.compileFiles
rbuckton Nov 10, 2017
4697ba3
Add support for variations in module/target in compiler tests
rbuckton Nov 10, 2017
cd0809e
Deprecate CompilerResult
rbuckton Nov 10, 2017
791c01e
Deprecate GeneratedFile
rbuckton Nov 10, 2017
646c32c
Merge branch 'master' into vfs
rbuckton Nov 11, 2017
4fbc74e
Partial deprecation of non-vfs TestServerHost
rbuckton Nov 13, 2017
3d3977f
Migrate compileOnSave tests to vfs
rbuckton Nov 13, 2017
41567b2
Migrate tscWatchMode to vfs
rbuckton Nov 22, 2017
fa42835
Switch to function spies
rbuckton Nov 23, 2017
c5e5020
Migrate tsserverProjectSystem to vfs
rbuckton Nov 27, 2017
c3701df
Deprecate virtualFileSystemWithWatch
rbuckton Nov 28, 2017
1cb1088
Update projects tests to use vfs
rbuckton Dec 11, 2017
6727499
Re-enable all tests
rbuckton Dec 15, 2017
7944f50
Merge branch 'master' into vfs
rbuckton Dec 18, 2017
279b348
Accept baselines
rbuckton Dec 18, 2017
b4c3bd4
Temporarily revert baselines
rbuckton Dec 19, 2017
e426257
Revert more baselines, add jake task for typemock
rbuckton Dec 19, 2017
d409155
Minor PR feedback
rbuckton Dec 19, 2017
ddb2155
Additional PR feedback and cleanup
rbuckton Dec 19, 2017
ac51fa0
Merge branch 'master' into vfs
rbuckton Dec 20, 2017
c87b725
Work around private packages in Node 6
rbuckton Dec 20, 2017
6b53d38
Fix lint errors
rbuckton Dec 20, 2017
dd054e6
Show diff in baseline failure (temporary)
rbuckton Dec 20, 2017
17281d0
Force case sensitive file names by default in tests, revert dd054e6
rbuckton Dec 20, 2017
fb469e7
Update build for node 6 to allow private package
rbuckton Dec 20, 2017
2646ee2
Update typemock
rbuckton Dec 20, 2017
9c25443
Minor cleanup/comments
rbuckton Dec 21, 2017
ee41557
More consistent POSIX-like virtual file system.
rbuckton Jan 20, 2018
87de5ff
Merge branch 'master' into vfs
rbuckton Jan 22, 2018
774ed0c
Update build script
rbuckton Jan 23, 2018
cda8728
Update build script
rbuckton Jan 23, 2018
7ca84ac
Merge branch 'master' into vfs
rbuckton Jan 29, 2018
9e6cd16
Disable node6 build
rbuckton Jan 29, 2018
f527a15
Disable node6 build
rbuckton Jan 29, 2018
545868c
Merge branch 'vfs' of https://github.com/Microsoft/TypeScript into vfs
rbuckton Jan 29, 2018
d0988b8
PR Feedback
rbuckton Jan 29, 2018
4d8d514
Migrate core.ts
rbuckton Jan 30, 2018
7f4ac29
Clean up build steps
rbuckton Jan 30, 2018
97a842f
Fix ordering in fourslash tests
rbuckton Jan 30, 2018
16cfcc4
Merge branch 'master' into vfs
rbuckton Jan 31, 2018
bb05381
Update new tests from master
rbuckton Jan 31, 2018
3de9630
Merge branch 'master' into vfs
rbuckton Jan 31, 2018
e2bbc3e
Merge branch 'master' into vfs
rbuckton Feb 1, 2018
4eb3b6b
Merge branch 'master' into vfs
rbuckton Feb 5, 2018
0b96348
Revert changes to unit tests
rbuckton Feb 6, 2018
f153b04
Revert changes to unit tests
rbuckton Feb 6, 2018
1efb844
Merge branch 'master' into vfs
rbuckton Feb 6, 2018
ea9f999
Merge branch 'master' into vfs
rbuckton Mar 5, 2018
1cbe930
Merge branch 'master' into vfs
rbuckton Apr 17, 2018
154f09b
Reorganize project structure.
rbuckton Apr 18, 2018
8b86423
Trim unused functionality
rbuckton Apr 18, 2018
1658770
Trim unused functionality
rbuckton Apr 18, 2018
0322d71
Cleanup and reorganize fakes
rbuckton Apr 19, 2018
6b79161
More cleanup and reorganization
rbuckton Apr 19, 2018
370107e
Merge branch 'master' into vfs
rbuckton Apr 19, 2018
e422365
Fix issues with runtests-browser
rbuckton Apr 24, 2018
bb26ab5
Merge branch 'master' into vfs
rbuckton Apr 24, 2018
c9c562a
Reorganize and remove duplication
rbuckton Apr 24, 2018
8424c4d
Partial migration of some shared vpath functionality to core
rbuckton Apr 27, 2018
4863d55
Merge branch 'master' into vfs
rbuckton Apr 27, 2018
1dff0af
More path cleanup
rbuckton Apr 30, 2018
d62a11f
Merge branch 'master' into vfs
rbuckton May 2, 2018
860f9f8
Update documentation comments
rbuckton May 2, 2018
66c11c5
Update completion order in test
rbuckton May 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
}
]
}
50 changes: 25 additions & 25 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ const cmdLineOptions = minimist(process.argv.slice(2), {

const noop = () => {}; // tslint:disable-line no-empty
/**
* @param {string} cmd
* @param {string[]} args
* @param {() => void} complete
* @param {(e: *, status: number) => void} error
* @param {string} cmd
* @param {string[]} args
* @param {() => void} complete
* @param {(e: *, status: number) => void} error
*/
function exec(cmd, args, complete = noop, error = noop) {
console.log(`${cmd} ${args.join(" ")}`);
Expand All @@ -82,7 +82,7 @@ function exec(cmd, args, complete = noop, error = noop) {
}

/**
* @param {string} cmd
* @param {string} cmd
*/
function possiblyQuote(cmd) {
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
Expand Down Expand Up @@ -223,8 +223,8 @@ const packageJson = "package.json";
const versionFile = path.join(compilerDirectory, "core.ts");

/**
* @param {string | string[]} source
* @param {string | string[]} dest
* @param {string | string[]} source
* @param {string | string[]} dest
* @returns {boolean}
*/
function needsUpdate(source, dest) {
Expand Down Expand Up @@ -291,7 +291,7 @@ function needsUpdate(source, dest) {
}

/**
* @param {tsc.Settings} base
* @param {tsc.Settings} base
* @param {boolean=} useBuiltCompiler
* @returns {tsc.Settings}
*/
Expand Down Expand Up @@ -443,7 +443,7 @@ const nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript
/** @type {string} */
let copyrightContent;
/**
* @param {boolean} outputCopyright
* @param {boolean} outputCopyright
*/
function prependCopyright(outputCopyright = !useDebugMode) {
return insert.prepend(outputCopyright ? (copyrightContent || (copyrightContent = fs.readFileSync(copyright).toString())) : "");
Expand Down Expand Up @@ -667,9 +667,9 @@ function restoreSavedNodeEnv() {
}

/**
* @param {string} defaultReporter
* @param {boolean} runInParallel
* @param {(e?: any) => void} done
* @param {string} defaultReporter
* @param {boolean} runInParallel
* @param {(e?: any) => void} done
*/
function runConsoleTests(defaultReporter, runInParallel, done) {
const lintFlag = cmdLineOptions.lint;
Expand Down Expand Up @@ -747,8 +747,8 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
});

/**
* @param {any=} err
* @param {number=} status
* @param {any=} err
* @param {number=} status
*/
function failWithStatus(err, status) {
if (err || status) {
Expand All @@ -767,8 +767,8 @@ function runConsoleTests(defaultReporter, runInParallel, done) {
}

/**
* @param {any=} error
* @param {number=} errorStatus
* @param {any=} error
* @param {number=} errorStatus
*/
function finish(error, errorStatus) {
restoreSavedNodeEnv();
Expand Down Expand Up @@ -801,7 +801,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 Expand Up @@ -886,7 +886,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
});

/**
* @param {(e?: any) => void} done
* @param {(e?: any) => void} done
*/
function cleanTestDirs(done) {
// Clean the local baselines & Rwc baselines directories
Expand All @@ -906,13 +906,13 @@ function cleanTestDirs(done) {

/**
* used to pass data from jake command line directly to run.js
* @param {string} tests
* @param {string} runners
* @param {boolean} light
* @param {string=} taskConfigsFolder
* @param {number=} workerCount
* @param {string=} stackTraceLimit
* @param {number=} timeout
* @param {string} tests
* @param {string} runners
* @param {boolean} light
* @param {string=} taskConfigsFolder
* @param {number=} workerCount
* @param {string=} stackTraceLimit
* @param {number=} timeout
*/
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout) {
const testConfigContents = JSON.stringify({
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 @@ -228,35 +229,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 @@ -293,15 +293,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 @@ -421,7 +421,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 @@ -599,7 +598,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 @@ -608,7 +607,7 @@ file(typesMapOutputPath, function() {
console.log("Parse error in typesMap.json: " + e);
}
fs.writeFileSync(typesMapOutputPath, content);
});
}));
compileFile(
tsserverLibraryFile,
languageServiceLibrarySources,
Expand Down Expand Up @@ -752,7 +751,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 @@ -1229,7 +1228,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