✨ Fix error msg in ab command

This commit is contained in:
Miguel de Benito Delgado 2026-11-01 11:05:25 +01:00
parent a50e234b10
commit 970373f100
3 changed files with 36 additions and 22 deletions

View File

@ -5,15 +5,19 @@
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns benches.render-wasm.node.run
"Serial renderer benchmark runs over a retained build.
"Renderer benchmark runs over fixed builds.
One run owns one run home, one loopback host and at most one Chromium process.
Fresh cases prepare once per slot on a new page/context. Reuse cases prepare
once and run every slot on that page/context. A failed attempt consumes its
slot. Browser failures leave the current case's remaining slots unattempted
and continue with the next case in a new browser. The run record is atomically
replaced after every preparation, attempt and diagnostic change."
(:require-macros
Runs are stored in a `home`, and execute via a loopback host and at most one
Chromium process.
`:fresh` cases prepare once per slot on a new page and context.
`:reuse` cases prepare once and run every slot on the same page and context.
A failed attempt consumes its slot.
Browser failures leave the current case's remaining slots unattempted and
continue with the next case in a new browser."
(:require-macros3
[app.common.exceptions :as ex])
(:require
["module" :as node-module]
@ -469,16 +473,6 @@
(or outcome :abandon)))))
(defn- ^:async launch-initial
[state]
(let [owner (attempt (await (ensure-browser state)))]
(reset! (:launch-deadline state) nil)
(when (failure? owner)
(when-not (interrupted? state)
(record-failure state nil :browser-launch (cause-evidence owner :browser-launch)))
(reset! (:abort-run? state) true))
(not (failure? owner))))
(defn- fail-startup
"Records the startup failure and aborts the run. An interrupted run records
nothing. Returns false."
@ -488,6 +482,14 @@
(reset! (:abort-run? state) true))
false)
(defn- ^:async launch-initial
[state]
(let [owner (attempt (await (ensure-browser state)))]
(reset! (:launch-deadline state) nil)
(if (failure? owner)
(fail-startup state :browser-launch owner)
true)))
(defn- ^:async record-provenance
[state deadline]
(let [git (attempt (await (build/git-provenance (:root state)
@ -764,7 +766,7 @@
:exit-code (get-exit-code run causes @(:harness-failed? state))}))
(defn ^:async execute
"Executes a prepared selection in an allocated home and owns host and browser.
"Executes a prepared selection. Owns host and browser.
- `root`: the frontend checkout root.
- `home`: the reserved output home.

View File

@ -189,8 +189,10 @@
"--allow-all-differences"})
(defn- invalid-args
[message]
(throw (ex-info message {:type ::invalid-args})))
([message]
(invalid-args message nil))
([message cause]
(throw (ex-info message {:type ::invalid-args} cause))))
(defn- some-flags?
[flags group]
@ -287,7 +289,7 @@
(try
(feature-plan/plan (:features options []) options)
(catch :default cause
(invalid-args (ex-message cause))))))
(invalid-args (errors/message-of cause) cause)))))
{:command command
:arguments arguments
:options (cond-> options (= command "ab") (assoc :default-features false))

View File

@ -285,6 +285,16 @@
(runner/parse-args ["ab" "--features" "a" "--only-comparisons"])))
(t/is (thrown? js/Error (runner/parse-args ["ab" "extra" "--features" "a" "--dry-run"]))))
(t/deftest ab-planning-errors-keep-their-cause
(let [error (try
(runner/parse-args ["ab" "--dry-run"])
nil
(catch :default cause cause))]
(t/is (= :benches.render-wasm.node.runner/invalid-args
(:type (ex-data error))))
(t/is (some? (ex-cause error)))
(t/is (str/includes? (ex-message (ex-cause error)) "at least one"))))
(t/deftest ab-limits-and-confirmation-apply-at-the-parser-boundary
(t/is (thrown-with-msg? js/Error #"requires --confirm" (runner/parse-args ["ab" "--features" "a"])))
(t/is (:confirm (:options (runner/parse-args ["ab" "--features" "a" "--confirm"]))))