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.
This commit is contained in:
51
tools/build/pubtest.js
Normal file
51
tools/build/pubtest.js
Normal file
@ -0,0 +1,51 @@
|
||||
var util = require('./util');
|
||||
var spawn = require('child_process').spawn;
|
||||
var glob = require('glob');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var process = require('process');
|
||||
var createTestMain = require('./create_dart_test_main.js')
|
||||
|
||||
function filterExclusiveTestFiles(files, dir) {
|
||||
return files.filter(function(file) {
|
||||
// TODO(juliemr): revisit if readFileSync becomes too slow.
|
||||
// At the moment, this takes <100ms for all of angular2.
|
||||
var text = fs.readFileSync(path.join(dir, file));
|
||||
var iit = text.indexOf('iit(');
|
||||
var ddescribe = text.indexOf('ddescribe(');
|
||||
return (iit !== -1 || ddescribe !== -1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function(config) {
|
||||
var platform = config.platform || 'dartium';
|
||||
var pubArgs = ['run', 'test', '-p', platform];
|
||||
var env = process.env;
|
||||
var exclusive = false;
|
||||
if (config.dartiumTmpdir) {
|
||||
env['PATH'] = env['PATH'] + ':' + config.dartiumTmpdir;
|
||||
}
|
||||
|
||||
testFiles = glob.sync(path.join(config.files), {cwd: config.dir});
|
||||
|
||||
if (config.useExclusiveTests) {
|
||||
var filtered = filterExclusiveTestFiles(testFiles, config.dir);
|
||||
if (filtered.length) {
|
||||
exclusive = true;
|
||||
pubArgs.push('--tags');
|
||||
pubArgs.push('solo');
|
||||
testFiles = filtered;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.bunchFiles && !exclusive) {
|
||||
var bigFile = createTestMain(config.dir, testFiles);
|
||||
testFiles = [bigFile];
|
||||
}
|
||||
|
||||
pubArgs = pubArgs.concat(testFiles);
|
||||
|
||||
return util.processToPromise(spawn(config.command, pubArgs, {
|
||||
cwd: config.dir, stdio: 'inherit', env: env
|
||||
}));
|
||||
};
|
Reference in New Issue
Block a user