Build/Test Tools: Specify exact node version in package.json.

Enforce it in the tests.

Merges [39478] to the 4.7 branch.

see #35105, #38657.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39480 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2016-12-04 17:37:38 +00:00
parent 98b7307e75
commit afca2c6cf0
2 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,9 @@
"type": "svn",
"url": "https://develop.svn.wordpress.org/trunk"
},
"engines": {
"node": "6.9.1"
},
"author": "The WordPress Contributors",
"license": "GPL-2.0+",
"devDependencies": {

View File

@ -23,8 +23,19 @@ class Tests_Basic extends WP_UnitTestCase {
$version .= '.0';
}
$this->assertEquals( $version, $package_json['version'], "package.json's version needs to be updated to $version." );
return $package_json;
}
/**
* @depends test_package_json
*/
function test_package_json_node_engine( $package_json ) {
$this->assertArrayHasKey( 'engines', $package_json );
$this->assertArrayHasKey( 'node', $package_json['engines'] );
$node = $package_json['engines']['node'];
$this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." );
}
// two tests for a lame bug in PHPUnit that broke the $GLOBALS reference
function test_globals() {
global $test_foo;