Skip to content

Commit 08ca1c0

Browse files
committed
Merge branch 'master' into glob2_merged
2 parents 0415b95 + f9923ef commit 08ca1c0

653 files changed

Lines changed: 290158 additions & 274306 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ tests/webhost/*.d.ts
3434
tests/webhost/webtsc.js
3535
tests/cases/**/*.js
3636
tests/cases/**/*.js.map
37-
tests/cases/**/*.d.ts
3837
*.config
3938
scripts/debug.bat
4039
scripts/run.bat
@@ -49,3 +48,4 @@ internal/
4948
**/.vs
5049
**/.vscode
5150
!**/.vscode/tasks.json
51+
!tests/cases/projects/projectOption/**/node_modules

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ These two files represent the DOM typings and are auto-generated. To make any mo
9191

9292
## Running the Tests
9393

94-
To run all tests, invoke the `runtests` target using jake:
94+
To run all tests, invoke the `runtests-parallel` target using jake:
9595

9696
```Shell
97-
jake runtests
97+
jake runtests-parallel
9898
```
9999

100100
This run will all tests; to run only a specific subset of tests, use:

Jakefile.js

Lines changed: 119 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var os = require("os");
55
var path = require("path");
66
var child_process = require("child_process");
77
var Linter = require("tslint");
8+
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
89

910
// Variables
1011
var compilerDirectory = "src/compiler/";
@@ -155,6 +156,7 @@ var harnessSources = harnessCoreSources.concat([
155156
"commandLineParsing.ts",
156157
"convertCompilerOptionsFromJson.ts",
157158
"convertTypingOptionsFromJson.ts",
159+
"tsserverProjectSystem.ts",
158160
"matchFiles.ts"
159161
].map(function (f) {
160162
return path.join(unittestsDirectory, f);
@@ -189,7 +191,10 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
189191
return { target: "lib." + source, sources: ["header.d.ts", source] };
190192
});
191193

192-
var es2017LibrarySource = ["es2017.object.d.ts"];
194+
var es2017LibrarySource = [
195+
"es2017.object.d.ts",
196+
"es2017.sharedmemory.d.ts"
197+
];
193198

194199
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
195200
return { target: "lib." + source, sources: ["header.d.ts", source] };
@@ -209,7 +214,7 @@ var librarySourceMap = [
209214
{ target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] },
210215
{ target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] },
211216
{ target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] },
212-
217+
213218
// JavaScript + all host library
214219
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) },
215220
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") }
@@ -273,6 +278,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
273278
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
274279
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
275280
* @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option
281+
* @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap
276282
* @param callback: a function to execute after the compilation process ends
277283
*/
278284
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
@@ -310,10 +316,16 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
310316
}
311317

312318
if (useDebugMode) {
313-
options += " -sourcemap";
314-
if (!opts.noMapRoot) {
315-
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
319+
if (opts.inlineSourceMap) {
320+
options += " --inlineSourceMap --inlineSources";
321+
} else {
322+
options += " -sourcemap";
323+
if (!opts.noMapRoot) {
324+
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
325+
}
316326
}
327+
} else {
328+
options += " --newLine LF";
317329
}
318330

319331
if (opts.stripInternal) {
@@ -490,7 +502,13 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
490502
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
491503
/*prefixes*/ [copyright],
492504
/*useBuiltCompiler*/ true,
493-
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true },
505+
/*opts*/ { noOutFile: false,
506+
generateDeclarations: true,
507+
preserveConstEnums: true,
508+
keepComments: true,
509+
noResolve: false,
510+
stripInternal: true
511+
},
494512
/*callback*/ function () {
495513
jake.cpR(servicesFile, nodePackageFile, {silent: true});
496514

@@ -513,16 +531,21 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
513531
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
514532
});
515533

516-
compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
517-
/*prefixes*/ [copyright],
518-
/*useBuiltCompiler*/ true,
519-
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true, noMapRoot: true },
520-
/*callback*/ function () {
521-
var content = fs.readFileSync(servicesFileInBrowserTest).toString();
522-
var i = content.lastIndexOf("\n");
523-
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
524-
});
525-
534+
compileFile(
535+
servicesFileInBrowserTest,
536+
servicesSources,
537+
[builtLocalDirectory, copyright].concat(servicesSources),
538+
/*prefixes*/ [copyright],
539+
/*useBuiltCompiler*/ true,
540+
{ noOutFile: false,
541+
generateDeclarations: true,
542+
preserveConstEnums: true,
543+
keepComments: true,
544+
noResolve: false,
545+
stripInternal: true,
546+
noMapRoot: true,
547+
inlineSourceMap: true
548+
});
526549

527550
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
528551
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
@@ -623,7 +646,13 @@ directory(builtLocalDirectory);
623646

624647
// Task to build the tests infrastructure using the built compiler
625648
var run = path.join(builtLocalDirectory, "run.js");
626-
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
649+
compileFile(
650+
/*outFile*/ run,
651+
/*source*/ harnessSources,
652+
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
653+
/*prefixes*/ [],
654+
/*useBuiltCompiler:*/ true,
655+
/*opts*/ { inlineSourceMap: true });
627656

628657
var internalTests = "internal/";
629658

@@ -682,9 +711,8 @@ function cleanTestDirs() {
682711
}
683712

684713
// used to pass data from jake command line directly to run.js
685-
function writeTestConfigFile(tests, light, testConfigFile) {
686-
console.log('Running test(s): ' + tests);
687-
var testConfigContents = JSON.stringify({ test: [tests], light: light });
714+
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount) {
715+
var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder });
688716
fs.writeFileSync('test.config', testConfigContents);
689717
}
690718

@@ -694,7 +722,7 @@ function deleteTemporaryProjectOutput() {
694722
}
695723
}
696724

697-
function runConsoleTests(defaultReporter, defaultSubsets) {
725+
function runConsoleTests(defaultReporter, runInParallel) {
698726
cleanTestDirs();
699727
var debug = process.env.debug || process.env.d;
700728
tests = process.env.test || process.env.tests || process.env.t;
@@ -703,9 +731,22 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
703731
if(fs.existsSync(testConfigFile)) {
704732
fs.unlinkSync(testConfigFile);
705733
}
734+
var workerCount, taskConfigsFolder;
735+
if (runInParallel) {
736+
// generate name to store task configuration files
737+
var prefix = os.tmpdir() + "/ts-tests";
738+
var i = 1;
739+
do {
740+
taskConfigsFolder = prefix + i;
741+
i++;
742+
} while (fs.existsSync(taskConfigsFolder));
743+
fs.mkdirSync(taskConfigsFolder);
744+
745+
workerCount = process.env.workerCount || os.cpus().length;
746+
}
706747

707-
if (tests || light) {
708-
writeTestConfigFile(tests, light, testConfigFile);
748+
if (tests || light || taskConfigsFolder) {
749+
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount);
709750
}
710751

711752
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -719,61 +760,76 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
719760

720761
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
721762
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
722-
var subsetRegexes;
723-
if(defaultSubsets.length === 0) {
724-
subsetRegexes = [tests];
725-
}
726-
else {
727-
var subsets = tests ? tests.split("|") : defaultSubsets;
728-
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
729-
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
730-
}
731-
var counter = subsetRegexes.length;
732-
var errorStatus;
733-
subsetRegexes.forEach(function (subsetRegex, i) {
734-
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
763+
if(!runInParallel) {
764+
tests = tests ? ' -g "' + tests + '"' : '';
735765
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
736766
console.log(cmd);
737-
function finish(status) {
738-
counter--;
739-
// save first error status
740-
if (status !== undefined && errorStatus === undefined) {
741-
errorStatus = status;
742-
}
743767

768+
var savedNodeEnv = process.env.NODE_ENV;
769+
process.env.NODE_ENV = "development";
770+
exec(cmd, function () {
771+
process.env.NODE_ENV = savedNodeEnv;
772+
runLinter();
773+
finish();
774+
}, function(e, status) {
775+
process.env.NODE_ENV = savedNodeEnv;
776+
finish(status);
777+
});
778+
779+
}
780+
else {
781+
var savedNodeEnv = process.env.NODE_ENV;
782+
process.env.NODE_ENV = "development";
783+
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
784+
process.env.NODE_ENV = savedNodeEnv;
785+
786+
// last worker clean everything and runs linter in case if there were no errors
744787
deleteTemporaryProjectOutput();
745-
if (counter !== 0 || errorStatus === undefined) {
746-
// run linter when last worker is finished
747-
if (lintFlag && counter === 0) {
748-
var lint = jake.Task['lint'];
749-
lint.addListener('complete', function () {
750-
complete();
751-
});
752-
lint.invoke();
753-
}
754-
complete();
788+
jake.rmRf(taskConfigsFolder);
789+
if (err) {
790+
fail(err);
755791
}
756792
else {
757-
fail("Process exited with code " + status);
793+
runLinter();
794+
complete();
758795
}
796+
});
797+
}
798+
799+
function failWithStatus(status) {
800+
fail("Process exited with code " + status);
801+
}
802+
803+
function finish(errorStatus) {
804+
deleteTemporaryProjectOutput();
805+
if (errorStatus !== undefined) {
806+
failWithStatus(errorStatus);
759807
}
760-
exec(cmd, function () {
761-
finish();
762-
}, function(e, status) {
763-
finish(status);
808+
else {
809+
complete();
810+
}
811+
}
812+
function runLinter() {
813+
if (!lintFlag) {
814+
return;
815+
}
816+
var lint = jake.Task['lint'];
817+
lint.addListener('complete', function () {
818+
complete();
764819
});
765-
});
820+
lint.invoke();
821+
}
766822
}
767823

768824
var testTimeout = 20000;
769825
desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true.");
770826
task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() {
771-
runConsoleTests('min', ['compiler', 'conformance', 'Projects', 'fourslash']);
827+
runConsoleTests('min', /*runInParallel*/ true);
772828
}, {async: true});
773829

774830
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true.");
775831
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
776-
runConsoleTests('mocha-fivemat-progress-reporter', []);
832+
runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false);
777833
}, {async: true});
778834

779835
desc("Generates code coverage data via instanbul");
@@ -790,7 +846,7 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
790846

791847
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
792848
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
793-
var cmd = 'browserify built/local/run.js -o built/local/bundle.js';
849+
var cmd = 'browserify built/local/run.js -d -o built/local/bundle.js';
794850
exec(cmd);
795851
}, {async: true});
796852

@@ -807,11 +863,11 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
807863
fs.unlinkSync(testConfigFile);
808864
}
809865
if(tests || light) {
810-
writeTestConfigFile(tests, light, testConfigFile);
866+
writeTestConfigFile(tests, light);
811867
}
812868

813869
tests = tests ? tests : '';
814-
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests;
870+
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON.stringify(tests);
815871
console.log(cmd);
816872
exec(cmd);
817873
}, {async: true});

lib/lib.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,24 @@ interface ObjectConstructor {
152152
*/
153153
getOwnPropertyNames(o: any): string[];
154154

155+
/**
156+
* Creates an object that has null prototype.
157+
* @param o Object to use as a prototype. May be null
158+
*/
159+
create(o: null): any;
160+
161+
/**
162+
* Creates an object that has the specified prototype, and that optionally contains specified properties.
163+
* @param o Object to use as a prototype. May be null
164+
*/
165+
create<T>(o: T): T;
166+
155167
/**
156168
* Creates an object that has the specified prototype, and that optionally contains specified properties.
157169
* @param o Object to use as a prototype. May be null
158170
* @param properties JavaScript object that contains one or more property descriptors.
159171
*/
160-
create(o: any, properties?: PropertyDescriptorMap): any;
172+
create(o: any, properties: PropertyDescriptorMap): any;
161173

162174
/**
163175
* Adds a property to an object, or modifies attributes of an existing property.

lib/lib.es2017.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ and limitations under the License.
1515

1616
/// <reference no-default-lib="true"/>
1717
/// <reference path="lib.es2016.d.ts" />
18-
/// <reference path="lib.es2017.object.d.ts" />
18+
/// <reference path="lib.es2017.object.d.ts" />
19+
/// <reference path="lib.es2017.sharedmemory.d.ts" />

0 commit comments

Comments
 (0)