1 module.exports = function( grunt ) {
5 var fs = require( "fs" ),
6 spawnTest = require( "./lib/spawn_test.js" ),
7 testsDir = "./test/node_smoke_tests/",
8 nodeSmokeTests = [ "babel:nodeSmokeTests" ];
10 // Fire up all tests defined in test/node_smoke_tests/*.js in spawned sub-processes.
11 // All the files under test/node_smoke_tests/*.js are supposed to exit with 0 code
12 // on success or another one on failure. Spawning in sub-processes is
13 // important so that the tests & the main process don't interfere with
14 // each other, e.g. so that they don't share the require cache.
16 fs.readdirSync( testsDir )
17 .filter( function( testFilePath ) {
18 return fs.statSync( testsDir + testFilePath ).isFile() &&
19 /\.js$/.test( testFilePath );
21 .forEach( function( testFilePath ) {
22 var taskName = "node_" + testFilePath.replace( /\.js$/, "" );
24 grunt.registerTask( taskName, function() {
25 spawnTest( this.async(), "test/node_smoke_tests/" + testFilePath );
28 nodeSmokeTests.push( taskName );
31 grunt.registerTask( "node_smoke_tests", nodeSmokeTests );