Skip to content

Commit 9907453

Browse files
Merge branch 'master' into correctlyCacheTaggedTemplates
2 parents 5565709 + b670b97 commit 9907453

File tree

819 files changed

+52953
-5026
lines changed

Some content is hidden

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

819 files changed

+52953
-5026
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ internal/
5959
.idea
6060
yarn.lock
6161
package-lock.json
62+
.parallelperf.json

Gulpfile.ts

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import merge2 = require("merge2");
3131
import * as os from "os";
3232
import fold = require("travis-fold");
3333
const gulp = helpMaker(originalGulp);
34-
const mochaParallel = require("./scripts/mocha-parallel.js");
35-
const {runTestsInParallel} = mochaParallel;
3634

3735
Error.stackTraceLimit = 1000;
3836

@@ -668,36 +666,18 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
668666
}
669667
else {
670668
// run task to load all tests and partition them between workers
671-
const args = [];
672-
args.push("-R", "min");
673-
if (colors) {
674-
args.push("--colors");
675-
}
676-
else {
677-
args.push("--no-colors");
678-
}
679-
args.push(run);
680669
setNodeEnvToDevelopment();
681-
runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) {
682-
// last worker clean everything and runs linter in case if there were no errors
683-
del(taskConfigsFolder).then(() => {
684-
if (!err) {
685-
lintThenFinish();
686-
}
687-
else {
688-
finish(err);
689-
}
690-
});
670+
exec(host, [run], lintThenFinish, function(e, status) {
671+
finish(e, status);
691672
});
692673
}
693674
});
694675

695676
function failWithStatus(err?: any, status?: number) {
696-
if (err) {
697-
console.log(err);
677+
if (err || status) {
678+
process.exit(typeof status === "number" ? status : 2);
698679
}
699-
done(err || status);
700-
process.exit(status);
680+
done();
701681
}
702682

703683
function lintThenFinish() {
@@ -711,7 +691,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
711691

712692
function finish(error?: any, errorStatus?: number) {
713693
restoreSavedNodeEnv();
714-
deleteTemporaryProjectOutput().then(() => {
694+
deleteTestConfig().then(deleteTemporaryProjectOutput).then(() => {
715695
if (error !== undefined || errorStatus !== undefined) {
716696
failWithStatus(error, errorStatus);
717697
}
@@ -720,6 +700,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
720700
}
721701
});
722702
}
703+
704+
function deleteTestConfig() {
705+
return del("test.config");
706+
}
723707
}
724708

725709
gulp.task("runtests-parallel", "Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.", ["build-rules", "tests"], (done) => {
@@ -836,7 +820,7 @@ function cleanTestDirs(done: (e?: any) => void) {
836820

837821
// used to pass data from jake command line directly to run.js
838822
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
839-
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder });
823+
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions["colors"] });
840824
console.log("Running tests with config: " + testConfigContents);
841825
fs.writeFileSync("test.config", testConfigContents);
842826
}
@@ -1066,10 +1050,11 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
10661050
const fileMatcher = cmdLineOptions["files"];
10671051
const files = fileMatcher
10681052
? `src/**/${fileMatcher}`
1069-
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1070-
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
1053+
: "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1054+
const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
10711055
console.log("Linting: " + cmd);
10721056
child_process.execSync(cmd, { stdio: [0, 1, 2] });
1057+
if (fold.isTravis()) console.log(fold.end("lint"));
10731058
});
10741059

10751060
gulp.task("default", "Runs 'local'", ["local"]);

Jakefile.js

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// This file contains the build logic for the public repo
2+
// @ts-check
23

34
var fs = require("fs");
45
var os = require("os");
56
var path = require("path");
67
var child_process = require("child_process");
78
var fold = require("travis-fold");
8-
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
99
var ts = require("./lib/typescript");
1010

1111

@@ -38,7 +38,7 @@ else if (process.env.PATH !== undefined) {
3838

3939
function filesFromConfig(configPath) {
4040
var configText = fs.readFileSync(configPath).toString();
41-
var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true);
41+
var config = ts.parseConfigFileTextToJson(configPath, configText);
4242
if (config.error) {
4343
throw new Error(diagnosticsToString([config.error]));
4444
}
@@ -104,6 +104,9 @@ var harnessCoreSources = [
104104
"loggedIO.ts",
105105
"rwcRunner.ts",
106106
"test262Runner.ts",
107+
"./parallel/shared.ts",
108+
"./parallel/host.ts",
109+
"./parallel/worker.ts",
107110
"runner.ts"
108111
].map(function (f) {
109112
return path.join(harnessDirectory, f);
@@ -143,6 +146,7 @@ var harnessSources = harnessCoreSources.concat([
143146
"customTransforms.ts",
144147
"programMissingFiles.ts",
145148
"symbolWalker.ts",
149+
"languageService.ts",
146150
].map(function (f) {
147151
return path.join(unittestsDirectory, f);
148152
})).concat([
@@ -595,7 +599,7 @@ file(typesMapOutputPath, function() {
595599
var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json'));
596600
// Validate that it's valid JSON
597601
try {
598-
JSON.parse(content);
602+
JSON.parse(content.toString());
599603
} catch (e) {
600604
console.log("Parse error in typesMap.json: " + e);
601605
}
@@ -739,7 +743,7 @@ desc("Builds the test infrastructure using the built compiler");
739743
task("tests", ["local", run].concat(libraryTargets));
740744

741745
function exec(cmd, completeHandler, errorHandler) {
742-
var ex = jake.createExec([cmd], { windowsVerbatimArguments: true });
746+
var ex = jake.createExec([cmd], { windowsVerbatimArguments: true, interactive: true });
743747
// Add listeners for output and error
744748
ex.addListener("stdout", function (output) {
745749
process.stdout.write(output);
@@ -765,15 +769,16 @@ function exec(cmd, completeHandler, errorHandler) {
765769
ex.run();
766770
}
767771

772+
const del = require("del");
768773
function cleanTestDirs() {
769774
// Clean the local baselines directory
770775
if (fs.existsSync(localBaseline)) {
771-
jake.rmRf(localBaseline);
776+
del.sync(localBaseline);
772777
}
773778

774779
// Clean the local Rwc baselines directory
775780
if (fs.existsSync(localRwcBaseline)) {
776-
jake.rmRf(localRwcBaseline);
781+
del.sync(localRwcBaseline);
777782
}
778783

779784
jake.mkdirP(localRwcBaseline);
@@ -782,13 +787,14 @@ function cleanTestDirs() {
782787
}
783788

784789
// used to pass data from jake command line directly to run.js
785-
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit) {
790+
function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) {
786791
var testConfigContents = JSON.stringify({
787792
test: tests ? [tests] : undefined,
788793
light: light,
789794
workerCount: workerCount,
790795
taskConfigsFolder: taskConfigsFolder,
791-
stackTraceLimit: stackTraceLimit
796+
stackTraceLimit: stackTraceLimit,
797+
noColor: !colors
792798
});
793799
fs.writeFileSync('test.config', testConfigContents);
794800
}
@@ -830,7 +836,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
830836
}
831837

832838
if (tests || light || taskConfigsFolder) {
833-
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit);
839+
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors);
834840
}
835841

836842
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -893,19 +899,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
893899
var savedNodeEnv = process.env.NODE_ENV;
894900
process.env.NODE_ENV = "development";
895901
var startTime = mark();
896-
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: !colors }, function (err) {
902+
exec(host + " " + run, function () {
897903
process.env.NODE_ENV = savedNodeEnv;
898904
measure(startTime);
899-
// last worker clean everything and runs linter in case if there were no errors
900-
deleteTemporaryProjectOutput();
901-
jake.rmRf(taskConfigsFolder);
902-
if (err) {
903-
fail(err);
904-
}
905-
else {
906-
runLinter();
907-
complete();
908-
}
905+
runLinter();
906+
finish();
907+
}, function (e, status) {
908+
process.env.NODE_ENV = savedNodeEnv;
909+
measure(startTime);
910+
finish(status);
909911
});
910912
}
911913

@@ -968,8 +970,8 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is
968970
task("runtests-browser", ["browserify", nodeServerOutFile], function () {
969971
cleanTestDirs();
970972
host = "node";
971-
browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
972-
tests = process.env.test || process.env.tests || process.env.t;
973+
var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
974+
var tests = process.env.test || process.env.tests || process.env.t;
973975
var light = process.env.light || false;
974976
var testConfigFile = 'test.config';
975977
if (fs.existsSync(testConfigFile)) {
@@ -1041,6 +1043,7 @@ function acceptBaseline(sourceFolder, targetFolder) {
10411043
if (fs.existsSync(target)) {
10421044
fs.unlinkSync(target);
10431045
}
1046+
jake.mkdirP(path.dirname(target));
10441047
fs.renameSync(path.join(sourceFolder, filename), target);
10451048
}
10461049
}
@@ -1118,7 +1121,7 @@ task("update-sublime", ["local", serverFile], function () {
11181121
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
11191122
});
11201123

1121-
var tslintRuleDir = "scripts/tslint";
1124+
var tslintRuleDir = "scripts/tslint/rules";
11221125
var tslintRules = [
11231126
"booleanTriviaRule",
11241127
"debugAssertRule",
@@ -1134,13 +1137,27 @@ var tslintRulesFiles = tslintRules.map(function (p) {
11341137
return path.join(tslintRuleDir, p + ".ts");
11351138
});
11361139
var tslintRulesOutFiles = tslintRules.map(function (p) {
1137-
return path.join(builtLocalDirectory, "tslint", p + ".js");
1140+
return path.join(builtLocalDirectory, "tslint/rules", p + ".js");
1141+
});
1142+
var tslintFormattersDir = "scripts/tslint/formatters";
1143+
var tslintFormatters = [
1144+
"autolinkableStylishFormatter",
1145+
];
1146+
var tslintFormatterFiles = tslintFormatters.map(function (p) {
1147+
return path.join(tslintFormattersDir, p + ".ts");
1148+
});
1149+
var tslintFormattersOutFiles = tslintFormatters.map(function (p) {
1150+
return path.join(builtLocalDirectory, "tslint/formatters", p + ".js");
11381151
});
11391152
desc("Compiles tslint rules to js");
1140-
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
1153+
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(tslintFormattersOutFiles).concat(["build-rules-end"]));
11411154
tslintRulesFiles.forEach(function (ruleFile, i) {
11421155
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1143-
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
1156+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/rules"), lib: "es6" });
1157+
});
1158+
tslintFormatterFiles.forEach(function (ruleFile, i) {
1159+
compileFile(tslintFormattersOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1160+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/formatters"), lib: "es6" });
11441161
});
11451162

11461163
desc("Emit the start of the build-rules fold");
@@ -1208,8 +1225,8 @@ task("lint", ["build-rules"], () => {
12081225
const fileMatcher = process.env.f || process.env.file || process.env.files;
12091226
const files = fileMatcher
12101227
? `src/**/${fileMatcher}`
1211-
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1212-
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
1228+
: "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1229+
const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
12131230
console.log("Linting: " + cmd);
12141231
jake.exec([cmd], { interactive: true }, () => {
12151232
if (fold.isTravis()) console.log(fold.end("lint"));

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
For the latest stable version:
1414

15-
```
15+
```bash
1616
npm install -g typescript
1717
```
1818

1919
For our nightly builds:
2020

21-
```
21+
```bash
2222
npm install -g typescript@next
2323
```
2424

@@ -50,19 +50,19 @@ In order to build the TypeScript compiler, ensure that you have [Git](https://gi
5050

5151
Clone a copy of the repo:
5252

53-
```
53+
```bash
5454
git clone https://github.com/Microsoft/TypeScript.git
5555
```
5656

5757
Change to the TypeScript directory:
5858

59-
```
59+
```bash
6060
cd TypeScript
6161
```
6262

6363
Install Gulp tools and dev dependencies:
6464

65-
```
65+
```bash
6666
npm install -g gulp
6767
npm install
6868
```
@@ -88,7 +88,7 @@ gulp help # List the above commands.
8888

8989
## Usage
9090

91-
```shell
91+
```bash
9292
node built/local/tsc.js hello.ts
9393
```
9494

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"devDependencies": {
3232
"@types/browserify": "latest",
3333
"@types/chai": "latest",
34+
"@types/colors": "latest",
3435
"@types/convert-source-map": "latest",
3536
"@types/del": "latest",
3637
"@types/glob": "latest",
@@ -48,8 +49,8 @@
4849
"@types/q": "latest",
4950
"@types/run-sequence": "latest",
5051
"@types/through2": "latest",
51-
"browserify": "latest",
5252
"browser-resolve": "^1.11.2",
53+
"browserify": "latest",
5354
"chai": "latest",
5455
"convert-source-map": "latest",
5556
"del": "latest",
@@ -75,6 +76,7 @@
7576
"travis-fold": "latest",
7677
"ts-node": "latest",
7778
"tslint": "latest",
79+
"colors": "latest",
7880
"typescript": "next"
7981
},
8082
"scripts": {

scripts/bisect-test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/// <reference path="..\src\harness\external\node.d.ts" />
2-
1+
/**
2+
* You should have ts-node installed globally before executing this, probably!
3+
* Otherwise you'll need to compile this script before you start bisecting!
4+
*/
35
import cp = require('child_process');
46
import fs = require('fs');
57

@@ -42,8 +44,8 @@ jake.on('close', jakeExitCode => {
4244
});
4345
} else {
4446
console.log('Unknown command line arguments.');
45-
console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles');
46-
console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"');
47+
console.log('Usage (compile errors): git bisect run ts-node scripts\bisect-test.ts "../failure.ts --module amd" !compiles');
48+
console.log('Usage (emit check): git bisect run ts-node scripts\bisect-test.ts bar.ts emits bar.js "_this = this"');
4749
// Aborts the 'git bisect run' process
4850
process.exit(-1);
4951
}

0 commit comments

Comments
 (0)