Skip to content

Commit a6973a3

Browse files
committed
Revert "inspector: rewrite inspector test helper"
This reverts commit 2296b67. That commit was landed without a green CI and is failing on Windows. Ref: #14460 PR-URL: #14777 Reviewed-By: Refael Ackermann <[email protected]>
1 parent f422e38 commit a6973a3

22 files changed

+1122
-865
lines changed

test/common/README.md

-9
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,6 @@ Tests whether `name` and `expected` are part of a raised warning.
9999

100100
Checks if `pathname` exists
101101

102-
### fires(promise, [error], [timeoutMs])
103-
* promise [&lt;Promise]
104-
* error [&lt;String] default = 'timeout'
105-
* timeoutMs [&lt;Number] default = 100
106-
107-
Returns a new promise that will propagate `promise` resolution or rejection if
108-
that happens within the `timeoutMs` timespan, or rejects with `error` as
109-
a reason otherwise.
110-
111102
### fixturesDir
112103
* return [&lt;String>]
113104

test/common/index.js

-42
Original file line numberDiff line numberDiff line change
@@ -814,32 +814,6 @@ function restoreWritable(name) {
814814
delete process[name].writeTimes;
815815
}
816816

817-
function onResolvedOrRejected(promise, callback) {
818-
return promise.then((result) => {
819-
callback();
820-
return result;
821-
}, (error) => {
822-
callback();
823-
throw error;
824-
});
825-
}
826-
827-
function timeoutPromise(error, timeoutMs) {
828-
let clearCallback = null;
829-
let done = false;
830-
const promise = onResolvedOrRejected(new Promise((resolve, reject) => {
831-
const timeout = setTimeout(() => reject(error), timeoutMs);
832-
clearCallback = () => {
833-
if (done)
834-
return;
835-
clearTimeout(timeout);
836-
resolve();
837-
};
838-
}), () => done = true);
839-
promise.clear = clearCallback;
840-
return promise;
841-
}
842-
843817
exports.hijackStdout = hijackStdWritable.bind(null, 'stdout');
844818
exports.hijackStderr = hijackStdWritable.bind(null, 'stderr');
845819
exports.restoreStdout = restoreWritable.bind(null, 'stdout');
@@ -853,19 +827,3 @@ exports.firstInvalidFD = function firstInvalidFD() {
853827
} catch (e) {}
854828
return fd;
855829
};
856-
857-
exports.fires = function fires(promise, error, timeoutMs) {
858-
if (!timeoutMs && util.isNumber(error)) {
859-
timeoutMs = error;
860-
error = null;
861-
}
862-
if (!error)
863-
error = 'timeout';
864-
if (!timeoutMs)
865-
timeoutMs = 100;
866-
const timeout = timeoutPromise(error, timeoutMs);
867-
return Promise.race([
868-
onResolvedOrRejected(promise, () => timeout.clear()),
869-
timeout
870-
]);
871-
};

0 commit comments

Comments
 (0)