Skip to content

Commit cc35bd5

Browse files
committed
Merge remote-tracking branch 'origin/master' into import_completions_pr
2 parents 8a976f1 + 7ee05ba commit cc35bd5

File tree

314 files changed

+8818
-29214
lines changed

Some content is hidden

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

314 files changed

+8818
-29214
lines changed

.travis.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,33 @@ node_js:
77

88
sudo: false
99

10-
os:
11-
- linux
12-
- osx
10+
env:
11+
- workerCount=3
1312

1413
matrix:
1514
fast_finish: true
16-
exclude:
15+
include:
1716
- os: osx
18-
node_js: '4'
17+
node_js: stable
18+
osx_image: xcode7.3
19+
env: workerCount=2
20+
allow_failures:
1921
- os: osx
20-
node_js: '0.10'
2122

2223
branches:
2324
only:
2425
- master
25-
- transforms
26+
- transforms
27+
28+
install:
29+
- npm uninstall typescript
30+
- npm uninstall tslint
31+
- npm install
32+
- npm update
33+
34+
cache:
35+
directories:
36+
- node_modules
37+
38+
git:
39+
depth: 1

Gulpfile.ts

Lines changed: 66 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import through2 = require("through2");
3434
import merge2 = require("merge2");
3535
import intoStream = require("into-stream");
3636
import * as os from "os";
37-
import Linter = require("tslint");
37+
import fold = require("travis-fold");
3838
const gulp = helpMaker(originalGulp);
3939
const mochaParallel = require("./scripts/mocha-parallel.js");
4040
const {runTestsInParallel} = mochaParallel;
@@ -59,7 +59,6 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5959
browser: process.env.browser || process.env.b || "IE",
6060
tests: process.env.test || process.env.tests || process.env.t,
6161
light: process.env.light || false,
62-
port: process.env.port || process.env.p || "8888",
6362
reporter: process.env.reporter || process.env.r,
6463
lint: process.env.lint || true,
6564
files: process.env.f || process.env.file || process.env.files || "",
@@ -450,7 +449,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
450449
});
451450

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

456455

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

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

509508
gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => {
510509
return runSequence("LKGInternal", "VerifyLKG");
@@ -766,7 +765,7 @@ function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?:
766765
}
767766

768767

769-
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --port=, --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
768+
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
770769
cleanTestDirs((err) => {
771770
if (err) { console.error(err); done(err); process.exit(1); }
772771
host = "node";
@@ -781,9 +780,6 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
781780
}
782781

783782
const args = [nodeServerOutFile];
784-
if (cmdLineOptions["port"]) {
785-
args.push(cmdLineOptions["port"]);
786-
}
787783
if (cmdLineOptions["browser"]) {
788784
args.push(cmdLineOptions["browser"]);
789785
}
@@ -932,26 +928,6 @@ gulp.task("build-rules", "Compiles tslint rules to js", () => {
932928
.pipe(gulp.dest(dest));
933929
});
934930

935-
function getLinterOptions() {
936-
return {
937-
configuration: require("./tslint.json"),
938-
formatter: "prose",
939-
formattersDirectory: undefined,
940-
rulesDirectory: "built/local/tslint"
941-
};
942-
}
943-
944-
function lintFileContents(options, path, contents) {
945-
const ll = new Linter(path, contents, options);
946-
console.log("Linting '" + path + "'.");
947-
return ll.lint();
948-
}
949-
950-
function lintFile(options, path) {
951-
const contents = fs.readFileSync(path, "utf8");
952-
return lintFileContents(options, path, contents);
953-
}
954-
955931
const lintTargets = [
956932
"Gulpfile.ts",
957933
"src/compiler/**/*.ts",
@@ -960,29 +936,75 @@ const lintTargets = [
960936
"src/server/**/*.ts",
961937
"scripts/tslint/**/*.ts",
962938
"src/services/**/*.ts",
939+
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
963940
];
964941

942+
function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback: (failures: number) => void, failures: number) {
943+
const file = files.pop();
944+
if (file) {
945+
console.log(`Linting '${file.path}'.`);
946+
child.send({ kind: "file", name: file.path });
947+
}
948+
else {
949+
child.send({ kind: "close" });
950+
callback(failures);
951+
}
952+
}
953+
954+
function spawnLintWorker(files: {path: string}[], callback: (failures: number) => void) {
955+
const child = cp.fork("./scripts/parallel-lint");
956+
let failures = 0;
957+
child.on("message", function(data) {
958+
switch (data.kind) {
959+
case "result":
960+
if (data.failures > 0) {
961+
failures += data.failures;
962+
console.log(data.output);
963+
}
964+
sendNextFile(files, child, callback, failures);
965+
break;
966+
case "error":
967+
console.error(data.error);
968+
failures++;
969+
sendNextFile(files, child, callback, failures);
970+
break;
971+
}
972+
});
973+
sendNextFile(files, child, callback, failures);
974+
}
965975

966976
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
967977
const fileMatcher = RegExp(cmdLineOptions["files"]);
968-
const lintOptions = getLinterOptions();
969-
let failed = 0;
970-
return gulp.src(lintTargets)
971-
.pipe(insert.transform((contents, file) => {
972-
if (!fileMatcher.test(file.path)) return contents;
973-
const result = lintFile(lintOptions, file.path);
974-
if (result.failureCount > 0) {
975-
console.log(result.output);
976-
failed += result.failureCount;
978+
if (fold.isTravis()) console.log(fold.start("lint"));
979+
980+
let files: {stat: fs.Stats, path: string}[] = [];
981+
return gulp.src(lintTargets, { read: false })
982+
.pipe(through2.obj((chunk, enc, cb) => {
983+
files.push(chunk);
984+
cb();
985+
}, (cb) => {
986+
files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
987+
const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length;
988+
for (let i = 0; i < workerCount; i++) {
989+
spawnLintWorker(files, finished);
977990
}
978-
return contents; // TODO (weswig): Automatically apply fixes? :3
979-
}))
980-
.on("end", () => {
981-
if (failed > 0) {
982-
console.error("Linter errors.");
983-
process.exit(1);
991+
992+
let completed = 0;
993+
let failures = 0;
994+
function finished(fails) {
995+
completed++;
996+
failures += fails;
997+
if (completed === workerCount) {
998+
if (fold.isTravis()) console.log(fold.end("lint"));
999+
if (failures > 0) {
1000+
throw new Error(`Linter errors: ${failures}`);
1001+
}
1002+
else {
1003+
cb();
1004+
}
1005+
}
9841006
}
985-
});
1007+
}));
9861008
});
9871009

9881010

0 commit comments

Comments
 (0)