jquery/build/tasks/node_smoke_tests.js
Michał Gołębiowski dbb2daa8c3 Build: Don't install jsdom 3 on Node.js 0.10 & 0.12 by default
jsdom 3 requires Python & Visual Studio on Windows which is a significant
barrier to contributors. Newer jsdom versions don't require pre-compiling
but work only on io.js. This commit installs the new jsdom everywhere (it
does install in old Node.js, it just won't work) and executes Node-related
tests only on newer Nodes or if a working jsdom version is installed. The
latter can be achieved by running the `old_jsdom` task.

Node.js is merging with io.js soon so this will become a smaller problem over
time.

One drawback is our Jenkins setup runs on Node 0.10 so it won't be running
Node tests anymore. We have Travis set up on io.js, though so all PRs
have those tests run. When the new LTS Node.js arrives (as it soon merges
with io.js) we should update our Jenkins infrastructure so that it runs on this
new version.

Fixes gh-2519
Closes gh-2526
2015-09-08 17:42:38 +02:00

33 lines
1.1 KiB
JavaScript

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