X Tutup
Skip to content

Commit 5a59e44

Browse files
committed
chore(test): migrate Dart tests to package:test
Instead of running with karma and the karma-dart shim, run dart tests directly using the new package:test runner. This migrates away from package:unittest. Fixes a couple tests, mostly associated with depending on absolute URLs or editing the test providers after an injector had already been created. Remove karma-dart and associated files. Change gupfiles to run tests via `pub run test` instead.
1 parent 7455b90 commit 5a59e44

39 files changed

+530
-509
lines changed

gulpfile.js

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ gulp.task('test.js', function(done) {
467467

468468
gulp.task('test.dart', function(done) {
469469
runSequence('versions.dart', 'test.transpiler.unittest', 'test.unit.dart/ci',
470-
'test.dart.angular2_testing/ci', sequenceComplete(done));
470+
sequenceComplete(done));
471471
});
472472

473473
gulp.task('versions.dart', function() { dartSdk.logVersion(DART_SDK); });
@@ -635,8 +635,7 @@ gulp.task('buildRouter.dev', function() {
635635
gulp.task('test.unit.dart', function(done) {
636636
printModulesWarning();
637637
runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart',
638-
'!build/change_detect.dart', '!build/remove-pub-symlinks', 'build.dart.material.css',
639-
'!test.unit.dart/karma-server', '!test.unit.dart/karma-run', function(error) {
638+
'!build/change_detect.dart', '!build/remove-pub-symlinks', function(error) {
640639
var watch = require('./tools/build/watch');
641640

642641
// if initial build failed (likely due to build or formatting step) then exit
@@ -645,9 +644,10 @@ gulp.task('test.unit.dart', function(done) {
645644
done(error);
646645
return;
647646
}
647+
// treatTestErrorsAsFatal = false;
648648

649-
watch(['modules/angular2/**'], {ignoreInitial: true},
650-
['!build/tree.dart', '!test.unit.dart/karma-run']);
649+
watch(['modules/angular2/**'],
650+
['!build/tree.dart', '!test.unit.dart/run/angular2']);
651651
});
652652
});
653653

@@ -789,20 +789,6 @@ gulp.task('watch.dart.dev', function(done) {
789789
});
790790
});
791791

792-
gulp.task('!test.unit.dart/karma-run', function(done) {
793-
// run the run command in a new process to avoid duplicate logging by both server and runner from
794-
// a single process
795-
runKarma('karma-dart.conf.js', done);
796-
});
797-
798-
799-
gulp.task('!test.unit.dart/karma-server', function() {
800-
var karma = require('karma');
801-
802-
new karma.Server({configFile: __dirname + '/karma-dart.conf.js', reporters: 'dots'}).start();
803-
});
804-
805-
806792
gulp.task('test.unit.router/ci', function(done) {
807793
var karma = require('karma');
808794

@@ -850,20 +836,56 @@ gulp.task('test.unit.js.browserstack/ci', function(done) {
850836
});
851837

852838
gulp.task('test.unit.dart/ci', function(done) {
853-
var karma = require('karma');
839+
runSequence('test.dart.dartium_symlink', '!test.unit.dart/run/angular2',
840+
'!test.unit.dart/run/angular2_testing', '!test.unit.dart/run/benchpress',
841+
sequenceComplete(done));
842+
});
854843

855-
var browserConf = getBrowsersFromCLI(null, true);
856-
new karma.Server(
857-
{
858-
configFile: __dirname + '/karma-dart.conf.js',
859-
singleRun: true,
860-
reporters: ['dots'],
861-
browsers: browserConf.browsersToRun
862-
},
863-
done)
864-
.start();
844+
// At the moment, dart test requires dartium to be an executable on the path.
845+
// Make a temporary directory and symlink dartium from there (just for this command)
846+
// so that it can run.
847+
// TODO(juliemr): this won't work with windows - remove the hack and make this platform agnostic.
848+
var dartiumTmpdir = path.join(os.tmpdir(), 'dartium' + new Date().getTime().toString());
849+
var dartiumPathPrefix = 'PATH=$PATH:' + dartiumTmpdir + ' ';
850+
gulp.task(
851+
'test.dart.dartium_symlink',
852+
shell.task(['mkdir ' + dartiumTmpdir, 'ln -s $DARTIUM_BIN ' + dartiumTmpdir + '/dartium']));
853+
854+
gulp.task('!test.unit.dart/run/angular2', function() {
855+
var pubtest = require('./tools/build/pubtest');
856+
return pubtest({
857+
dir: path.join(CONFIG.dest.dart, 'angular2'),
858+
dartiumTmpdir: dartiumTmpdir,
859+
command: DART_SDK.PUB,
860+
files: '**/*_spec.dart',
861+
bunchFiles: true,
862+
useExclusiveTests: true
863+
});
865864
});
866865

866+
gulp.task('!test.unit.dart/run/angular2_testing', function() {
867+
var pubtest = require('./tools/build/pubtest');
868+
869+
return pubtest({
870+
dir: path.join(CONFIG.dest.dart, 'angular2_testing'),
871+
dartiumTmpdir: dartiumTmpdir,
872+
command: DART_SDK.PUB,
873+
files: '**/*_test.dart',
874+
useExclusiveTests: true
875+
});
876+
});
877+
878+
gulp.task('!test.unit.dart/run/benchpress', function() {
879+
var pubtest = require('./tools/build/pubtest');
880+
881+
return pubtest({
882+
dir: path.join(CONFIG.dest.dart, 'benchpress'),
883+
dartiumTmpdir: dartiumTmpdir,
884+
command: DART_SDK.PUB,
885+
files: '**/*_spec.dart',
886+
useExclusiveTests: true
887+
});
888+
});
867889

868890
gulp.task('test.unit.cjs/ci', function(done) {
869891
runJasmineTests(['dist/js/cjs/{angular2,benchpress}/test/**/*_spec.js'], done);
@@ -930,24 +952,6 @@ gulp.task('test.server.dart', runServerDartTests(gulp, gulpPlugins, {dest: 'dist
930952
gulp.task('test.transpiler.unittest',
931953
function(done) { runJasmineTests(['tools/transpiler/unittest/**/*.js'], done); });
932954

933-
// At the moment, dart test requires dartium to be an executable on the path.
934-
// Make a temporary directory and symlink dartium from there (just for this command)
935-
// so that it can run.
936-
var dartiumTmpdir = path.join(os.tmpdir(), 'dartium' + new Date().getTime().toString());
937-
gulp.task('test.dart.angular2_testing/ci', ['build/pubspec.dart'], function(done) {
938-
runSequence('test.dart.angular2_testing_symlink', 'test.dart.angular2_testing',
939-
sequenceComplete(done));
940-
});
941-
942-
gulp.task(
943-
'test.dart.angular2_testing_symlink',
944-
shell.task(['mkdir ' + dartiumTmpdir, 'ln -s $DARTIUM_BIN ' + dartiumTmpdir + '/dartium']));
945-
946-
gulp.task('test.dart.angular2_testing',
947-
shell.task(['PATH=$PATH:' + dartiumTmpdir + ' pub run test -p dartium'],
948-
{'cwd': 'dist/dart/angular2_testing'}));
949-
950-
951955
// -----------------
952956
// Pre-test checks
953957

@@ -1017,6 +1021,7 @@ gulp.task('build/pure-packages.dart/standalone', function() {
10171021
'modules_dart/**/*',
10181022
'!modules_dart/**/*.proto',
10191023
'!modules_dart/**/packages{,/**}',
1024+
'!modules_dart/**/.packages',
10201025
'!modules_dart/payload{,/**}',
10211026
'!modules_dart/transform{,/**}',
10221027
])

karma-dart-evalcache.js

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

karma-dart.conf.js

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

modules/angular2/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
dev_dependencies:
2424
transformer_test: '^0.2.0'
2525
guinness: '^0.1.18'
26+
guinness2: '0.0.5'
2627
quiver: '^0.21.4'
2728
test: '^0.12.6'
2829
transformers:

modules/angular2/src/testing/matchers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library testing.matchers;
22

33
import 'dart:async';
44

5-
import 'package:guinness/guinness.dart' as gns;
5+
import 'package:guinness2/guinness2.dart' as gns;
66

77
import 'package:angular2/src/platform/dom/dom_adapter.dart' show DOM;
88

0 commit comments

Comments
 (0)
X Tutup