mirror of
https://github.com/penpot/penpot.git
synced 2026-11-23 19:00:36 +00:00
👷 Run the generative component tests apart from CI
The random component program properties of `composable-gen-test` (`random-compositions`, `random-structure-compositions` and the other nine `random-*` tests) ran in every common test run, on the JVM with 100 programs each and in JS with 15. They are now tagged `:generative` and left out of the default runs, so CI runs only the unit tests. - `tests.edn` skips `:generative`; `tests-generative.edn` runs only it: `pnpm run test:generative`. - The JS runner leaves them out of the full run; `--generative` runs only them: `pnpm run test:generative:js`. A `--focus` still runs a focused one. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
c5c60e466b
commit
1380d49da8
@ -22,6 +22,15 @@ From `common/`:
|
||||
- Build JS test target only (no run): `pnpm run build:test`
|
||||
- After `build:test` has been run, run the compiled runner directly: `node target/tests/test.js [--focus ...] [--log-level ...]`.
|
||||
|
||||
The full runs above (and CI) leave out the generative tests: the `random-*`
|
||||
properties of `composable-gen-test`, tagged `^:generative`, which run random
|
||||
component programs and take most of the time. Run them on their own:
|
||||
- JVM: `pnpm run test:generative` (`clojure -M:dev:test --config-file tests-generative.edn`);
|
||||
add `--focus common-tests.logic.composable-gen-test/random-grid-compositions` for one.
|
||||
A `--focus` on one of them without `--config-file tests-generative.edn` skips it.
|
||||
- JS: `pnpm run test:generative:js` (`node target/tests/test.js --generative`);
|
||||
a JS `--focus` on one of them runs it.
|
||||
|
||||
New common JS test namespaces must be required/listed in `common_tests/runner.cljc`;
|
||||
new vars in existing namespaces need no runner change. Multiple JVM `--focus` flags
|
||||
compose as a union.
|
||||
@ -112,8 +121,10 @@ The regression rejects a 1e-5 height change and a 5e-15 opacity change.
|
||||
## Generated component programs
|
||||
|
||||
`composable/gen` builds seeded EDN programs and resolves targets from current
|
||||
shape-tree order. Run `common-tests.logic.composable-gen-test`; set
|
||||
`PENPOT_GEN_NUM` and `PENPOT_GEN_SEED` to replay a count and seed. Before merge,
|
||||
shape-tree order. Run the random properties with `pnpm run test:generative`
|
||||
(they are not part of the default run or CI); set `PENPOT_GEN_NUM` and
|
||||
`PENPOT_GEN_SEED` to replay a count and seed. Their coverage checks need the
|
||||
default number of programs; with very few they fail on insufficient coverage. Before merge,
|
||||
Phase 4 requires 5000 scenarios per property. `cg/run` accepts the printed
|
||||
program and an optional expected trace; changed targets or skips fail replay.
|
||||
Use separate fresh JVMs for concurrent checks: `world` resets the global test
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
"watch:test": "concurrently \"clojure -M:dev:shadow-cljs watch test\" \"nodemon -C -d 2 -w target/tests/ --exec 'node target/tests/test.js'\"",
|
||||
"build:test": "clojure -M:dev:shadow-cljs compile test",
|
||||
"test": "pnpm run build:test && node target/tests/test.js",
|
||||
"test:quiet": "node ./scripts/test-quiet.js"
|
||||
"test:quiet": "node ./scripts/test-quiet.js",
|
||||
"test:generative": "clojure -M:dev:test --config-file tests-generative.edn",
|
||||
"test:generative:js": "node ./scripts/test-quiet.js --generative"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1606,7 +1606,7 @@
|
||||
#?(:clj (apply cg/coverage-errors args)
|
||||
:cljs (do args [])))
|
||||
|
||||
(t/deftest random-compositions
|
||||
(t/deftest ^:generative random-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -1618,7 +1618,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage [:edit :reset :update-main :detach :sync :undo :redo]))
|
||||
(pr-str (coverage-errors @coverage [:edit :reset :update-main :detach :sync :undo :redo])))))
|
||||
|
||||
(t/deftest random-structure-compositions
|
||||
(t/deftest ^:generative random-structure-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -1668,7 +1668,7 @@
|
||||
(t/is (some? index))
|
||||
(t/is (= (not differ?) (boolean (some #{:fill-group} groups)))))))
|
||||
|
||||
(t/deftest random-swap-compositions
|
||||
(t/deftest ^:generative random-swap-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2349,7 +2349,7 @@
|
||||
:ops [[:make-variant 1] [:switch 11] [:make-variant 2] [:switch 10] [:swap 1 0 0 0]
|
||||
[:update-main 0 0 0 0]]}))))
|
||||
|
||||
(t/deftest random-variant-compositions
|
||||
(t/deftest ^:generative random-variant-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2761,7 +2761,7 @@
|
||||
:layout-copies false :layout-children false}]
|
||||
:ops [[:delete] [:swap] [:add-child 1] [:structure] [:structure 4 0 1] [:structure 2 5 3]]}))))
|
||||
|
||||
(t/deftest random-shape-structure-compositions
|
||||
(t/deftest ^:generative random-shape-structure-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2773,7 +2773,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage cg/shape-structure-coverage-kinds))
|
||||
(pr-str (coverage-errors @coverage cg/shape-structure-coverage-kinds)))))
|
||||
|
||||
(t/deftest random-grid-compositions
|
||||
(t/deftest ^:generative random-grid-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2785,7 +2785,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage cg/grid-coverage-kinds))
|
||||
(pr-str (coverage-errors @coverage cg/grid-coverage-kinds)))))
|
||||
|
||||
(t/deftest random-token-compositions
|
||||
(t/deftest ^:generative random-token-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2797,7 +2797,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage cg/token-coverage-kinds))
|
||||
(pr-str (coverage-errors @coverage cg/token-coverage-kinds)))))
|
||||
|
||||
(t/deftest random-scale-compositions
|
||||
(t/deftest ^:generative random-scale-compositions
|
||||
;; scale programs run several times longer than the others; the gates draw more
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
@ -2860,7 +2860,7 @@
|
||||
[:library-text-style 19 0 1] [:library-delete 0 0 0 0]
|
||||
[:library-variant-property 0 0 0 0] [:library-sync] [:switch 19]]}))))
|
||||
|
||||
(t/deftest random-library-compositions
|
||||
(t/deftest ^:generative random-library-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2872,7 +2872,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage cg/library-kinds))
|
||||
(pr-str (coverage-errors @coverage cg/library-kinds)))))
|
||||
|
||||
(t/deftest random-stale-library-compositions
|
||||
(t/deftest ^:generative random-stale-library-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
@ -2884,7 +2884,7 @@
|
||||
(t/is (empty? (coverage-errors @coverage cg/stale-library-coverage-kinds #{:sync}))
|
||||
(pr-str (coverage-errors @coverage cg/stale-library-coverage-kinds #{:sync})))))
|
||||
|
||||
(t/deftest random-library-dependency-compositions
|
||||
(t/deftest ^:generative random-library-dependency-compositions
|
||||
(let [coverage (atom {})
|
||||
failure (atom nil)]
|
||||
(smt/check!
|
||||
|
||||
@ -340,6 +340,7 @@
|
||||
|
||||
(def cli-options
|
||||
[["-f" "--focus FOCUS" "Run one test namespace or one test var, e.g. common-tests.logic.comp-sync-test/test-sync-when-changing-attribute"]
|
||||
["-g" "--generative" "Run only the generative tests (random component programs), which the default run leaves out"]
|
||||
["-l" "--log-level LEVEL" "Set app logger level: trace|debug|info|warn|error"
|
||||
:parse-fn keyword
|
||||
:validate [log-levels "must be one of trace, debug, info, warn, error"]]
|
||||
@ -361,6 +362,8 @@
|
||||
"Focus examples:\n"
|
||||
" pnpm run test:js -- --focus common-tests.logic.comp-sync-test\n"
|
||||
" pnpm run test:js -- --focus common-tests.logic.comp-sync-test/test-sync-when-changing-attribute\n\n"
|
||||
"Generative tests (left out of the default run):\n"
|
||||
" pnpm run test:generative:js\n\n"
|
||||
"Log level example (quiets app logging during the run):\n"
|
||||
" pnpm run test:js -- --focus common-tests.logic.comp-sync-test --log-level warn"))
|
||||
|
||||
@ -456,9 +459,25 @@
|
||||
[focus]
|
||||
(run-test-vars! [(selected-tests (parse-focus focus))]))
|
||||
|
||||
(defn- select-vars
|
||||
"Keep in each of `tests` only the vars `pred` accepts, dropping the
|
||||
namespaces left without any."
|
||||
[pred tests]
|
||||
(->> tests
|
||||
(map #(update % :vars (partial filterv pred)))
|
||||
(filter (comp seq :vars))))
|
||||
|
||||
(defn- generative?
|
||||
[test-var]
|
||||
(true? (:generative (meta test-var))))
|
||||
|
||||
(defn- run-all-tests!
|
||||
[]
|
||||
(run-test-vars! (map #(selected-tests {:ns %}) test-namespaces)))))
|
||||
"Run every test but the generative ones, or only those with
|
||||
`generative-only?`."
|
||||
[generative-only?]
|
||||
(run-test-vars!
|
||||
(select-vars (if generative-only? generative? (complement generative?))
|
||||
(map #(selected-tests {:ns %}) test-namespaces))))))
|
||||
|
||||
(defn -main
|
||||
[& _args]
|
||||
@ -479,6 +498,6 @@
|
||||
(l/setup! {:app level}))
|
||||
(if (:focus options)
|
||||
(run-focused-test! (:focus options))
|
||||
(run-all-tests!)))))
|
||||
(run-all-tests! (:generative options))))))
|
||||
:clj
|
||||
(apply t/run-tests test-namespaces)))
|
||||
|
||||
5
common/tests-generative.edn
Normal file
5
common/tests-generative.edn
Normal file
@ -0,0 +1,5 @@
|
||||
#kaocha/v1
|
||||
{:tests [{:id :generative
|
||||
:test-paths ["test"]
|
||||
:focus-meta [:generative]}]
|
||||
:kaocha/reporter [kaocha.report/dots]}
|
||||
@ -1,6 +1,8 @@
|
||||
#kaocha/v1
|
||||
{:tests [{:id :unit
|
||||
:test-paths ["test"]}]
|
||||
:test-paths ["test"]
|
||||
;; The random component programs run on their own: tests-generative.edn
|
||||
:skip-meta [:generative]}]
|
||||
:kaocha/reporter [kaocha.report/dots]
|
||||
|
||||
;; Only read when the cloverage plugin is on (`:coverage` alias).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user