Skip to content

Commit 35bfe4e

Browse files
Merge pull request microsoft#2063 from jbondc/contrib
Run jake in interactive mode so output isn't lost.
2 parents 7212912 + cb6852a commit 35bfe4e

6 files changed

Lines changed: 46 additions & 208 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ node_js:
55

66
sudo: false
77

8-
before_script: npm install -g codeclimate-test-reporter
8+
before_script:
9+
- npm install -g codeclimate-test-reporter
910

1011
after_script:
1112
- cat coverage/lcov.info | codeclimate

Jakefile

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
var fs = require("fs");
44
var os = require("os");
55
var path = require("path");
6-
var child_process = require("child_process");
76

87
// Variables
98
var compilerDirectory = "src/compiler/";
@@ -26,7 +25,8 @@ var thirdParty = "ThirdPartyNoticeText.txt";
2625
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
2726
if (process.env.path !== undefined) {
2827
process.env.path = nodeModulesPathPrefix + process.env.path;
29-
} else if (process.env.PATH !== undefined) {
28+
}
29+
else if (process.env.PATH !== undefined) {
3030
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3131
}
3232

@@ -203,7 +203,8 @@ function concatenateFiles(destinationFile, sourceFiles) {
203203
var useDebugMode = true;
204204
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
205205
var compilerFilename = "tsc.js";
206-
/* Compiles a file from a list of sources
206+
207+
/* Compiles a file from a list of sources
207208
* @param outFile: the target file name
208209
* @param sources: an array of the names of the source files
209210
* @param prereqs: prerequisite tasks to compiling the file
@@ -214,8 +215,9 @@ var compilerFilename = "tsc.js";
214215
* @param outDir: true to compile using --outDir
215216
* @param keepComments: false to compile using --removeComments
216217
* @param callback: a function to execute after the compilation process ends
218+
* @async
217219
*/
218-
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
220+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
219221
file(outFile, prereqs, function() {
220222
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
221223
var options = "--module commonjs -noImplicitAny";
@@ -254,17 +256,9 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
254256

255257
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
256258
cmd = cmd + sources.join(" ");
257-
console.log(cmd + "\n");
258259

259-
var ex = jake.createExec([cmd]);
260-
// Add listeners for output and error
261-
ex.addListener("stdout", function(output) {
262-
process.stdout.write(output);
263-
});
264-
ex.addListener("stderr", function(error) {
265-
process.stderr.write(error);
266-
});
267-
ex.addListener("cmdEnd", function() {
260+
exec(cmd, function() {
261+
console.log("")
268262
if (!useDebugMode && prefixes && fs.existsSync(outFile)) {
269263
for (var i in prefixes) {
270264
prependFile(prefixes[i], outFile);
@@ -274,14 +268,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
274268
if (callback) {
275269
callback();
276270
}
277-
278-
complete();
279-
});
280-
ex.addListener("error", function() {
271+
else {
272+
complete();
273+
}
274+
}, /* errorHandler */ function() {
281275
fs.unlinkSync(outFile);
282276
fail("Compilation of " + outFile + " unsuccessful");
283277
});
284-
ex.run();
278+
285279
}, {async: true});
286280
}
287281

@@ -324,19 +318,8 @@ compileFile(processDiagnosticMessagesJs,
324318
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
325319
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
326320
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
327-
console.log(cmd);
328-
var ex = jake.createExec([cmd]);
329-
// Add listeners for output and error
330-
ex.addListener("stdout", function(output) {
331-
process.stdout.write(output);
332-
});
333-
ex.addListener("stderr", function(error) {
334-
process.stderr.write(error);
335-
});
336-
ex.addListener("cmdEnd", function() {
337-
complete();
338-
});
339-
ex.run();
321+
322+
exec(cmd);
340323
}, {async: true})
341324

342325
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
@@ -401,6 +384,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
401384

402385
// Delete the temp dir
403386
jake.rmRf(tempDirPath, {silent: true});
387+
complete();
404388
});
405389

406390
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
@@ -449,10 +433,8 @@ compileFile(word2mdJs,
449433
file(specMd, [word2mdJs, specWord], function () {
450434
var specWordFullPath = path.resolve(specWord);
451435
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
452-
console.log(cmd);
453-
child_process.exec(cmd, function () {
454-
complete();
455-
});
436+
437+
exec(cmd);
456438
}, {async: true})
457439

458440

@@ -503,22 +485,24 @@ var refTest262Baseline = path.join(internalTests, "baselines/test262/reference")
503485
desc("Builds the test infrastructure using the built compiler");
504486
task("tests", ["local", run].concat(libraryTargets));
505487

506-
function exec(cmd, completeHandler) {
507-
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
508-
// Add listeners for output and error
509-
ex.addListener("stdout", function(output) {
510-
process.stdout.write(output);
511-
});
512-
ex.addListener("stderr", function(error) {
513-
process.stderr.write(error);
514-
});
488+
/* Executes a command
489+
* @param cmd: command to execute
490+
* @param completeHandler?: a function to execute after the command ends
491+
* @param errorHandler?: a function to execute if an error occurs
492+
* @async
493+
*/
494+
function exec(cmd, completeHandler, errorHandler) {
495+
console.log(cmd);
496+
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true, interactive: true});
515497
ex.addListener("cmdEnd", function() {
516498
if (completeHandler) {
517499
completeHandler();
518500
}
519-
complete();
501+
else {
502+
complete();
503+
}
520504
});
521-
ex.addListener("error", function(e, status) {
505+
ex.addListener("error", errorHandler || function(e, status) {
522506
fail("Process exited with code " + status);
523507
})
524508

@@ -537,7 +521,7 @@ function cleanTestDirs() {
537521
}
538522

539523
jake.mkdirP(localRwcBaseline);
540-
jake.mkdirP(localTest262Baseline);
524+
jake.mkdirP(localTest262Baseline);
541525
jake.mkdirP(localBaseline);
542526
}
543527

@@ -548,10 +532,14 @@ function writeTestConfigFile(tests, testConfigFile) {
548532
fs.writeFileSync('test.config', testConfigContents);
549533
}
550534

535+
/* Removes project output
536+
* @async
537+
*/
551538
function deleteTemporaryProjectOutput() {
552539
if (fs.existsSync(path.join(localBaseline, "projectOutput/"))) {
553540
jake.rmRf(path.join(localBaseline, "projectOutput/"));
554541
}
542+
complete();
555543
}
556544

557545
var testTimeout = 20000;
@@ -580,14 +568,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
580568
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
581569
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
582570
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
583-
console.log(cmd);
571+
584572
exec(cmd, deleteTemporaryProjectOutput);
585573
}, {async: true});
586574

587575
desc("Generates code coverage data via instanbul")
588576
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
589577
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
590-
console.log(cmd);
578+
591579
exec(cmd);
592580
}, { async: true });
593581

@@ -619,7 +607,6 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
619607

620608
tests = tests ? tests : '';
621609
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
622-
console.log(cmd);
623610
exec(cmd);
624611
}, {async: true});
625612

@@ -635,14 +622,12 @@ function getDiffTool() {
635622
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
636623
task('diff', function () {
637624
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
638-
console.log(cmd)
639625
exec(cmd);
640626
}, {async: true});
641627

642628
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
643629
task('diff-rwc', function () {
644630
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
645-
console.log(cmd)
646631
exec(cmd);
647632
}, {async: true});
648633

@@ -689,13 +674,6 @@ task("webhost", [webhostJsPath], function() {
689674
jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true});
690675
});
691676

692-
// Perf compiler
693-
var perftscPath = "tests/perftsc.ts";
694-
var perftscJsPath = "built/local/perftsc.js";
695-
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
696-
desc("Builds augmented version of the compiler for perf tests");
697-
task("perftsc", [perftscJsPath]);
698-
699677
// Instrumented compiler
700678
var loggedIOpath = harnessDirectory + 'loggedIO.ts';
701679
var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js';
@@ -704,14 +682,12 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
704682
jake.mkdirP(temp);
705683
var options = "--outdir " + temp + ' ' + loggedIOpath;
706684
var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " ";
707-
console.log(cmd + "\n");
708-
var ex = jake.createExec([cmd]);
709-
ex.addListener("cmdEnd", function() {
685+
686+
exec(cmd, function() {
710687
fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath);
711688
jake.rmRf(temp);
712689
complete();
713690
});
714-
ex.run();
715691
}, {async: true});
716692

717693
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
@@ -721,10 +697,6 @@ compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath],
721697
desc("Builds an instrumented tsc.js");
722698
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
723699
var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename;
724-
console.log(cmd);
725-
var ex = jake.createExec([cmd]);
726-
ex.addListener("cmdEnd", function() {
727-
complete();
728-
});
729-
ex.run();
700+
701+
exec(cmd);
730702
}, { async: true });

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
"codeclimate-test-reporter": "latest"
4343
},
4444
"scripts": {
45-
"test": "jake generate-code-coverage"
45+
"test": "jake --trace generate-code-coverage"
4646
}
4747
}

src/compiler/tsc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ module ts {
258258
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
259259
}
260260

261-
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
261+
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) {
262262
// Return existing SourceFile object if one is available
263263
if (cachedProgram) {
264264
var sourceFile = cachedProgram.getSourceFile(fileName);

tests/perfsys.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)