Skip to content

Commit 3de8c22

Browse files
author
Andy Hanson
committed
Merge branch 'master' into no_ts_extension
2 parents 359c8b1 + 78cea2a commit 3de8c22

File tree

205 files changed

+5525
-840
lines changed

Some content is hidden

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

205 files changed

+5525
-840
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ node_js:
77

88
sudo: false
99

10+
env:
11+
- workerCount=3
12+
1013
matrix:
1114
fast_finish: true
1215
include:
1316
- os: osx
1417
node_js: stable
1518
osx_image: xcode7.3
19+
env: workerCount=2
20+
allow_failures:
21+
- os: osx
1622

1723
branches:
1824
only:
@@ -28,3 +34,6 @@ install:
2834
cache:
2935
directories:
3036
- node_modules
37+
38+
git:
39+
depth: 1

Gulpfile.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import merge2 = require("merge2");
3535
import intoStream = require("into-stream");
3636
import * as os from "os";
3737
import Linter = require("tslint");
38+
import fold = require("travis-fold");
3839
const gulp = helpMaker(originalGulp);
3940
const mochaParallel = require("./scripts/mocha-parallel.js");
4041
const {runTestsInParallel} = mochaParallel;
@@ -449,7 +450,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
449450
});
450451

451452
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
452-
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
453+
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
453454
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
454455

455456

@@ -503,7 +504,7 @@ gulp.task("VerifyLKG", false, [], () => {
503504
return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory));
504505
});
505506

506-
gulp.task("LKGInternal", false, ["lib", "local", "lssl"]);
507+
gulp.task("LKGInternal", false, ["lib", "local"]);
507508

508509
gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => {
509510
return runSequence("LKGInternal", "VerifyLKG");
@@ -964,6 +965,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
964965
const fileMatcher = RegExp(cmdLineOptions["files"]);
965966
const lintOptions = getLinterOptions();
966967
let failed = 0;
968+
if (fold.isTravis()) console.log(fold.start("lint"));
967969
return gulp.src(lintTargets)
968970
.pipe(insert.transform((contents, file) => {
969971
if (!fileMatcher.test(file.path)) return contents;
@@ -975,6 +977,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
975977
return contents; // TODO (weswig): Automatically apply fixes? :3
976978
}))
977979
.on("end", () => {
980+
if (fold.isTravis()) console.log(fold.end("lint"));
978981
if (failed > 0) {
979982
console.error("Linter errors.");
980983
process.exit(1);

Jakefile.js

Lines changed: 59 additions & 5 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 fold = require("travis-fold");
89
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
910

1011
// Variables
@@ -32,6 +33,28 @@ if (process.env.path !== undefined) {
3233
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3334
}
3435

36+
function toNs(diff) {
37+
return diff[0] * 1e9 + diff[1];
38+
}
39+
40+
function mark() {
41+
if (!fold.isTravis()) return;
42+
var stamp = process.hrtime();
43+
var id = Math.floor(Math.random() * 0xFFFFFFFF).toString(16);
44+
console.log("travis_time:start:" + id + "\r");
45+
return {
46+
stamp: stamp,
47+
id: id
48+
};
49+
}
50+
51+
function measure(marker) {
52+
if (!fold.isTravis()) return;
53+
var diff = process.hrtime(marker.stamp);
54+
var total = [marker.stamp[0] + diff[0], marker.stamp[1] + diff[1]];
55+
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
56+
}
57+
3558
var compilerSources = [
3659
"core.ts",
3760
"performance.ts",
@@ -285,6 +308,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
285308
*/
286309
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
287310
file(outFile, prereqs, function() {
311+
var startCompileTime = mark();
288312
opts = opts || {};
289313
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
290314
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
@@ -361,11 +385,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
361385
callback();
362386
}
363387

388+
measure(startCompileTime);
364389
complete();
365390
});
366391
ex.addListener("error", function() {
367392
fs.unlinkSync(outFile);
368393
fail("Compilation of " + outFile + " unsuccessful");
394+
measure(startCompileTime);
369395
});
370396
ex.run();
371397
}, {async: true});
@@ -551,7 +577,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr
551577
compileFile(
552578
tsserverLibraryFile,
553579
languageServiceLibrarySources,
554-
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
580+
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
555581
/*prefixes*/ [copyright],
556582
/*useBuiltCompiler*/ true,
557583
{ noOutFile: false, generateDeclarations: true });
@@ -560,9 +586,19 @@ compileFile(
560586
desc("Builds language service server library");
561587
task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]);
562588

589+
desc("Emit the start of the build fold");
590+
task("build-fold-start", [] , function() {
591+
if (fold.isTravis()) console.log(fold.start("build"));
592+
});
593+
594+
desc("Emit the end of the build fold");
595+
task("build-fold-end", [] , function() {
596+
if (fold.isTravis()) console.log(fold.end("build"));
597+
});
598+
563599
// Local target to build the compiler and services
564600
desc("Builds the full compiler and services");
565-
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
601+
task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
566602

567603
// Local target to build only tsc.js
568604
desc("Builds only the compiler");
@@ -617,7 +653,7 @@ task("generate-spec", [specMd]);
617653

618654
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
619655
desc("Makes a new LKG out of the built js files");
620-
task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() {
656+
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
621657
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets);
622658
var missingFiles = expectedFiles.filter(function (f) {
623659
return !fs.existsSync(f);
@@ -758,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
758794
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
759795
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
760796
if(!runInParallel) {
797+
var startTime = mark();
761798
tests = tests ? ' -g "' + tests + '"' : '';
762799
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
763800
console.log(cmd);
@@ -766,20 +803,23 @@ function runConsoleTests(defaultReporter, runInParallel) {
766803
process.env.NODE_ENV = "development";
767804
exec(cmd, function () {
768805
process.env.NODE_ENV = savedNodeEnv;
806+
measure(startTime);
769807
runLinter();
770808
finish();
771809
}, function(e, status) {
772810
process.env.NODE_ENV = savedNodeEnv;
811+
measure(startTime);
773812
finish(status);
774813
});
775814

776815
}
777816
else {
778817
var savedNodeEnv = process.env.NODE_ENV;
779818
process.env.NODE_ENV = "development";
819+
var startTime = mark();
780820
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
781821
process.env.NODE_ENV = savedNodeEnv;
782-
822+
measure(startTime);
783823
// last worker clean everything and runs linter in case if there were no errors
784824
deleteTemporaryProjectOutput();
785825
jake.rmRf(taskConfigsFolder);
@@ -998,12 +1038,22 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
9981038
return path.join(builtLocalDirectory, "tslint", p + ".js");
9991039
});
10001040
desc("Compiles tslint rules to js");
1001-
task("build-rules", tslintRulesOutFiles);
1041+
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
10021042
tslintRulesFiles.forEach(function(ruleFile, i) {
10031043
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
10041044
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")});
10051045
});
10061046

1047+
desc("Emit the start of the build-rules fold");
1048+
task("build-rules-start", [] , function() {
1049+
if (fold.isTravis()) console.log(fold.start("build-rules"));
1050+
});
1051+
1052+
desc("Emit the end of the build-rules fold");
1053+
task("build-rules-end", [] , function() {
1054+
if (fold.isTravis()) console.log(fold.end("build-rules"));
1055+
});
1056+
10071057
function getLinterOptions() {
10081058
return {
10091059
configuration: require("./tslint.json"),
@@ -1047,6 +1097,8 @@ var lintTargets = compilerSources
10471097

10481098
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
10491099
task("lint", ["build-rules"], function() {
1100+
if (fold.isTravis()) console.log(fold.start("lint"));
1101+
var startTime = mark();
10501102
var lintOptions = getLinterOptions();
10511103
var failed = 0;
10521104
var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || "");
@@ -1062,6 +1114,8 @@ task("lint", ["build-rules"], function() {
10621114
done[target] = true;
10631115
}
10641116
}
1117+
measure(startTime);
1118+
if (fold.isTravis()) console.log(fold.end("lint"));
10651119
if (failed > 0) {
10661120
fail('Linter errors.', failed);
10671121
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
},
3131
"devDependencies": {
3232
"@types/browserify": "latest",
33-
"@types/convert-source-map": "latest",
3433
"@types/chai": "latest",
34+
"@types/convert-source-map": "latest",
3535
"@types/del": "latest",
3636
"@types/glob": "latest",
3737
"@types/gulp": "latest",
@@ -72,13 +72,14 @@
7272
"run-sequence": "latest",
7373
"sorcery": "latest",
7474
"through2": "latest",
75+
"travis-fold": "latest",
7576
"ts-node": "latest",
7677
"tslint": "next",
7778
"typescript": "next"
7879
},
7980
"scripts": {
8081
"pretest": "jake tests",
81-
"test": "jake runtests",
82+
"test": "jake runtests-parallel",
8283
"build": "npm run build:compiler && npm run build:tests",
8384
"build:compiler": "jake local",
8485
"build:tests": "jake tests",

scripts/processDiagnosticMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti
6969
}
7070

7171
function buildUniqueNameMap(names: string[]): ts.Map<string> {
72-
var nameMap: ts.Map<string> = {};
72+
var nameMap = ts.createMap<string>();
7373

7474
var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined);
7575

scripts/tslint/preferConstRule.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as Lint from "tslint/lib/lint";
22
import * as ts from "typescript";
33

4-
54
export class Rule extends Lint.Rules.AbstractRule {
65
public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`;
76

@@ -64,7 +63,7 @@ interface DeclarationUsages {
6463
}
6564

6665
class PreferConstWalker extends Lint.RuleWalker {
67-
private inScopeLetDeclarations: ts.Map<DeclarationUsages>[] = [];
66+
private inScopeLetDeclarations: ts.MapLike<DeclarationUsages>[] = [];
6867
private errors: Lint.RuleFailure[] = [];
6968
private markAssignment(identifier: ts.Identifier) {
7069
const name = identifier.text;
@@ -172,7 +171,7 @@ class PreferConstWalker extends Lint.RuleWalker {
172171
}
173172

174173
private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) {
175-
const names: ts.Map<DeclarationUsages> = {};
174+
const names: ts.MapLike<DeclarationUsages> = {};
176175
if (isLet(node.initializer)) {
177176
if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) {
178177
this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names);
@@ -194,7 +193,7 @@ class PreferConstWalker extends Lint.RuleWalker {
194193
}
195194

196195
visitBlock(node: ts.Block) {
197-
const names: ts.Map<DeclarationUsages> = {};
196+
const names: ts.MapLike<DeclarationUsages> = {};
198197
for (const statement of node.statements) {
199198
if (statement.kind === ts.SyntaxKind.VariableStatement) {
200199
this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names);
@@ -205,15 +204,15 @@ class PreferConstWalker extends Lint.RuleWalker {
205204
this.popDeclarations();
206205
}
207206

208-
private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.Map<DeclarationUsages>) {
207+
private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.MapLike<DeclarationUsages>) {
209208
for (const node of list.declarations) {
210209
if (isLet(node) && !isExported(node)) {
211210
this.collectNameIdentifiers(node, node.name, ret);
212211
}
213212
}
214213
}
215214

216-
private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
215+
private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.MapLike<DeclarationUsages>) {
217216
if (node.kind === ts.SyntaxKind.Identifier) {
218217
table[(node as ts.Identifier).text] = { declaration, usages: 0 };
219218
}
@@ -222,7 +221,7 @@ class PreferConstWalker extends Lint.RuleWalker {
222221
}
223222
}
224223

225-
private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
224+
private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.MapLike<DeclarationUsages>) {
226225
for (const element of pattern.elements) {
227226
this.collectNameIdentifiers(value, element.name, table);
228227
}

scripts/types/ambient.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ declare module "into-stream" {
2222
}
2323

2424
declare module "sorcery";
25+
declare module "travis-fold";

0 commit comments

Comments
 (0)