From 9083f5e232cc7a54554a2cef63c49b7e6d2cfe96 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 23 Oct 2026 09:34:33 +0200 Subject: [PATCH] :bug: Accept zero and negative property-test environment seeds Require an integer seed while retaining positive counts. Seed zero is a valid test.check replay seed and must behave like the explicit option. Validation: PENPOT_GEN_SEED=0 schema and runner suites pass, 44 tests / 119 assertions. The regression failed before the fix. AI-assisted-by: GPT-6 --- common/src/app/common/schema/test.cljc | 7 ++++--- common/test/common_tests/schema_check_test.cljc | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/schema/test.cljc b/common/src/app/common/schema/test.cljc index 446c0c3003..bdfcd79d62 100644 --- a/common/src/app/common/schema/test.cljc +++ b/common/src/app/common/schema/test.cljc @@ -94,9 +94,10 @@ [name] (when-let [value #?(:clj (System/getenv name) :cljs (some-> js/globalThis .-process .-env (aget name)))] - (let [number #?(:clj (parse-long value) :cljs (js/Number value))] - (when-not (and (integer? number) (pos? number)) - (throw (ex-info (str name " must be a positive integer") + (let [number #?(:clj (parse-long value) :cljs (js/Number value)) + seed? (= name "PENPOT_GEN_SEED")] + (when-not (and (integer? number) (or seed? (pos? number))) + (throw (ex-info (str name (if seed? " must be an integer" " must be a positive integer")) {:variable name :value value}))) number))) diff --git a/common/test/common_tests/schema_check_test.cljc b/common/test/common_tests/schema_check_test.cljc index 6cceb58d41..59ad2a741f 100644 --- a/common/test/common_tests/schema_check_test.cljc +++ b/common/test/common_tests/schema_check_test.cljc @@ -29,3 +29,13 @@ {:type :shrunk :seed 712 :shrunk {:smallest [10]}}))] (t/is (str/includes? output "712")) (t/is (str/includes? output ":smallest [10]")))) + +(t/deftest check-uses-the-environment-seed + (let [seed (atom nil) + expected #?(:clj (some-> (System/getenv "PENPOT_GEN_SEED") parse-long) + :cljs (some-> js/globalThis .-process .-env .-PENPOT_GEN_SEED js/Number))] + (smt/check! (smt/for [value gen/nat] (<= 0 value)) + :num 1 + :reporter-fn #(when (= :complete (:type %)) (reset! seed (:seed %)))) + (when (some? expected) + (t/is (= expected @seed)))))