Skip to content

Commit

Permalink
Revert "inspector: rewrite inspector test helper"
Browse files Browse the repository at this point in the history
This reverts commit 2296b67.

That commit was landed without a green CI and is failing on Windows.

Ref: nodejs#14460
  • Loading branch information
addaleax committed Aug 11, 2017
1 parent f422e38 commit 42d8d32
Show file tree
Hide file tree
Showing 22 changed files with 1,122 additions and 865 deletions.
9 changes: 0 additions & 9 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ Tests whether `name` and `expected` are part of a raised warning.

Checks if `pathname` exists

### fires(promise, [error], [timeoutMs])
* promise [<Promise]
* error [<String] default = 'timeout'
* timeoutMs [<Number] default = 100

Returns a new promise that will propagate `promise` resolution or rejection if
that happens within the `timeoutMs` timespan, or rejects with `error` as
a reason otherwise.

### fixturesDir
* return [<String>]

Expand Down
42 changes: 0 additions & 42 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,32 +814,6 @@ function restoreWritable(name) {
delete process[name].writeTimes;
}

function onResolvedOrRejected(promise, callback) {
return promise.then((result) => {
callback();
return result;
}, (error) => {
callback();
throw error;
});
}

function timeoutPromise(error, timeoutMs) {
let clearCallback = null;
let done = false;
const promise = onResolvedOrRejected(new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(error), timeoutMs);
clearCallback = () => {
if (done)
return;
clearTimeout(timeout);
resolve();
};
}), () => done = true);
promise.clear = clearCallback;
return promise;
}

exports.hijackStdout = hijackStdWritable.bind(null, 'stdout');
exports.hijackStderr = hijackStdWritable.bind(null, 'stderr');
exports.restoreStdout = restoreWritable.bind(null, 'stdout');
Expand All @@ -853,19 +827,3 @@ exports.firstInvalidFD = function firstInvalidFD() {
} catch (e) {}
return fd;
};

exports.fires = function fires(promise, error, timeoutMs) {
if (!timeoutMs && util.isNumber(error)) {
timeoutMs = error;
error = null;
}
if (!error)
error = 'timeout';
if (!timeoutMs)
timeoutMs = 100;
const timeout = timeoutPromise(error, timeoutMs);
return Promise.race([
onResolvedOrRejected(promise, () => timeout.clear()),
timeout
]);
};
Loading

0 comments on commit 42d8d32

Please sign in to comment.