Run jake in interactive mode so output isn't lost.

Fix jake perftsc.
This commit is contained in:
jbondc 2015-02-18 07:55:29 -05:00
parent d2c992c2de
commit 97ffcc3520
6 changed files with 77 additions and 88 deletions

View File

@ -5,7 +5,8 @@ node_js:
sudo: false
before_script: npm install -g codeclimate-test-reporter
before_script:
- npm install -g codeclimate-test-reporter
after_script:
- cat coverage/lcov.info | codeclimate

View File

@ -235,14 +235,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
cmd = cmd + sources.join(" ");
console.log(cmd + "\n");
var ex = jake.createExec([cmd]);
// Add listeners for output and error
ex.addListener("stdout", function(output) {
process.stdout.write(output);
});
ex.addListener("stderr", function(error) {
process.stderr.write(error);
});
var ex = jake.createExec([cmd], {interactive: true});
ex.addListener("cmdEnd", function() {
if (!useDebugMode && prefixes && fs.existsSync(outFile)) {
for (var i in prefixes) {
@ -303,19 +296,10 @@ compileFile(processDiagnosticMessagesJs,
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
console.log(cmd);
var ex = jake.createExec([cmd]);
// Add listeners for output and error
ex.addListener("stdout", function(output) {
process.stdout.write(output);
});
ex.addListener("stderr", function(error) {
process.stderr.write(error);
});
ex.addListener("cmdEnd", function() {
exec(cmd, function() {
complete();
});
ex.run();
}, {async: true})
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
@ -421,8 +405,8 @@ compileFile(word2mdJs,
file(specMd, [word2mdJs, specWord], function () {
var specWordFullPath = path.resolve(specWord);
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
console.log(cmd);
child_process.exec(cmd, function () {
exec(cmd, function () {
complete();
});
}, {async: true})
@ -476,19 +460,12 @@ desc("Builds the test infrastructure using the built compiler");
task("tests", ["local", run].concat(libraryTargets));
function exec(cmd, completeHandler) {
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
// Add listeners for output and error
ex.addListener("stdout", function(output) {
process.stdout.write(output);
});
ex.addListener("stderr", function(error) {
process.stderr.write(error);
});
console.log(cmd);
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true, interactive: true});
ex.addListener("cmdEnd", function() {
if (completeHandler) {
completeHandler();
}
complete();
});
ex.addListener("error", function(e, status) {
fail("Process exited with code " + status);
@ -509,7 +486,7 @@ function cleanTestDirs() {
}
jake.mkdirP(localRwcBaseline);
jake.mkdirP(localTest262Baseline);
jake.mkdirP(localTest262Baseline);
jake.mkdirP(localBaseline);
}
@ -552,15 +529,17 @@ task("runtests", ["tests", builtLocalDirectory], function() {
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
console.log(cmd);
exec(cmd, deleteTemporaryProjectOutput);
}, {async: true});
desc("Generates code coverage data via instanbul")
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
console.log(cmd);
exec(cmd);
exec(cmd, function(){
complete();
});
}, { async: true });
// Browser tests
@ -571,7 +550,9 @@ compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
var cmd = 'browserify built/local/run.js -o built/local/bundle.js';
exec(cmd);
exec(cmd, function(){
complete();
});
}, {async: true});
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
@ -591,8 +572,9 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
tests = tests ? tests : '';
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
console.log(cmd);
exec(cmd);
exec(cmd, function(){
complete();
});
}, {async: true});
function getDiffTool() {
@ -607,15 +589,17 @@ function getDiffTool() {
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff', function () {
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
console.log(cmd)
exec(cmd);
exec(cmd, function(){
complete();
});
}, {async: true});
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff-rwc', function () {
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
console.log(cmd)
exec(cmd);
exec(cmd, function(){
complete();
});
}, {async: true});
desc("Builds the test sources and automation in debug mode");
@ -676,14 +660,12 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
jake.mkdirP(temp);
var options = "--outdir " + temp + ' ' + loggedIOpath;
var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " ";
console.log(cmd + "\n");
var ex = jake.createExec([cmd]);
ex.addListener("cmdEnd", function() {
exec(cmd, function() {
fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath);
jake.rmRf(temp);
complete();
});
ex.run();
}, {async: true});
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
@ -693,10 +675,8 @@ compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath],
desc("Builds an instrumented tsc.js");
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename;
console.log(cmd);
var ex = jake.createExec([cmd]);
ex.addListener("cmdEnd", function() {
exec(cmd, function() {
complete();
});
ex.run();
}, { async: true });

View File

@ -41,6 +41,6 @@
"codeclimate-test-reporter": "latest"
},
"scripts": {
"test": "jake generate-code-coverage"
"test": "jake --trace generate-code-coverage"
}
}

View File

@ -152,7 +152,10 @@ module ts {
}
export function executeCommandLine(args: string[]): void {
var commandLine = parseCommandLine(args);
return executeCommand(parseCommandLine(args));
}
export function executeCommand(commandLine: ParsedCommandLine): void {
var configFileName: string; // Configuration file name (if any)
var configFileWatcher: FileWatcher; // Configuration file watcher
var cachedProgram: Program; // Program cached from last compilation

View File

@ -20,29 +20,9 @@ module perftest {
export var getCurrentDirectory = ts.sys.getCurrentDirectory;
var exit = ts.sys.exit;
var args = ts.sys.args;
// augment sys so first ts.executeCommandLine call will be finish silently
ts.sys.write = (s: string) => { };
ts.sys.exit = (code: number) => { };
ts.sys.args = []
export function restoreSys() {
ts.sys.args = args;
ts.sys.write = write;
}
export function hasLogIOFlag() {
return args.length > 2 && args[0] === "--logio";
}
export function getArgsWithoutLogIOFlag() {
return args.slice(2);
}
export function getArgsWithoutIOLogFile() {
return args.slice(1);
}
var resolvePathLog: ts.Map<string> = {};
@ -54,22 +34,34 @@ module perftest {
};
}
export function writeIOLog(fileNames: string[]) {
var path = args[1];
export function writeIOLog(fileNames: string[], dstPath: string) {
var log: IOLog = {
fileNames: fileNames,
resolvePath: resolvePathLog
};
writeFile(path, JSON.stringify(log));
writeFile(dstPath, JSON.stringify(log));
}
export function prepare(): IO {
var log = <IOLog>JSON.parse(readFile(args[0]));
export function prepare(cmd: ts.ParsedCommandLine): IO {
var content = readFile(cmd.fileNames[0]);
if (content === undefined) {
throw new Error('Invalid file: ' + cmd.fileNames[0])
}
try {
var log = <IOLog>JSON.parse(content);
}
catch (err) {
write("Invalid IO log file, expecting JSON")
}
cmd.fileNames = []
var files: ts.Map<string> = {};
log.fileNames.forEach(f => { files[f] = readFile(f); })
log.fileNames.forEach(f => {
files[f] = readFile(f);
cmd.fileNames.push(f)
})
ts.sys.createDirectory = (s: string) => { };
ts.sys.directoryExists = (s: string) => true;
ts.sys.fileExists = (s: string) => true;
@ -96,7 +88,9 @@ module perftest {
var out: string = "";
ts.sys.write = (s: string) => { out += s; };
ts.sys.write = (s: string) => {
out += s;
};
return {
getOut: () => out,

View File

@ -2,7 +2,18 @@
/// <reference path="..\src\compiler\tsc.ts"/>
// resolve all files used in this compilation
if (perftest.hasLogIOFlag()) {
ts.optionDeclarations.push({
name: "logio",
type: "string",
isFilePath: true
})
var commandLine = ts.parseCommandLine(ts.sys.args);
commandLine.options.diagnostics = true
var logIoPath = commandLine.options['logio'];
if (logIoPath) {
perftest.interceptIO();
var compilerHost: ts.CompilerHost = {
@ -10,7 +21,7 @@ if (perftest.hasLogIOFlag()) {
var content = perftest.readFile(s);
return content !== undefined ? ts.createSourceFile(s, content, v) : undefined;
},
getDefaultLibFilename: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
writeFile: (f: string, content: string) => { throw new Error("Unexpected operation: writeFile"); },
getCurrentDirectory: () => perftest.getCurrentDirectory(),
getCanonicalFileName: (f: string) => ts.sys.useCaseSensitiveFileNames ? f : f.toLowerCase(),
@ -18,13 +29,13 @@ if (perftest.hasLogIOFlag()) {
getNewLine: () => ts.sys.newLine
};
var commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag());
var program = ts.createProgram(commandLine.filenames, commandLine.options, compilerHost);
var fileNames = program.getSourceFiles().map(f => f.filename);
perftest.writeIOLog(fileNames);
var program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
var fileNames = program.getSourceFiles().map(f => f.fileName);
perftest.writeIOLog(fileNames, "" + logIoPath);
}
else {
var io = perftest.prepare();
ts.executeCommandLine(perftest.getArgsWithoutIOLogFile());
var io = perftest.prepare(commandLine);
ts.executeCommand(commandLine);
perftest.write(io.getOut());
}