From 970373f100a5168a80ad487d6d2836916b34210e Mon Sep 17 00:00:00 2001 From: Miguel de Benito Delgado Date: Sun, 1 Nov 2026 11:05:25 +0100 Subject: [PATCH] :sparkles: Fix error msg in ab command --- .../benches/render_wasm/node/run.cljs | 40 ++++++++++--------- .../benches/render_wasm/node/runner.cljs | 8 ++-- .../render_wasm/runner_test.cljs | 10 +++++ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/frontend/performance/benches/render_wasm/node/run.cljs b/frontend/performance/benches/render_wasm/node/run.cljs index c222ec18ea..a224040602 100644 --- a/frontend/performance/benches/render_wasm/node/run.cljs +++ b/frontend/performance/benches/render_wasm/node/run.cljs @@ -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. diff --git a/frontend/performance/benches/render_wasm/node/runner.cljs b/frontend/performance/benches/render_wasm/node/runner.cljs index 128a2db07e..81e7f3ac08 100644 --- a/frontend/performance/benches/render_wasm/node/runner.cljs +++ b/frontend/performance/benches/render_wasm/node/runner.cljs @@ -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)) diff --git a/frontend/test/performance_tests/render_wasm/runner_test.cljs b/frontend/test/performance_tests/render_wasm/runner_test.cljs index 56d36a2fbf..82d5d98a00 100644 --- a/frontend/test/performance_tests/render_wasm/runner_test.cljs +++ b/frontend/test/performance_tests/render_wasm/runner_test.cljs @@ -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"]))))