Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
adjustments (#680)
Browse files Browse the repository at this point in the history
* adjust promisify to node 10+

* run test-50-reject-* on linux only

* set host to node12

* enable armv7 in test-42-fetch-all

* add 12->6 to npm version map in test-79-npm

* remove unneeded test-50-bakery-4
  • Loading branch information
igorklopov committed May 10, 2019
1 parent b0da4ee commit 1d47858
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language:
- node_js
node_js: 10
node_js: 12
services:
- mongodb
sudo: true
Expand Down
58 changes: 34 additions & 24 deletions prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1458,25 +1458,37 @@ function payloadFileSync (pointer) {
var promisify = util.promisify;
if (promisify) {
var custom = promisify.custom;
var binding = process.binding('util');
var createPromise = binding.createPromise;
var promiseResolve = binding.promiseResolve;
var promiseReject = binding.promiseReject;
var customPromisifyArgs = require('internal/util').customPromisifyArgs;
var createPromise;

if (NODE_VERSION_MAJOR <= 8) {
var binding = process.binding('util');
var promiseResolve = binding.promiseResolve;
var promiseReject = binding.promiseReject;
createPromise = function (fn) {
var p = binding.createPromise;
var resolve = promiseResolve.bind(p);
var reject = promiseReject.bind(p);
fn(resolve, reject);
return p;
};
} else {
createPromise = function (fn) {
return new Promise(fn);
};
}

// /////////////////////////////////////////////////////////////
// FS //////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////

Object.defineProperty(require('fs').exists, custom, {
value: function (path) {
var promise = createPromise();

require('fs').exists(path, function (exists) {
promiseResolve(promise, exists);
return createPromise(function (resolve) {
require('fs').exists(path, function (exists) {
resolve(exists);
});
});

return promise;
}
});

Expand All @@ -1492,22 +1504,20 @@ function payloadFileSync (pointer) {
// CHILD_PROCESS ///////////////////////////////////////////////
// /////////////////////////////////////////////////////////////

var customPromiseExecFunction = function (orig) {
var customPromiseExecFunction = function (o) {
return function () {
var args = Array.from(arguments);
var promise = createPromise();

orig.apply(undefined, args.concat(function (error, stdout, stderr) {
if (error !== null) {
error.stdout = stdout;
error.stderr = stderr;
promiseReject(promise, error);
} else {
promiseResolve(promise, { stdout: stdout, stderr: stderr });
}
}));

return promise;
return createPromise(function (resolve, reject) {
o.apply(undefined, args.concat(function (error, stdout, stderr) {
if (error !== null) {
error.stdout = stdout;
error.stderr = stderr;
reject(error);
} else {
resolve({ stdout: stdout, stderr: stderr });
}
}));
});
};
};

Expand Down
4 changes: 2 additions & 2 deletions test/test-42-fetch-all/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function nodeRangeToNodeVersion (nodeRange) {

for (const platform of knownPlatforms) {
const nodeRanges = [ 'node8', 'node10', 'node12' ];
if (platform === 'linux' || platform === 'alpine') nodeRanges.unshift('node6');
if (platform === 'linux') nodeRanges.unshift('node4');
if (platform !== 'macos' && platform !== 'win') nodeRanges.unshift('node6');
for (const nodeRange of nodeRanges) {
const nodeVersion = nodeRangeToNodeVersion(nodeRange);
const archs = [ 'x64' ];
if (platform === 'win') archs.unshift('x86');
// TODO restore // if (platform === 'linux') archs.push('armv7');
if (platform === 'linux') archs.push('armv7');
// linux-armv7 is needed in multi-arch tests,
// so keeping it here as obligatory. but let's
// leave compiling for freebsd to end users
Expand Down
34 changes: 0 additions & 34 deletions test/test-50-bakery-4/main.js

This file was deleted.

16 changes: 0 additions & 16 deletions test/test-50-bakery-4/test-x-index.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/test-50-reject-4/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const utils = require('../utils.js');
assert(!module.parent);
assert(__dirname === process.cwd());

// only linux has node4
if (process.platform !== 'linux') return;

const target = 'node4';
const inputs = { index: './test-x-index.js', warmup: './test-x-warmup.js' };
const output = './run-time/test-output.exe';
Expand Down
3 changes: 3 additions & 0 deletions test/test-50-reject-6/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const utils = require('../utils.js');
assert(!module.parent);
assert(__dirname === process.cwd());

// only linux and alpine have node6
if (process.platform !== 'linux' && process.platform !== 'alpine') return;

const target = 'node6';
const inputs = { index: './test-x-index.js', warmup: './test-x-warmup.js' };
const output = './run-time/test-output.exe';
Expand Down
2 changes: 1 addition & 1 deletion test/test-79-npm/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const hostVersion = process.version.match(/^v(\d+)/)[1];
const host = 'node' + hostVersion;
const target = process.argv[2] || host;
const windows = process.platform === 'win32';
const npm = { 0: 2, 4: 2, 6: 3, 7: 4, 8: 5, 9: 5, 10: 5 }[hostVersion];
const npm = { 0: 2, 4: 2, 6: 3, 7: 4, 8: 5, 9: 5, 10: 5, 12: 6 }[hostVersion];
assert(npm !== undefined);

function applyMetaToRight (right, meta) {
Expand Down

0 comments on commit 1d47858

Please sign in to comment.