2016-01-23 12:26:56 -05:00
|
|
|
/*
|
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var gulp = require('gulp'),
|
2016-01-27 13:57:07 -05:00
|
|
|
gulp_qunit = require('gulp-qunit'),
|
|
|
|
node_qunit = require('qunit'),
|
2016-01-27 20:21:34 -05:00
|
|
|
gutil = require('gulp-util');
|
2016-01-27 13:57:07 -05:00
|
|
|
|
2016-01-27 21:03:34 -05:00
|
|
|
gulp.task('test', ['test:browser', 'test:node']);
|
2016-01-27 13:57:07 -05:00
|
|
|
|
|
|
|
gulp.task('test:browser', ['minify:acorn'], function() {
|
2016-01-23 12:26:56 -05:00
|
|
|
return gulp.src('test/index.html')
|
2016-01-27 13:57:07 -05:00
|
|
|
.pipe(gulp_qunit({ timeout: 20, noGlobals: true }));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('test:node', ['minify:acorn'], function(callback) {
|
|
|
|
// Use the correct working directory for tests:
|
|
|
|
process.chdir('./test');
|
2016-01-27 20:21:34 -05:00
|
|
|
// Deactivate all logging since we're doing our own directly to gutil.log()
|
|
|
|
// from helpers.js
|
|
|
|
node_qunit.setup({ log: {} });
|
2016-01-27 13:57:07 -05:00
|
|
|
node_qunit.run({
|
|
|
|
maxBlockDuration: 100 * 1000,
|
|
|
|
deps: [
|
|
|
|
// To dynamically load the tests files from the sources, we need to
|
|
|
|
// require Prepro.js first. Since we need a sub-module, we have to
|
|
|
|
// use relative addresses: require('prepro/lib/node') does not work
|
|
|
|
// because of the way node-qunit handles relative addresses.
|
|
|
|
'../node_modules/prepro/lib/node.js',
|
|
|
|
// Note that loading dist/paper-full.js also works in combination
|
|
|
|
// with `gulp load`, in which case Prepro.js is present and handles
|
|
|
|
// the loading transparently.
|
|
|
|
{ path: '../dist/paper-full.js', namespace: 'paper' }
|
|
|
|
],
|
|
|
|
// Now load the actual test files through test/load.js, using Prepro.js
|
|
|
|
// for the loading, which was requested above.
|
|
|
|
code: 'load.js'
|
|
|
|
}, function(err, stats) {
|
2016-01-27 20:21:34 -05:00
|
|
|
err = err || stats.failed > 0 && 'QUnit assertions failed';
|
|
|
|
callback(err && new gutil.PluginError('node-qunit', err));
|
2016-01-27 13:57:07 -05:00
|
|
|
});
|
2016-01-23 12:26:56 -05:00
|
|
|
});
|