@brillout/test-e2e 0.6.21 → 0.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/run.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { run };
|
|
2
2
|
import type { TolerateError } from './Logs/isTolerateError.js';
|
|
3
|
-
declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, verbose, cwd, tolerateError, serverUrl, isFlaky, }?: {
|
|
3
|
+
declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, verbose, cwd, tolerateError, serverUrl, isFlaky, tolerateExitCode, }?: {
|
|
4
4
|
additionalTimeout?: number;
|
|
5
5
|
serverIsReadyMessage?: string | ((log: string) => boolean);
|
|
6
6
|
serverIsReadyDelay?: number;
|
|
@@ -11,4 +11,5 @@ declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, ser
|
|
|
11
11
|
tolerateError?: TolerateError;
|
|
12
12
|
serverUrl?: string;
|
|
13
13
|
isFlaky?: boolean;
|
|
14
|
+
tolerateExitCode?: number[];
|
|
14
15
|
}): void;
|
package/dist/run.js
CHANGED
|
@@ -8,7 +8,7 @@ import { page } from './page.js';
|
|
|
8
8
|
import { TIMEOUT_NPM_SCRIPT, TIMEOUT_PLAYWRIGHT, TIMEOUT_PROCESS_TERMINATION } from './TIMEOUTS.js';
|
|
9
9
|
function run(cmd, {
|
|
10
10
|
//baseUrl = '',
|
|
11
|
-
additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = cliOptions.inspect, verbose = cliOptions.verbose, cwd, tolerateError, serverUrl, isFlaky, } = {}) {
|
|
11
|
+
additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = cliOptions.inspect, verbose = cliOptions.verbose, cwd, tolerateError, serverUrl, isFlaky, tolerateExitCode, } = {}) {
|
|
12
12
|
assert(cwd === undefined);
|
|
13
13
|
additionalTimeout += serverIsReadyDelay;
|
|
14
14
|
setRunInfo({
|
|
@@ -32,6 +32,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
32
32
|
additionalTimeout,
|
|
33
33
|
serverIsReadyMessage,
|
|
34
34
|
serverIsReadyDelay,
|
|
35
|
+
tolerateExitCode,
|
|
35
36
|
});
|
|
36
37
|
page.on('console', onConsole);
|
|
37
38
|
page.on('pageerror', onPageError);
|
|
@@ -104,7 +105,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
async function startProcess({ serverIsReadyMessage, serverIsReadyDelay, additionalTimeout, cmd, }) {
|
|
108
|
+
async function startProcess({ serverIsReadyMessage, serverIsReadyDelay, additionalTimeout, cmd, tolerateExitCode, }) {
|
|
108
109
|
const cwd = getCwd();
|
|
109
110
|
if (!serverIsReadyMessage) {
|
|
110
111
|
serverIsReadyMessage = (log) => {
|
|
@@ -129,6 +130,7 @@ async function startProcess({ serverIsReadyMessage, serverIsReadyDelay, addition
|
|
|
129
130
|
isReadyLog: serverIsReadyMessage,
|
|
130
131
|
isReadyTimeout: TIMEOUT_NPM_SCRIPT + additionalTimeout,
|
|
131
132
|
killPort: process.env.CI || !isLinux() ? false : getServerPort(),
|
|
133
|
+
tolerateExitCode,
|
|
132
134
|
onStderr(data, { loggedAfterExit }) {
|
|
133
135
|
Logs.add({
|
|
134
136
|
logSource: 'stderr',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { runCommandLongRunning };
|
|
2
|
-
declare function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout, onStdout, onStderr, onExit, onTerminationError, terminationTimeout, }: {
|
|
2
|
+
declare function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout, onStdout, onStderr, onExit, onTerminationError, terminationTimeout, tolerateExitCode, }: {
|
|
3
3
|
cmd: string;
|
|
4
4
|
cwd: string;
|
|
5
5
|
killPort: false | number;
|
|
@@ -14,6 +14,7 @@ declare function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReady
|
|
|
14
14
|
onExit: (errMsg?: string) => void;
|
|
15
15
|
onTerminationError: (errMsg: string) => void;
|
|
16
16
|
terminationTimeout: number;
|
|
17
|
+
tolerateExitCode?: number[];
|
|
17
18
|
}): {
|
|
18
19
|
terminate: (force?: true) => Promise<void>;
|
|
19
20
|
isReadyPromise: Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { runCommandLongRunning };
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import stripAnsi from 'strip-ansi';
|
|
4
|
-
import { assert, runCommandShortLived, humanizeTime, isWindows, isLinux, isCallable } from '../utils.js';
|
|
5
|
-
function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout, onStdout, onStderr, onExit, onTerminationError, terminationTimeout, }) {
|
|
4
|
+
import { assert, runCommandShortLived, humanizeTime, isWindows, isLinux, isCallable, isMac } from '../utils.js';
|
|
5
|
+
function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout, onStdout, onStderr, onExit, onTerminationError, terminationTimeout, tolerateExitCode, }) {
|
|
6
6
|
if (killPort)
|
|
7
7
|
killByPort(killPort);
|
|
8
8
|
let onError;
|
|
@@ -82,7 +82,7 @@ function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout,
|
|
|
82
82
|
let errMsg;
|
|
83
83
|
{
|
|
84
84
|
const exitIsExpected = isReady === true || isReadyPromiseTimedOut;
|
|
85
|
-
if (!isSuccessCode(code)) {
|
|
85
|
+
if (!isSuccessCode(code, tolerateExitCode)) {
|
|
86
86
|
errMsg = `Unexpected termination of command \`${cmd}\` with exit code ${code}`;
|
|
87
87
|
}
|
|
88
88
|
else if (!exitIsExpected) {
|
|
@@ -219,8 +219,19 @@ async function killByPort(port) {
|
|
|
219
219
|
assert(port);
|
|
220
220
|
await runCommandShortLived(`fuser -k ${port}/tcp`, { swallowError: true, timeout: 10 * 1000 });
|
|
221
221
|
}
|
|
222
|
-
function isSuccessCode(code) {
|
|
223
|
-
|
|
222
|
+
function isSuccessCode(code, tolerateExitCode) {
|
|
223
|
+
if (code === 0 ||
|
|
224
|
+
code === null ||
|
|
225
|
+
// Exit code can be `1` on Windows on nominal exit — I don't know why
|
|
226
|
+
(code === 1 && isWindows()) ||
|
|
227
|
+
// Exit code can be `143` on MacOS on nominal exit — I don't know why
|
|
228
|
+
(code === 143 && isMac())) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
if (tolerateExitCode?.includes(code)) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
224
235
|
}
|
|
225
236
|
// Workaround for Node.js regression:
|
|
226
237
|
// - https://github.com/nodejs/node/issues/52475
|