Skip to content

Commit ebb9b06

Browse files
authored
Merge pull request mapbox#301 from mapbox/tape-tests
Refactor tests / port to tape
2 parents 28fd7a2 + 53b852f commit ebb9b06

File tree

10 files changed

+569
-540
lines changed

10 files changed

+569
-540
lines changed

appveyor.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ environment:
55
- nodejs_version: 0.10
66
- nodejs_version: 4
77
- nodejs_version: 6
8+
- nodejs_version: 8
89

910
platform:
1011
- x64
@@ -15,14 +16,19 @@ shallow_clone: true
1516
install:
1617
- ps: Install-Product node $env:nodejs_version $env:Platform
1718
- ps: Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
18-
# make [email protected] x86 builds work
19-
# https://github.com/mapbox/node-pre-gyp/issues/209#issuecomment-217690537
20-
- npm config set -g cafile=package.json
21-
- npm config set -g strict-ssl=false
19+
- npm config get
2220
# upgrade node-gyp to dodge 2013 compile issue present in the node gyp bundled with node v0.10
2321
# https://github.com/nodejs/node-gyp/issues/972#issuecomment-231055109
24-
- npm install [email protected]
25-
- node --version
22+
- IF "%nodejs_version:~0,1%"=="0" npm install [email protected]
23+
# upgrade node-gyp to dodge https://github.com/mapbox/node-pre-gyp/issues/209#issuecomment-307641388
24+
# and allow make node 4.x x86 builds work
25+
# https://github.com/mapbox/node-pre-gyp/issues/209#issuecomment-217690537
26+
- IF "%nodejs_version:~0,1%"=="4" npm install [email protected]
27+
# downgrade npm to avoid multiple npm bugs:
28+
# for node v6 this dodges npm 3.10.10 bug whereby --nodedir/--dist-url is not passed to node-gyp (https://github.com/mapbox/node-pre-gyp/issues/300)
29+
# for all node x86 versions this dodges a mysterious ELIFECYCLE error: https://ci.appveyor.com/project/Mapbox/node-pre-gyp/build/1.0.582/job/b8q2nud6vkj0s6qo#L233
30+
# for node v8 this dodges https://github.com/mapbox/node-pre-gyp/issues/302
31+
- npm install [email protected] -g - node --version
2632
- npm --version
2733
- node -e "console.log(process.arch);"
2834
- IF /I "%PLATFORM%" == "x64" set PATH=C:\Python27-x64;%PATH%

bin/node-pre-gyp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ prog.parseArgv(process.argv);
2626
if (prog.todo.length === 0) {
2727
if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) {
2828
console.log('v%s', prog.version);
29-
} else {
29+
return process.exit(0);
30+
} else if (~process.argv.indexOf('-h') || ~process.argv.indexOf('--help')) {
3031
console.log('%s', prog.usage());
32+
return process.exit(0);
3133
}
32-
return process.exit(0);
34+
console.log('%s', prog.usage());
35+
return process.exit(1);
3336
}
3437

3538
// if --no-color is passed

lib/util/versioning.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ if (process.env.NODE_PRE_GYP_ABI_CROSSWALK) {
1717
abi_crosswalk = require('./abi_crosswalk.json');
1818
}
1919

20+
var major_versions = {};
21+
Object.keys(abi_crosswalk).forEach(function(v) {
22+
var major = v.split('.')[0];
23+
if (!major_versions[major]) {
24+
major_versions[major] = v;
25+
}
26+
});
27+
2028
function get_electron_abi(runtime, target_version) {
2129
if (!runtime) {
2230
throw new Error("get_electron_abi requires valid runtime arg");
@@ -136,6 +144,13 @@ function get_runtime_abi(runtime, target_version) {
136144
break;
137145
}
138146
}
147+
} else if (major >= 2) {
148+
// look for last release that is the same major version
149+
if (major_versions[major]) {
150+
cross_obj = abi_crosswalk[major_versions[major]];
151+
console.log('Warning: node-pre-gyp could not find exact match for ' + target_version);
152+
console.log('Warning: but node-pre-gyp successfully choose ' + major_versions[major] + ' as ABI compatible target');
153+
}
139154
} else if (major === 0) { // node.js
140155
if (target_parts[1] % 2 === 0) { // for stable/even node.js series
141156
// look for the last release that is the same minor release

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,25 @@
2727
"request": "^2.81.0",
2828
"rimraf": "^2.6.1",
2929
"semver": "^5.3.0",
30+
"tape": "^4.6.3",
3031
"tar": "^2.2.1",
3132
"tar-pack": "^3.4.0"
3233
},
3334
"devDependencies": {
3435
"aws-sdk": "^2.28.0",
35-
"mocha": "^3.2.0",
3636
"retire": "^1.2.12",
3737
"jshint": "^2.9.4"
3838
},
3939
"jshintConfig": {
4040
"node": true,
4141
"globalstrict": true,
4242
"undef": true,
43-
"unused": true,
44-
"noarg": true,
45-
"mocha": true
43+
"unused": false,
44+
"noarg": true
4645
},
4746
"scripts": {
4847
"pretest": "jshint test/build.test.js test/s3_setup.test.js test/versioning.test.js",
4948
"update-crosswalk": "node scripts/abi_crosswalk.js",
50-
"test": "jshint lib lib/util scripts bin/node-pre-gyp && mocha -R spec --timeout 500000"
49+
"test": "jshint lib lib/util scripts bin/node-pre-gyp && tape test/*test.js"
5150
}
5251
}

0 commit comments

Comments
 (0)