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 24 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
scripts/generateLocalizedDiagnosticMessages.js
scripts/*.js.map
scripts/typings/
scripts/typemock/dist
coverage/
internal/
**/.DS_Store
Expand Down
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"]
}
]
}
23 changes: 17 additions & 6 deletions Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,19 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
return runSequence("LKGInternal", "VerifyLKG");
});

gulp.task("typemock", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably add either a jake task that mirror this, or a jake task that shells out to this; otherwise the jake tests task will fail if you have yet to build typemock, no? At least until we remove jake, which is something I, personally, would be happy to entertain again. The team has had, like, 2 years to adopt new habits. 🐱 Hmmm... if outright removing it is too much right now (just because muscle/task memory), then maybe swapping all the jakefile's tasks with ones that shellout to gulp would be appropriate... Gah, that's a topic for another issue. In any case, this typemock-building functionality should probably be accessible via jake in some way.

const typemock = tsc.createProject("scripts/typemock/src/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
return typemock.src()
.pipe(sourcemaps.init())
.pipe(newer("scripts/typemock/dist"))
.pipe(typemock())
.pipe(sourcemaps.write(".", <any>{ includeContent: false, destPath: "scripts/typemock/dist" }))
.pipe(gulp.dest("scripts/typemock/dist"));
});

// Task to build the tests infrastructure using the built compiler
const run = path.join(builtLocalDirectory, "run.js");
gulp.task(run, /*help*/ false, [servicesFile, tsserverLibraryFile], () => {
gulp.task(run, /*help*/ false, [servicesFile, tsserverLibraryFile, "typemock"], () => {
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
return testProject.src()
.pipe(newer(run))
Expand Down Expand Up @@ -650,7 +659,7 @@ function restoreSavedNodeEnv() {
process.env.NODE_ENV = savedNodeEnv;
}

function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void, noExit?: boolean) {
const lintFlag = cmdLineOptions.lint;
cleanTestDirs((err) => {
if (err) { console.error(err); failWithStatus(err, 1); }
Expand Down Expand Up @@ -726,8 +735,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
});

function failWithStatus(err?: any, status?: number) {
if (err || status) {
process.exit(typeof status === "number" ? status : 2);
if (!noExit) {
if (err || status) {
process.exit(typeof status === "number" ? status : 2);
}
}
done();
}
Expand Down Expand Up @@ -1114,5 +1125,5 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
gulp.task("default", "Runs 'local'", ["local"]);

gulp.task("watch", "Watches the src/ directory for changes and executes runtests-parallel.", [], () => {
gulp.watch("src/**/*.*", ["runtests-parallel"]);
});
gulp.watch(["src/**/*.*", "scripts/typemock/src/**/*.*"], ["runtests-parallel"]);
});
81 changes: 1 addition & 80 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,86 +91,7 @@ var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "

var typesMapOutputPath = path.join(builtLocalDirectory, 'typesMap.json');

var harnessCoreSources = [
"harness.ts",
"virtualFileSystem.ts",
"virtualFileSystemWithWatch.ts",
"sourceMapRecorder.ts",
"harnessLanguageService.ts",
"fourslash.ts",
"runnerbase.ts",
"compilerRunner.ts",
"typeWriter.ts",
"fourslashRunner.ts",
"projectsRunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
"externalCompileRunner.ts",
"test262Runner.ts",
"./parallel/shared.ts",
"./parallel/host.ts",
"./parallel/worker.ts",
"runner.ts"
].map(function (f) {
return path.join(harnessDirectory, f);
});

var harnessSources = harnessCoreSources.concat([
"incrementalParser.ts",
"jsDocParsing.ts",
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts",
"services/patternMatcher.ts",
"session.ts",
"versionCache.ts",
"convertToBase64.ts",
"transpile.ts",
"reuseProgramStructure.ts",
"textStorage.ts",
"moduleResolution.ts",
"tsconfigParsing.ts",
"asserts.ts",
"builder.ts",
"commandLineParsing.ts",
"configurationExtension.ts",
"convertCompilerOptionsFromJson.ts",
"convertTypeAcquisitionFromJson.ts",
"tsserverProjectSystem.ts",
"tscWatchMode.ts",
"compileOnSave.ts",
"typingsInstaller.ts",
"projectErrors.ts",
"matchFiles.ts",
"initializeTSConfig.ts",
"extractConstants.ts",
"extractFunctions.ts",
"extractRanges.ts",
"extractTestHelpers.ts",
"printer.ts",
"textChanges.ts",
"telemetry.ts",
"transform.ts",
"customTransforms.ts",
"programMissingFiles.ts",
"symbolWalker.ts",
"languageService.ts",
"publicApi.ts",
"hostNewLineSupport.ts",
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
"protocol.ts",
"utilities.ts",
"scriptVersionCache.ts",
"scriptInfo.ts",
"project.ts",
"typingsCache.ts",
"editorServices.ts",
"session.ts",
].map(function (f) {
return path.join(serverDirectory, f);
}));
var harnessSources = filesFromConfig("./src/harness/tsconfig.json");

var es2015LibrarySources = [
"es2015.core.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@types/node": "latest",
"@types/q": "latest",
"@types/run-sequence": "latest",
"@types/source-map-support": "^0.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pinned while we generally use latest if possible - is there a reason it must be pinned?

"@types/through2": "latest",
"@types/xml2js": "^0.4.0",
"xml2js": "^0.4.19",
Expand Down Expand Up @@ -78,6 +79,7 @@
"travis-fold": "latest",
"ts-node": "latest",
"tslint": "latest",
"typemock": "file:scripts/typemock",
"vinyl": "latest",
"chalk": "latest",
"typescript": "next"
Expand Down
28 changes: 28 additions & 0 deletions scripts/typemock/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const gulp = require("gulp");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth considering making this a Gulpfile.ts just like our root one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not change the extension. TypeMock was originally a garage/hackathon project I put together a few years back and eventually I'd like to see about publishing it as a standalone package. Since the gulpfile is so simple I don't think its worth adding the ts-node dependency and overhead to support a .ts extension.

const gutil = require("gulp-util");
const sourcemaps = require("gulp-sourcemaps");
const tsb = require("gulp-tsb");
const mocha = require("gulp-mocha");
const del = require("del");

const src = {
compile: tsb.create("src/tsconfig.json"),
src: () => gulp.src(["src/**/*.ts"]),
dest: () => gulp.dest("dist")
};

gulp.task("clean", () => del(["dist/**/*"]));

gulp.task("build", () => src.src()
.pipe(sourcemaps.init())
.pipe(src.compile())
.pipe(sourcemaps.write(".", { includeContent: false, destPath: "dist" }))
.pipe(gulp.dest("dist")));

gulp.task("test", ["build"], () => gulp
.src(["dist/tests/index.js"], { read: false })
.pipe(mocha({ reporter: "dot" })));

gulp.task("watch", () => gulp.watch(["src/**/*"], ["test"]));

gulp.task("default", ["test"]);
35 changes: 35 additions & 0 deletions scripts/typemock/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"private": true,
"name": "typemock",
"version": "0.0.0",
"description": "JavaScript Mock object framework",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "gulp test"
},
"keywords": [
"javascript",
"mock",
"type",
"typescript"
],
"author": "Ron Buckton (ron.buckton@microsoft.com)",
"license": "Apache-2.0",
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/mocha": "^2.2.27",
"@types/node": "^8.0.20",
"@types/source-map-support": "^0.4.0",
"chai": "^4.1.2",
"del": "^2.0.2",
"gulp": "^3.9.1",
"gulp-mocha": "^4.3.1",
"gulp-sourcemaps": "^2.6.1",
"gulp-tsb": "^2.0.5",
"merge2": "^0.3.6",
"mocha": "^2.2.5",
"source-map-support": "^0.5.0",
"typescript": "^2.6.1"
}
}
Loading