Skip to content

Commit 38e9215

Browse files
committed
Add Rhino test task
1 parent e7d5d5f commit 38e9215

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

Gruntfile.js

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ module.exports = function(grunt) {
181181
'tests/**/*.js'
182182
]
183183
}
184+
},
185+
test_rhino: {
186+
tests: {
187+
src: [
188+
'<%= concat.tests.dest %>',
189+
'tests/all-rules.js'
190+
]
191+
}
184192
}
185193
});
186194

@@ -195,7 +203,9 @@ module.exports = function(grunt) {
195203
// Default task.
196204
grunt.registerTask('default', ['test']);
197205

206+
//Testing
198207
grunt.registerTask('test', ['clean:build', 'jshint', 'concat', 'yuitest']);
208+
grunt.registerTask('rhino', ['clean:build', 'jshint', 'concat', 'test_rhino']);
199209

200210
grunt.registerTask('release', ['test', 'clean:release', 'copy:release', 'includereplace:release', 'changelog']);
201211

@@ -232,18 +242,11 @@ module.exports = function(grunt) {
232242

233243
//Event to execute after all tests suites are finished
234244
function reportResults(allsuites) {
235-
var end = Date.now();
236-
var elapsed = end - start;
237-
grunt.log.writeln().write("Finished in " + (elapsed / 1000) + " seconds").writeln();
238-
239-
if (allsuites.results.failed > 0) {
240-
grunt.fail.warn(allsuites.results.failed + "/" + allsuites.results.total + "tests failed");
241-
} else {
242-
grunt.log.ok(allsuites.results.passed + "/" + allsuites.results.total + "tests passed");
243-
if (allsuites.results.ignored > 0) {
244-
grunt.log.warn("Ignored: " + allsuites.results.ignored);
245-
}
246-
}
245+
var results = allsuites.results;
246+
grunt.log.write("\nTotal tests: " + results.total + ", Failures: " +
247+
results.failed + ", Skipped: " + results.ignored +
248+
", Time: " + (results.duration/1000) + " seconds\n");
249+
247250
//Tell grunt we're done the async testing
248251
done();
249252
}
@@ -323,4 +326,24 @@ module.exports = function(grunt) {
323326
});
324327

325328
});
329+
330+
//Run test suite through rhino
331+
grunt.registerMultiTask('test_rhino', 'Run the test suite through rhino', function() {
332+
var done = this.async();
333+
var files = this.filesSrc;
334+
var progress = files.length;
335+
336+
files.forEach(function(filepath) {
337+
grunt.util.spawn({
338+
cmd: 'java',
339+
args: ['-jar', 'lib/js.jar', 'lib/yuitest-rhino-cli.js', 'build/csslint.js', filepath],
340+
opts: {stdio: 'inherit'}
341+
}, function(error, result, code) {
342+
progress--;
343+
if (progress === 0) {
344+
done();
345+
}
346+
});
347+
});
348+
});
326349
};

0 commit comments

Comments
 (0)