parent
376bdf4dc7
commit
52bf0def4e
|
@ -137,7 +137,7 @@ $(npm bin)/gulp clean
|
||||||
|
|
||||||
1. `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e. karma
|
1. `$(npm bin)/gulp test.unit.js`: JS tests in a browser; runs in **watch mode** (i.e. karma
|
||||||
watches the test files for changes and re-runs tests when files are updated).
|
watches the test files for changes and re-runs tests when files are updated).
|
||||||
2. `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS (requires a build before)
|
2. `$(npm bin)/gulp test.unit.cjs`: JS tests in NodeJS; runs in **watch mode**
|
||||||
3. `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
3. `$(npm bin)/gulp test.unit.dart`: Dart tests in Dartium; runs in **watch mode**.
|
||||||
|
|
||||||
If you prefer running tests in "single-run" mode rather than watch mode use
|
If you prefer running tests in "single-run" mode rather than watch mode use
|
||||||
|
|
31
gulpfile.js
31
gulpfile.js
|
@ -3,6 +3,8 @@ var gulpPlugins = require('gulp-load-plugins')();
|
||||||
var runSequence = require('run-sequence');
|
var runSequence = require('run-sequence');
|
||||||
var madge = require('madge');
|
var madge = require('madge');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
||||||
|
|
||||||
var clean = require('./tools/build/clean');
|
var clean = require('./tools/build/clean');
|
||||||
|
@ -16,6 +18,7 @@ var jsserve = require('./tools/build/jsserve');
|
||||||
var pubserve = require('./tools/build/pubserve');
|
var pubserve = require('./tools/build/pubserve');
|
||||||
var rundartpackage = require('./tools/build/rundartpackage');
|
var rundartpackage = require('./tools/build/rundartpackage');
|
||||||
var copy = require('./tools/build/copy');
|
var copy = require('./tools/build/copy');
|
||||||
|
var file2moduleName = require('./tools/build/file2modulename');
|
||||||
var karma = require('karma').server;
|
var karma = require('karma').server;
|
||||||
var minimist = require('minimist');
|
var minimist = require('minimist');
|
||||||
var es5build = require('./tools/build/es5build');
|
var es5build = require('./tools/build/es5build');
|
||||||
|
@ -606,8 +609,32 @@ gulp.task('test.unit.dart/ci', function (done) {
|
||||||
karma.start({configFile: __dirname + '/karma-dart.conf.js',
|
karma.start({configFile: __dirname + '/karma-dart.conf.js',
|
||||||
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
||||||
});
|
});
|
||||||
gulp.task('test.unit.cjs', function (done) {
|
gulp.task('test.unit.cjs/ci', function () {
|
||||||
return gulp.src(CONFIG.test.js.cjs).pipe(jasmine(/*{verbose: true, includeStackTrace: true}*/));
|
return gulp.src(CONFIG.test.js.cjs).pipe(jasmine({includeStackTrace: true, timeout: 1000}));
|
||||||
|
});
|
||||||
|
gulp.task('test.unit.cjs', ['build.js.cjs'], function () {
|
||||||
|
//Run tests once
|
||||||
|
runSequence('test.unit.cjs/ci', function() {});
|
||||||
|
//Watcher to transpile file changed
|
||||||
|
gulp.watch(CONFIG.transpile.src.js.concat(['modules/**/*.cjs']), function(event) {
|
||||||
|
var relPath = path.relative(__dirname, event.path).replace(/\\/g, "/");
|
||||||
|
gulp.src(relPath)
|
||||||
|
.pipe(gulpPlugins.rename({extname: '.'+ 'js'}))
|
||||||
|
.pipe(util.insertSrcFolder(gulpPlugins, CONFIG.srcFolderInsertion.js))
|
||||||
|
.pipe(gulpTraceur(CONFIG.transpile.options.js.cjs, file2moduleName))
|
||||||
|
.pipe(transformCJSTests())
|
||||||
|
.pipe(gulp.dest(CONFIG.dest.js.cjs + path.dirname(relPath.replace("modules", ""))));
|
||||||
|
});
|
||||||
|
//Watcher to run tests when dist/js/cjs/angular2 is updated by the first watcher (after clearing the node cache)
|
||||||
|
gulp.watch(CONFIG.dest.js.cjs + '/angular2/**/*.js', function(event) {
|
||||||
|
for (var id in require.cache) {
|
||||||
|
if (id.replace(/\\/g, "/").indexOf(CONFIG.dest.js.cjs) > -1) {
|
||||||
|
delete require.cache[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
runSequence('test.unit.cjs/ci', function() {});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
|
|
|
@ -10,4 +10,4 @@ cd $SCRIPT_DIR/../..
|
||||||
./node_modules/.bin/gulp test.transpiler.unittest
|
./node_modules/.bin/gulp test.transpiler.unittest
|
||||||
./node_modules/.bin/gulp docs/test
|
./node_modules/.bin/gulp docs/test
|
||||||
./node_modules/.bin/gulp test.unit.js/ci --browsers=$KARMA_BROWSERS
|
./node_modules/.bin/gulp test.unit.js/ci --browsers=$KARMA_BROWSERS
|
||||||
./node_modules/.bin/gulp test.unit.cjs
|
./node_modules/.bin/gulp test.unit.cjs/ci
|
||||||
|
|
|
@ -23,9 +23,9 @@ exports.reloadSources = function() {
|
||||||
needsReload = true;
|
needsReload = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.compile = function compile(options, paths, source) {
|
exports.compile = function compile(options, paths, source, reloadTraceur) {
|
||||||
if (needsReload) {
|
if (needsReload) {
|
||||||
reloadCompiler();
|
reloadCompiler(reloadTraceur);
|
||||||
needsReload = false;
|
needsReload = false;
|
||||||
}
|
}
|
||||||
var inputPath, outputPath, moduleName;
|
var inputPath, outputPath, moduleName;
|
||||||
|
@ -73,8 +73,10 @@ exports.init = function() {
|
||||||
|
|
||||||
// Transpile and evaluate the code in `src`.
|
// Transpile and evaluate the code in `src`.
|
||||||
// Use existing traceur to compile our sources.
|
// Use existing traceur to compile our sources.
|
||||||
function reloadCompiler() {
|
function reloadCompiler(reloadTraceur) {
|
||||||
|
if (reloadTraceur) {
|
||||||
loadModule(TRACEUR_PATH, false);
|
loadModule(TRACEUR_PATH, false);
|
||||||
|
}
|
||||||
glob.sync(__dirname + '/src/**/*.js').forEach(function(fileName) {
|
glob.sync(__dirname + '/src/**/*.js').forEach(function(fileName) {
|
||||||
loadModule(fileName, true);
|
loadModule(fileName, true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ function createJs2DartPreprocessor(logger, basePath, config, emitter) {
|
||||||
inputPath: file.originalPath,
|
inputPath: file.originalPath,
|
||||||
outputPath: file.path,
|
outputPath: file.path,
|
||||||
moduleName: moduleName
|
moduleName: moduleName
|
||||||
}, content);
|
}, content, true);
|
||||||
|
|
||||||
var transpiledContent = result.js;
|
var transpiledContent = result.js;
|
||||||
var sourceMap = result.sourceMap;
|
var sourceMap = result.sourceMap;
|
||||||
|
|
Loading…
Reference in New Issue