Skip to content

Commit 511e832

Browse files
committed
chore(build): Karma watches broccoli output.
This is a prerequisite for switching to TypeScript. We need to remove the Traceur preprocessor from Karma, so we have the build specified in a single place (broccoli tree def'n).
1 parent 09f8d8f commit 511e832

File tree

6 files changed

+42
-44
lines changed

6 files changed

+42
-44
lines changed

gulpfile.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var jsserve = require('./tools/build/jsserve');
2424
var pubserve = require('./tools/build/pubserve');
2525
var rundartpackage = require('./tools/build/rundartpackage');
2626
var file2moduleName = require('./tools/build/file2modulename');
27-
var karma = require('karma').server;
27+
var karma = require('karma');
2828
var minimist = require('minimist');
2929
var runServerDartTests = require('./tools/build/run_server_dart_tests');
3030
var sourcemaps = require('gulp-sourcemaps');
@@ -320,18 +320,41 @@ function getBrowsersFromCLI() {
320320
var args = minimist(process.argv.slice(2));
321321
return [args.browsers?args.browsers:'DartiumWithWebPlatform']
322322
}
323-
gulp.task('test.unit.js', function (done) {
324-
karma.start({configFile: __dirname + '/karma-js.conf.js'}, done);
323+
324+
gulp.task('test.unit.js', ['build/clean.js'], function (neverDone) {
325+
326+
function buildAndTest() {
327+
runSequence(
328+
'broccoli.js.dev',
329+
'test.unit.dev/karma-run'
330+
);
331+
}
332+
333+
karma.server.start({configFile: __dirname + '/karma-js.conf.js'});
334+
buildAndTest();
335+
336+
gulp.watch('modules/**', function() {
337+
console.log('args', arguments);
338+
buildAndTest();
339+
});
340+
});
341+
342+
gulp.task('test.unit.dev/karma-run', function(done) {
343+
karma.runner.run({configFile: __dirname + '/karma-js.conf.js'}, done);
325344
});
345+
346+
326347
gulp.task('test.unit.dart', function (done) {
327-
karma.start({configFile: __dirname + '/karma-dart.conf.js'}, done);
348+
karma.server.start({configFile: __dirname + '/karma-dart.conf.js'}, done);
328349
});
350+
329351
gulp.task('test.unit.js/ci', function (done) {
330-
karma.start({configFile: __dirname + '/karma-js.conf.js',
331-
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
352+
karma.server.start({configFile: __dirname + '/karma-js.conf.js',
353+
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
332354
});
355+
333356
gulp.task('test.unit.dart/ci', function (done) {
334-
karma.start({configFile: __dirname + '/karma-dart.conf.js',
357+
karma.server.start({configFile: __dirname + '/karma-dart.conf.js',
335358
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
336359
});
337360

karma-js.conf.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module.exports = function(config) {
1010
files: [
1111
// Sources and specs.
1212
// Loaded through the es6-module-loader, in `test-main.js`.
13-
{pattern: 'modules/**', included: false},
14-
{pattern: 'tools/transpiler/spec/**', included: false},
13+
{pattern: 'dist/js/dev/es5/**', included: false, watched: false},
1514

1615
'node_modules/traceur/bin/traceur-runtime.js',
1716
'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js',
@@ -28,34 +27,9 @@ module.exports = function(config) {
2827
],
2928

3029
exclude: [
31-
'modules/**/e2e_test/**'
30+
'dist/js/dev/es5/**/e2e_test/**',
3231
],
3332

34-
preprocessors: {
35-
'modules/**/*.js': ['traceur'],
36-
'modules/**/*.es6': ['traceur'],
37-
'tools/transpiler/spec/**/*.js': ['traceur'],
38-
'tools/transpiler/spec/**/*.es6': ['traceur'],
39-
},
40-
41-
traceurPreprocessor: {
42-
options: {
43-
outputLanguage: 'es5',
44-
sourceMaps: true,
45-
script: false,
46-
memberVariables: true,
47-
modules: 'instantiate',
48-
types: true,
49-
typeAssertions: true,
50-
typeAssertionModule: 'rtts_assert/rtts_assert',
51-
annotations: true
52-
},
53-
resolveModuleName: file2moduleName,
54-
transformPath: function(fileName) {
55-
return fileName.replace(/\.es6$/, '.js');
56-
}
57-
},
58-
5933
customLaunchers: {
6034
DartiumWithWebPlatform: {
6135
base: 'Dartium',
@@ -68,6 +42,4 @@ module.exports = function(config) {
6842

6943
port: 9876
7044
});
71-
72-
config.plugins.push(require('./tools/transpiler/karma-traceur-preprocessor'));
7345
};

modules/angular2/src/facade/async.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ export class EventEmitter extends Observable {
123123
return(value) {
124124
this._subject.onCompleted();
125125
}
126-
}
126+
}

modules/angular2/src/facade/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ export class EventEmitter extends Observable {
9999
throw(error) { this._subject.onError(error); }
100100

101101
return (value) { this._subject.onCompleted(); }
102-
}
102+
}

test-main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
99
// we will call `__karma__.start()` later, once all the specs are loaded.
1010
__karma__.loaded = function() {};
1111

12-
13-
System.baseURL = '/base/modules/';
12+
System.baseURL = '/base/';
1413

1514
// So that we can import packages like `core/foo`, instead of `core/src/foo`.
1615
System.paths = {
1716
'*': './*.js',
18-
'transpiler/*': '../tools/transpiler/*.js',
19-
'rx/*': '../node_modules/rx/*.js'
20-
}
17+
'benchpress/*': 'dist/js/dev/es5/benchpress/*.js',
18+
'angular2/*': 'dist/js/dev/es5/angular2/*.js',
19+
'rtts_assert/*': 'dist/js/dev/es5/rtts_assert/*.js',
20+
'rx/*': 'node_modules/rx/*.js'
21+
};
2122

2223
// Import all the specs, execute their `main()` method and kick off Karma (Jasmine).
2324
System.import('angular2/src/dom/browser_adapter').then(function(browser_adapter) {

tools/build/file2modulename.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function file2moduleName(filePath) {
33
// module name should be relative to `modules` and `tools` folder
44
.replace(/.*\/modules\//, '')
55
.replace(/.*\/tools\//, '')
6+
// and 'dist' folder
7+
.replace(/.*\/dist\/js\/dev\/es5\//, '')
68
// module name should not include `lib`, `web` folders
79
// as they are wrapper packages for dart
810
.replace(/\/web\//, '/')

0 commit comments

Comments
 (0)