fix(tsc-wrapped): make `test.sh tools` run the tsc-wrapped tests again (#18683)

This commit is contained in:
Tobias Bosch 2017-08-10 14:46:42 -07:00 committed by Miško Hevery
parent 845c68fdb3
commit 2da45e629d
3 changed files with 20 additions and 14 deletions

View File

@ -23,9 +23,9 @@ require('zone.js/dist/fake-async-test.js');
var jrunner = new JasmineRunner();
(global as any)['jasmine'] = jrunner.jasmine;
require('zone.js/dist/jasmine-patch.js');
var toolsDir = process.cwd() + '/dist/tools';
function toolsDirRequire(moduleId: string) {
return require(path.join(toolsDir, moduleId));
var rootDir = process.cwd();
function rootDirRequire(moduleId: string) {
return require(path.join(rootDir, moduleId));
}
// Tun on full stack traces in errors to help debugging
@ -40,9 +40,8 @@ if (globsIndex < 0) {
args = process.argv.slice(globsIndex + 1);
}
var specFiles = args.map(function(globstr: string) { return glob.sync(globstr, {cwd: toolsDir}); })
var specFiles = args.map(function(globstr: string) { return glob.sync(globstr, {cwd: rootDir}); })
.reduce((specFiles: string[], paths: string[]) => specFiles.concat(paths), []);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color') === -1});
@ -50,5 +49,5 @@ jrunner.configureDefaultReporter({showColors: process.argv.indexOf('--no-color')
jrunner.onComplete(function(passed: boolean) { process.exit(passed ? 0 : 1); });
jrunner.projectBaseDir = path.resolve(__dirname, '../../');
jrunner.specDir = '';
specFiles.forEach((file: string) => { toolsDirRequire(file); });
specFiles.forEach((file: string) => { rootDirRequire(file); });
jrunner.execute();

View File

@ -96,10 +96,10 @@ if (platform == 'node') {
} else if (platform == 'tools') {
tscWatch = new TscWatch(Object.assign(
{
tsconfig: 'tools/tsconfig.json',
tsconfig: ['tools/tsconfig.json', 'packages/tsc-wrapped/tsconfig.json'],
onChangeCmds: [[
'node', 'dist/tools/cjs-jasmine/index-tools', '--',
'@angular/tsc-wrapped/**/*{_,.}spec.js'
'dist/all/@angular/tsc-wrapped/**/*{_,.}spec.js'
]]
},
BaseConfig));

View File

@ -22,7 +22,7 @@ export const TSC = normalize('node_modules/.bin/tsc') + (/^win/.test(platform())
export type Command = (stdIn: any, stdErr: any) => Promise<number>;
export class TscWatch {
private tsconfig: string;
private tsconfig: string[];
private start: string|RegExp;
private error: string|RegExp;
private complete: string|RegExp;
@ -33,13 +33,13 @@ export class TscWatch {
private runOnce: boolean = false;
constructor({tsconfig, start, error, complete, onStartCmds = null, onChangeCmds = null}: {
tsconfig: string,
tsconfig: string | string[],
error: string|RegExp,
start: string,
complete: string, onStartCmds?: Array<string[]|Command>, onChangeCmds?: Array<string[]|Command>
}) {
console.log('Watching:', tsconfig, 'in', process.cwd());
this.tsconfig = tsconfig;
this.tsconfig = Array.isArray(tsconfig) ? tsconfig : [tsconfig];
this.start = start;
this.error = error;
this.complete = complete;
@ -48,10 +48,17 @@ export class TscWatch {
}
watch() {
const args = [TSC, '--emitDecoratorMetadata', '--project', this.tsconfig];
if (!this.runOnce) args.push('--watch');
const tsc =
this.runCmd(args, {}, (d) => this.consumeLine(d, false), (d) => this.consumeLine(d, true));
Promise
.all(this.tsconfig.map(tsconfig => {
const args = [TSC, '--emitDecoratorMetadata', '--project', tsconfig];
if (!this.runOnce) args.push('--watch');
return this.runCmd(
args, {}, (d) => this.consumeLine(d, false), (d) => this.consumeLine(d, true));
}))
.then(
exitCodes =>
exitCodes.reduce((prevValue, currValue) => Math.max(prevValue, currValue), 0));
if (this.runOnce) {
tsc.then(() => this.triggerCmds(), code => process.exit(code));
}