Skip to content

Commit 9323138

Browse files
committed
refactor: inline single-caller wrapper helpers
1 parent e88f9ad commit 9323138

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

src/unitest.gleam

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,13 @@ pub fn resolve_cli_action(args: List(String)) -> CliAction {
479479
case parse_cli_args(args) {
480480
Ok(cli_opts) -> RunWithCliOptions(cli_opts)
481481
Error(message) ->
482-
case wants_help(args) {
482+
case list.contains(args, "--help") || list.contains(args, "-h") {
483483
True -> ShowCliMessage(message, 0)
484484
False -> ShowCliMessage(message, 1)
485485
}
486486
}
487487
}
488488

489-
fn wants_help(args: List(String)) -> Bool {
490-
list.contains(args, "--help") || list.contains(args, "-h")
491-
}
492-
493489
@internal
494490
pub fn render_table(
495491
results: List(TestResult),

src/unitest_ffi.mjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import { from_dynamic as decodeTestRunResult } from "./unitest/internal/outcome.
1313
// backstop) from racing that and terminating a worker that was about to report.
1414
const WORKER_WATCHDOG_GRACE_MS = 100;
1515

16-
function formatError(err) {
17-
return err == null ? String(err) : err.message || String(err);
18-
}
19-
2016
function makeGenericError(message) {
2117
return decodeTestRunResult({ kind: "error", message });
2218
}
@@ -26,7 +22,7 @@ function crashedOutcome(error) {
2622
kind: "error",
2723
failureKind: {
2824
type: "crashed",
29-
reason: formatError(error),
25+
reason: error == null ? String(error) : error.message || String(error),
3026
stack: parseStack(error),
3127
},
3228
});
@@ -345,10 +341,6 @@ function startWithWorkerThreads(
345341
});
346342
}
347343

348-
function isAsyncTimeoutResult(result) {
349-
return result?.failureKind?.type === "timeout";
350-
}
351-
352344
function recycleWorker(w) {
353345
w._done = true;
354346
w.terminate();
@@ -414,7 +406,7 @@ function startWithWorkerThreads(
414406
),
415407
);
416408
}
417-
if (isAsyncTimeoutResult(msg.result)) {
409+
if (msg.result?.failureKind?.type === "timeout") {
418410
// Promise.race cannot cancel the losing test; it is still running
419411
// inside this worker. Recycle the worker so its side effects cannot
420412
// interfere with later tests. Deliberate, so it does not count

0 commit comments

Comments
 (0)