forked from moment/moment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqtest.js
56 lines (53 loc) · 1.8 KB
/
qtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module.exports = function (grunt) {
grunt.task.registerTask('qtest', 'run tests locally', function () {
var done = this.async(),
testrunner,
tests;
testrunner = require('node-qunit');
testrunner.options.log.assertions = false;
testrunner.options.log.tests = false;
testrunner.options.log.summary = false;
testrunner.options.log.testing = false;
testrunner.options.maxBlockDuration = 600000;
if (grunt.option('only') != null) {
tests = grunt.file.expand.apply(
null,
grunt
.option('only')
.split(',')
.map(function (file) {
if (file === 'moment') {
return 'build/umd/test/moment/*.js';
} else if (file === 'locale') {
return 'build/umd/test/locale/*.js';
} else {
return 'build/umd/test/' + file + '.js';
}
})
);
} else {
tests = grunt.file.expand(
'build/umd/test/moment/*.js',
'build/umd/test/locale/*.js'
);
}
testrunner.run(
{
code: 'build/umd/moment.js',
tests: tests,
},
function (err, report) {
if (err) {
console.log('woot', err, report);
done(err);
return;
}
err = null;
if (report.failed !== 0) {
err = new Error(report.failed + ' tests failed');
}
done(err);
}
);
});
};