Skip to content

Commit 5f1c7fc

Browse files
committed
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. (cherry-picked from dbb2daa) Fixes gh-2519 Closes gh-2526
1 parent 8c851bf commit 5f1c7fc

File tree

5 files changed

+41
-35
lines changed

5 files changed

+41
-35
lines changed

Gruntfile.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ module.exports = function( grunt ) {
1414
var fs = require( "fs" ),
1515
stripJSONComments = require( "strip-json-comments" ),
1616
gzip = require( "gzip-js" ),
17-
srcHintOptions = readOptionalJSON( "src/.jshintrc" );
17+
srcHintOptions = readOptionalJSON( "src/.jshintrc" ),
18+
newNode = !/^v0/.test( process.version ),
19+
20+
// Allow to skip jsdom-related tests in Node.js < 1.0.0
21+
runJsdomTests = newNode || ( function() {
22+
try {
23+
require( "jsdom" );
24+
return true;
25+
} catch ( e ) {
26+
return false;
27+
}
28+
} )();
1829

1930
// The concatenated file won't pass onevar
2031
// But our modules can
@@ -180,9 +191,14 @@ module.exports = function( grunt ) {
180191

181192
grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
182193

183-
grunt.registerTask( "test_fast", [ "node_smoke_tests" ] );
194+
// Don't run Node-related tests in Node.js < 1.0.0 as they require an old
195+
// jsdom version that needs compiling, making it harder for people to compile
196+
// jQuery on Windows. (see gh-2519)
197+
grunt.registerTask( "test_fast", runJsdomTests ? [ "node_smoke_tests" ] : [] );
184198

185-
grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] );
199+
grunt.registerTask( "test", [ "test_fast" ].concat(
200+
runJsdomTests ? [ "promises_aplus_tests" ] : []
201+
) );
186202

187203
// Short list as a high frequency watch task
188204
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );

build/tasks/install_jsdom.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

build/tasks/install_old_jsdom.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = function( grunt ) {
2+
3+
"use strict";
4+
5+
// Run this task to run jsdom-related tests on Node.js < 1.0.0.
6+
grunt.registerTask( "old_jsdom", function() {
7+
if ( !/^v0/.test( process.version ) ) {
8+
console.warn( "The old_jsdom task doesn\'t need to be run in io.js or new Node.js" );
9+
return;
10+
}
11+
12+
// Use npm on the command-line
13+
// There is no local npm
14+
grunt.util.spawn( {
15+
cmd: "npm",
16+
args: [ "install", "jsdom@3" ],
17+
opts: { stdio: "inherit" }
18+
}, this.async() );
19+
} );
20+
};

build/tasks/node_smoke_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = function( grunt ) {
55
var fs = require( "fs" ),
66
spawnTest = require( "./lib/spawn_test.js" ),
77
testsDir = "./test/node_smoke_tests/",
8-
nodeSmokeTests = [ "jsdom", "babel:nodeSmokeTests" ];
8+
nodeSmokeTests = [ "babel:nodeSmokeTests" ];
99

1010
// Fire up all tests defined in test/node_smoke_tests/*.js in spawned sub-processes.
1111
// All the files under test/node_smoke_tests/*.js are supposed to exit with 0 code

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"grunt-jsonlint": "1.0.4",
4040
"grunt-npmcopy": "0.1.0",
4141
"gzip-js": "0.3.2",
42+
"jsdom": "5.6.1",
4243
"load-grunt-tasks": "1.0.0",
4344
"native-promise-only": "0.7.8-a",
4445
"promises-aplus-tests": "2.1.0",
@@ -52,10 +53,6 @@
5253
"testswarm": "1.1.0",
5354
"win-spawn": "2.0.0"
5455
},
55-
"jsdomVersions": {
56-
"node": "3.1.2",
57-
"iojs": "5.3.0"
58-
},
5956
"scripts": {
6057
"build": "npm install && grunt",
6158
"start": "grunt watch",

0 commit comments

Comments
 (0)