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

View File

@ -96,10 +96,10 @@ if (platform == 'node') {
} else if (platform == 'tools') { } else if (platform == 'tools') {
tscWatch = new TscWatch(Object.assign( tscWatch = new TscWatch(Object.assign(
{ {
tsconfig: 'tools/tsconfig.json', tsconfig: ['tools/tsconfig.json', 'packages/tsc-wrapped/tsconfig.json'],
onChangeCmds: [[ onChangeCmds: [[
'node', 'dist/tools/cjs-jasmine/index-tools', '--', 'node', 'dist/tools/cjs-jasmine/index-tools', '--',
'@angular/tsc-wrapped/**/*{_,.}spec.js' 'dist/all/@angular/tsc-wrapped/**/*{_,.}spec.js'
]] ]]
}, },
BaseConfig)); 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 type Command = (stdIn: any, stdErr: any) => Promise<number>;
export class TscWatch { export class TscWatch {
private tsconfig: string; private tsconfig: string[];
private start: string|RegExp; private start: string|RegExp;
private error: string|RegExp; private error: string|RegExp;
private complete: string|RegExp; private complete: string|RegExp;
@ -33,13 +33,13 @@ export class TscWatch {
private runOnce: boolean = false; private runOnce: boolean = false;
constructor({tsconfig, start, error, complete, onStartCmds = null, onChangeCmds = null}: { constructor({tsconfig, start, error, complete, onStartCmds = null, onChangeCmds = null}: {
tsconfig: string, tsconfig: string | string[],
error: string|RegExp, error: string|RegExp,
start: string, start: string,
complete: string, onStartCmds?: Array<string[]|Command>, onChangeCmds?: Array<string[]|Command> complete: string, onStartCmds?: Array<string[]|Command>, onChangeCmds?: Array<string[]|Command>
}) { }) {
console.log('Watching:', tsconfig, 'in', process.cwd()); console.log('Watching:', tsconfig, 'in', process.cwd());
this.tsconfig = tsconfig; this.tsconfig = Array.isArray(tsconfig) ? tsconfig : [tsconfig];
this.start = start; this.start = start;
this.error = error; this.error = error;
this.complete = complete; this.complete = complete;
@ -48,10 +48,17 @@ export class TscWatch {
} }
watch() { watch() {
const args = [TSC, '--emitDecoratorMetadata', '--project', this.tsconfig];
if (!this.runOnce) args.push('--watch');
const tsc = 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) { if (this.runOnce) {
tsc.then(() => this.triggerCmds(), code => process.exit(code)); tsc.then(() => this.triggerCmds(), code => process.exit(code));
} }