mirror of
https://github.com/penpot/penpot.git
synced 2026-05-30 04:08:08 +00:00
* ⚡ Improve performance and fix orphan detection in validate-file - Add `*ref-shape-cache*` dynamic var to memoize `find-ref-shape` lookups per page, avoiding repeated O(depth) ancestor walks. - Add `*children-sets*` pre-computed maps for O(1) parent-child containment checks, replacing linear `some` scans. - Short-circuit `inside-component-main?` when the shape context already implies a main component. - Use single-pass reduce with early exit for duplicate detection (children, swap slots) instead of count/distinct or frequencies. - Guard `check-missing-slot` to skip expensive `find-near-match` when the shape already has a swap slot. - Refactor variant-set validation to use `run!` with direct `get`. - Refactor `check-ref-cycles` to use a single `reduce-kv` pass. - Fix `get-orphan-shapes`: the original `map` pipeline produced nils so orphan shapes were never validated; rewrite with `reduce-kv` for correct results. - Add `validate-file-affected!` for change-scoped validation, replacing full file validation in `process-changes-and-validate` to only validate pages and components touched by the changes. Signed-off-by: Andrey Antukh <niwi@niwi.nz> * ✨ Improved validation --------- Signed-off-by: Andrey Antukh <niwi@niwi.nz> Co-authored-by: alonso.torres <alonso.torres@kaleidos.net>
163 lines
5.8 KiB
Clojure
163 lines
5.8 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC
|
|
|
|
(ns common-tests.runner
|
|
(:require
|
|
#?(:clj [common-tests.fressian-test])
|
|
[clojure.test :as t]
|
|
[common-tests.attrs-test]
|
|
[common-tests.buffer-test]
|
|
[common-tests.colors-test]
|
|
[common-tests.data-test]
|
|
[common-tests.files-builder-test]
|
|
[common-tests.files-changes-test]
|
|
[common-tests.files-migrations-test]
|
|
[common-tests.files.shapes-builder-test]
|
|
[common-tests.files.validate-test]
|
|
[common-tests.geom-align-test]
|
|
[common-tests.geom-bounds-map-test]
|
|
[common-tests.geom-flex-layout-test]
|
|
[common-tests.geom-grid-layout-test]
|
|
[common-tests.geom-grid-test]
|
|
[common-tests.geom-line-test]
|
|
[common-tests.geom-modif-tree-test]
|
|
[common-tests.geom-modifiers-test]
|
|
[common-tests.geom-point-test]
|
|
[common-tests.geom-proportions-test]
|
|
[common-tests.geom-rect-test]
|
|
[common-tests.geom-shapes-common-test]
|
|
[common-tests.geom-shapes-constraints-test]
|
|
[common-tests.geom-shapes-corners-test]
|
|
[common-tests.geom-shapes-effects-test]
|
|
[common-tests.geom-shapes-intersect-test]
|
|
[common-tests.geom-shapes-strokes-test]
|
|
[common-tests.geom-shapes-test]
|
|
[common-tests.geom-shapes-text-test]
|
|
[common-tests.geom-shapes-tree-seq-test]
|
|
[common-tests.geom-snap-test]
|
|
[common-tests.geom-test]
|
|
[common-tests.logic.chained-propagation-test]
|
|
[common-tests.logic.comp-creation-test]
|
|
[common-tests.logic.comp-detach-with-nested-test]
|
|
[common-tests.logic.comp-remove-swap-slots-test]
|
|
[common-tests.logic.comp-reset-test]
|
|
[common-tests.logic.comp-sync-test]
|
|
[common-tests.logic.comp-touched-test]
|
|
[common-tests.logic.copying-and-duplicating-test]
|
|
[common-tests.logic.duplicated-pages-test]
|
|
[common-tests.logic.move-shapes-test]
|
|
[common-tests.logic.multiple-nesting-levels-test]
|
|
[common-tests.logic.swap-and-reset-test]
|
|
[common-tests.logic.swap-as-override-test]
|
|
[common-tests.logic.token-test]
|
|
[common-tests.logic.variants-switch-test]
|
|
[common-tests.media-test]
|
|
[common-tests.path-names-test]
|
|
[common-tests.record-test]
|
|
[common-tests.schema-test]
|
|
[common-tests.spec-test]
|
|
[common-tests.svg-path-test]
|
|
[common-tests.svg-test]
|
|
[common-tests.text-test]
|
|
[common-tests.time-test]
|
|
[common-tests.types.absorb-assets-test]
|
|
[common-tests.types.color-test]
|
|
[common-tests.types.components-test]
|
|
[common-tests.types.container-test]
|
|
[common-tests.types.fill-test]
|
|
[common-tests.types.modifiers-test]
|
|
[common-tests.types.objects-map-test]
|
|
[common-tests.types.path-data-test]
|
|
[common-tests.types.shape-decode-encode-test]
|
|
[common-tests.types.shape-interactions-test]
|
|
[common-tests.types.shape-layout-test]
|
|
[common-tests.types.token-test]
|
|
[common-tests.types.tokens-lib-test]
|
|
[common-tests.undo-stack-test]
|
|
[common-tests.uuid-test]))
|
|
|
|
#?(:cljs (enable-console-print!))
|
|
|
|
#?(:cljs
|
|
(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
|
|
(if (cljs.test/successful? m)
|
|
(.exit js/process 0)
|
|
(.exit js/process 1))))
|
|
|
|
(defn -main
|
|
[& args]
|
|
(t/run-tests
|
|
'common-tests.attrs-test
|
|
'common-tests.buffer-test
|
|
'common-tests.colors-test
|
|
'common-tests.data-test
|
|
#?(:clj 'common-tests.fressian-test)
|
|
'common-tests.files-changes-test
|
|
'common-tests.files-builder-test
|
|
'common-tests.files-migrations-test
|
|
'common-tests.files.validate-test
|
|
'common-tests.geom-align-test
|
|
'common-tests.geom-bounds-map-test
|
|
'common-tests.geom-flex-layout-test
|
|
'common-tests.geom-grid-layout-test
|
|
'common-tests.geom-grid-test
|
|
'common-tests.geom-line-test
|
|
'common-tests.geom-modif-tree-test
|
|
'common-tests.geom-modifiers-test
|
|
'common-tests.geom-point-test
|
|
'common-tests.geom-proportions-test
|
|
'common-tests.geom-rect-test
|
|
'common-tests.geom-shapes-common-test
|
|
'common-tests.geom-shapes-constraints-test
|
|
'common-tests.geom-shapes-corners-test
|
|
'common-tests.geom-shapes-effects-test
|
|
'common-tests.geom-shapes-intersect-test
|
|
'common-tests.geom-shapes-strokes-test
|
|
'common-tests.geom-shapes-test
|
|
'common-tests.geom-shapes-text-test
|
|
'common-tests.geom-shapes-tree-seq-test
|
|
'common-tests.geom-snap-test
|
|
'common-tests.geom-test
|
|
'common-tests.logic.chained-propagation-test
|
|
'common-tests.logic.comp-creation-test
|
|
'common-tests.logic.comp-detach-with-nested-test
|
|
'common-tests.logic.comp-remove-swap-slots-test
|
|
'common-tests.logic.comp-reset-test
|
|
'common-tests.logic.comp-sync-test
|
|
'common-tests.logic.comp-touched-test
|
|
'common-tests.logic.copying-and-duplicating-test
|
|
'common-tests.logic.duplicated-pages-test
|
|
'common-tests.logic.move-shapes-test
|
|
'common-tests.logic.multiple-nesting-levels-test
|
|
'common-tests.logic.swap-and-reset-test
|
|
'common-tests.logic.swap-as-override-test
|
|
'common-tests.logic.token-test
|
|
'common-tests.logic.variants-switch-test
|
|
'common-tests.media-test
|
|
'common-tests.path-names-test
|
|
'common-tests.record-test
|
|
'common-tests.schema-test
|
|
'common-tests.spec-test
|
|
'common-tests.svg-path-test
|
|
'common-tests.svg-test
|
|
'common-tests.text-test
|
|
'common-tests.time-test
|
|
'common-tests.types.absorb-assets-test
|
|
'common-tests.types.color-test
|
|
'common-tests.types.components-test
|
|
'common-tests.types.container-test
|
|
'common-tests.types.fill-test
|
|
'common-tests.types.modifiers-test
|
|
'common-tests.types.objects-map-test
|
|
'common-tests.types.path-data-test
|
|
'common-tests.types.shape-decode-encode-test
|
|
'common-tests.types.shape-interactions-test
|
|
'common-tests.types.shape-layout-test
|
|
'common-tests.types.token-test
|
|
'common-tests.types.tokens-lib-test
|
|
'common-tests.undo-stack-test
|
|
'common-tests.uuid-test))
|