Skip to content

Commit

Permalink
Revert "Extracted test code from the 'changes' component to 'test'. (#…
Browse files Browse the repository at this point in the history
…449)" (#450)

This reverts commit 43416d9.
  • Loading branch information
tengstrand authored Mar 14, 2024
1 parent 43416d9 commit 68b7739
Show file tree
Hide file tree
Showing 25 changed files with 256 additions and 341 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns ^:no-doc polylith.clj.core.test.bricks-to-test
(ns ^:no-doc polylith.clj.core.change.bricks-to-test
(:require [clojure.set :as set]
[polylith.clj.core.common.interface :as common]))

Expand Down
21 changes: 16 additions & 5 deletions components/change/src/polylith/clj/core/change/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
(:require [clojure.set :as set]
[polylith.clj.core.change.entity :as entity]
[polylith.clj.core.change.indirect-changes :as indirect-changes]
[polylith.clj.core.change.bricks-to-test :as bricks-to-test]
[polylith.clj.core.change.projects-to-test :as projects-to-test]
[polylith.clj.core.common.interface :as common]
[polylith.clj.core.git.interface :as git]
[polylith.clj.core.util.interface :as util]))
Expand All @@ -19,6 +21,10 @@
(vec (sort (map :name (filter #(project-affected? % changed-components changed-bases changed-projects)
projects)))))

(defn nothing-to-test [project]
(assoc project :bricks-to-test []
:projects-to-test []))

(defn with-changes [{:keys [ws-dir ws-local-dir user-input settings projects paths] :as workspace}]
(if (common/invalid-workspace? workspace)
workspace
Expand All @@ -27,19 +33,24 @@
:changed-components []
:changed-bases []
:changed-projects []
:changed-or-affected-projects []})
:changed-or-affected-projects []}
:projects (mapv nothing-to-test projects))
(let [{:keys [since changed-files is-no-changes]
:or {since "stable"}} user-input
tag-patterns (:tag-patterns settings)
{:keys [tag sha]} (git/sha ws-dir since tag-patterns)
files (git/diff ws-dir ws-local-dir is-no-changes changed-files sha nil)]
(let [{:keys [changed-components
(let [{:keys [is-dev is-all is-run-all-brick-tests is-run-project-tests selected-bricks selected-projects]} user-input
{:keys [changed-components
changed-bases
changed-projects]} (entity/changed-entities files paths)
changed-bricks (set (concat changed-components changed-bases))
affected-projects (affected-projects projects changed-components changed-bases changed-projects)
projects-with-changes (mapv #(indirect-changes/with-indirect-changes % changed-bricks)
projects)
projects-with-keys (mapv #(-> %
(indirect-changes/with-indirect-changes changed-bricks)
(bricks-to-test/with-bricks-to-test changed-projects changed-components changed-bases selected-bricks selected-projects is-dev is-run-all-brick-tests)
(projects-to-test/with-projects-to-test paths affected-projects selected-projects is-dev is-run-project-tests is-all))
projects)
changes (util/ordered-map :since since
:since-sha sha
:since-tag tag
Expand All @@ -50,4 +61,4 @@
:changed-projects changed-projects
:changed-or-affected-projects affected-projects)]
(assoc workspace :changes changes
:projects projects-with-changes))))))
:projects projects-with-keys))))))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns ^:no-doc polylith.clj.core.test.projects-to-test
(ns ^:no-doc polylith.clj.core.change.projects-to-test
(:require [clojure.set :as set]
[polylith.clj.core.path-finder.interface.criterias :as c]
[polylith.clj.core.path-finder.interface.select :as select]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns polylith.clj.core.test.bricks-to-test-test
(ns polylith.clj.core.change.bricks-to-test-test
(:require [clojure.test :refer :all]
[polylith.clj.core.test.bricks-to-test :as to-test]
[polylith.clj.core.test.test-data :as data])
[polylith.clj.core.change.bricks-to-test :as to-test]
[polylith.clj.core.change.test-data :as data])
(:refer-clojure :exclude [test]))

(defn test [{:keys [changed-projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
(deftest changed-projects--when-two-of-three-projects-contain-changed-bricks--return-the-projects-with-then-changed-bricks
(is (= #{"core" "dev"}
(project/indirectly-changed-project-names projects changed-bricks))))

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns polylith.clj.core.test.projects-to-test-test
(ns polylith.clj.core.change.projects-to-test-test
(:require [clojure.test :refer :all]
[polylith.clj.core.test.projects-to-test :as t]))
[polylith.clj.core.change.projects-to-test :as t]))

(deftest run-tests?--dont-run-project-tests-by-default
(is (false?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns polylith.clj.core.test.test-data
(ns polylith.clj.core.change.test-data
(:require [clojure.test :refer :all]))

(def dev {:is-dev true
Expand Down
4 changes: 2 additions & 2 deletions components/deps/src/polylith/clj/core/deps/interface.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
(defn base-deps [bases base suffixed-top-ns]
(base-deps/base-deps bases base suffixed-top-ns))

(defn project-deps [workspaces components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test]
(project-brick-deps/project-deps workspaces components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test))
(defn project-deps [components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test]
(project-brick-deps/project-deps components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test))

(defn print-brick-project-table [workspace project-name brick-name]
(brick-project-deps-table/print-table workspace project-name brick-name))
Expand Down
22 changes: 6 additions & 16 deletions components/deps/src/polylith/clj/core/deps/project_brick_deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@
both the src and the test context, and make all the calculations for us.
If a brick is only included in the test context for the project, then we treat all dependencies as test dependencies."
[brick brick-id->deps ifc->comp all-brick-ids brick-ids-in-project brick-ids-in-project-test test-only-brick-ids brick-ids-to-check]
[brick brick-id->deps ifc->comp all-brick-ids brick-ids-in-project brick-ids-in-project-test test-only-brick-ids brick-ids-to-test]
(let [src-brick-id (->brick-id brick)
test-brick-id (str src-brick-id " (t)")
src-deps (finalize-deps src-brick-id brick-id->deps ifc->comp all-brick-ids brick-ids-in-project nil)
test-deps (finalize-deps test-brick-id brick-id->deps ifc->comp all-brick-ids brick-ids-in-project-test brick-ids-to-check)]
test-deps (finalize-deps test-brick-id brick-id->deps ifc->comp all-brick-ids brick-ids-in-project-test brick-ids-to-test)]
(if (contains? test-only-brick-ids src-brick-id)
{:src {}
:test (merge-deps src-deps test-deps)}
Expand All @@ -239,8 +239,8 @@
(set (map #(name->brick-id % %) bricks-to-test)))))

(defn project-deps
[workspaces components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test]
"Calculates the src and test dependencies for a project. The returned dependencies
[components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test]
"Calculate the src and test dependencies for a project. The returned dependencies
are stored in a map with a :src and :test key and includes a key for each brick that is included
in the project, together with the direct, indirect, and circular dependencies (if any) +
missing dependencies on interfaces and bases (if any).
Expand Down Expand Up @@ -281,16 +281,6 @@
:aliases > :test > :extra-paths syntax is only needed for the development project if your IDE doesn't support
the :local/root syntax.
The recommendation is to use the :local/root syntax in all your projects if it's supported by your IDE."
; (def workspaces workspaces)
; (def components components)
; (def bases bases)
; (def poly-bases bases)
; (def component-names-src component-names-src)
; (def component-names-test component-names-test)
; (def base-names-src base-names-src)
; (def base-names-test base-names-test)
; (def suffixed-top-ns suffixed-top-ns)
; (def brick-names-to-test brick-names-to-test)
(let [brick-names (set (concat component-names-src component-names-test base-names-src base-names-test))
bricks (filter #(contains? brick-names (:name %))
(concat bases components))
Expand All @@ -300,7 +290,7 @@
(concat components
(filter #(contains? component-names (:name %))
components))))
brick-ids-to-check (brick-names-to-ids brick-names-to-test components)
brick-ids-to-test (brick-names-to-ids brick-names-to-test components)
all-brick-ids (set (concat (map #(-> % :interface :name) components)
(map :name bases)))
brick-ids-in-project-src (brick-ids-in-project component-names-src base-names-src bricks)
Expand All @@ -327,5 +317,5 @@
(doseq [brick-id (brick-id->brick-ids test-brick-id)]
(update-deps! test-brick-id brick-id brick-id->brick-ids brick-id->deps #{test-brick-id}))))
;; Step 2: For each brick, convert interface names to component names + calculate missing and circular dependencies.
(into {} (map (juxt :name #(brick-deps % @brick-id->deps ifc->comp all-brick-ids brick-ids-in-project-src brick-ids-in-project-test test-only-brick-ids brick-ids-to-check))
(into {} (map (juxt :name #(brick-deps % @brick-id->deps ifc->comp all-brick-ids brick-ids-in-project-src brick-ids-in-project-test test-only-brick-ids brick-ids-to-test))
bricks))))
4 changes: 0 additions & 4 deletions components/test/deps.edn

This file was deleted.

21 changes: 0 additions & 21 deletions components/test/src/polylith/clj/core/test/core.clj

This file was deleted.

7 changes: 0 additions & 7 deletions components/test/src/polylith/clj/core/test/interface.clj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(def minor 2)
(def patch 20)
(def revision SNAPSHOT) ;; Set to SNAPSHOT or RELEASE.
(def snapshot 7) ;; Increase by one for every snapshot release, or set to 0 if a release.
(def snapshot 6) ;; Increase by one for every snapshot release, or set to 0 if a release.
;; Also update :snapshot-version: at the top of readme.adoc.
(def snapshot? (= SNAPSHOT revision))

Expand All @@ -37,7 +37,7 @@

(def tool (if system/extended? "polyx" "poly"))

(def date "2024-03-12")
(def date "2024-03-06")

;; Execute 'poly doc version' to see when different changes was introduced.
(def api-version {:breaking 1, :non-breaking 0})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[polylith.clj.core.file.interface :as file]
[polylith.clj.core.workspace.enrich.core :as enrich]
[polylith.clj.core.change.interface :as change]
[polylith.clj.core.test.interface :as test]
[polylith.clj.core.workspace.fromdisk.core :as fromdisk]
[polylith.clj.core.ws-file.interface :as ws-file]))

Expand Down Expand Up @@ -55,8 +54,7 @@
@wsdir->workspace))]
(-> workspace
(enrich/enrich-workspace workspaces)
(change/with-changes)
(test/with-test-calculations)))))))
(change/with-changes)))))))

(comment
(require '[polylith.clj.core.user-input.interface :as user-input])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
brick->loc (brick->loc enriched-bricks)
brick->lib-imports (brick->lib-imports enriched-bricks)
alias-id (atom 0)
enriched-projects (vec (sort-by project-sorter (mapv #(project/enrich-project % ws-dir alias-id workspaces enriched-components enriched-bases profiles suffixed-top-ns brick->loc brick->lib-imports paths user-input settings name-type->keep-lib-versions outdated-libs library->latest-version) projects)))
enriched-projects (vec (sort-by project-sorter (mapv #(project/enrich-project % ws-dir alias-id enriched-components enriched-bases profiles suffixed-top-ns brick->loc brick->lib-imports paths user-input settings name-type->keep-lib-versions outdated-libs library->latest-version) projects)))
messages (validator/validate-ws suffixed-top-ns settings paths interface-names interfaces profiles enriched-components enriched-bases enriched-projects config-errors interface-ns workspaces user-input color-mode)]
(cond-> workspace
true (assoc :interfaces interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
(defn enrich-project [{:keys [alias name type is-dev test maven-repos namespaces paths lib-deps project-lib-deps] :as project}
ws-dir
alias-id
workspaces
components
bases
profiles
Expand Down Expand Up @@ -65,7 +64,7 @@
(seq base-names-test) (assoc :test base-names-test))
all-brick-names (concat component-names-src base-names-src component-names-test base-names-test)
brick-names-to-test (common/brick-names-to-test test all-brick-names)
deps (proj-deps/project-deps workspaces components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test)
deps (proj-deps/project-deps components bases component-names-src component-names-test base-names-src base-names-test suffixed-top-ns brick-names-to-test)
lib-imports (project-lib-imports all-brick-names brick->lib-imports)
lines-of-code-total (project-total-loc all-brick-names brick->loc)
lines-of-code (assoc (loc/lines-of-code ws-dir namespaces) :total lines-of-code-total)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
(select-keys (proj/enrich-project {:name project-name :is-dev dev?}
"."
(atom 0)
{}
components
bases
profiles
Expand Down Expand Up @@ -179,7 +178,6 @@
(dissoc (proj/enrich-project project
"."
(atom 0)
{}
components
bases
profiles
Expand Down Expand Up @@ -250,7 +248,6 @@
(dissoc (proj/enrich-project project
"."
(atom 0)
{}
components
bases
[{:name "default"
Expand Down
7 changes: 2 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
poly/sh {:local/root "components/sh"}
poly/shell {:local/root "components/shell"}
poly/tap {:local/root "components/tap"}
poly/test {:local/root "components/test"}
poly/test-helper {:local/root "components/test-helper"}
poly/test-runner-contract {:local/root "components/test-runner-contract"}
poly/test-runner-orchestrator {:local/root "components/test-runner-orchestrator"}
Expand All @@ -44,12 +43,10 @@
org.slf4j/slf4j-nop {:mvn/version "2.0.12"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.47"}}}

:+default {:extra-paths ["components/deps/test"]
:extra-deps {poly/image-creator {:local/root "components/image-creator"}
:+default {:extra-deps {poly/image-creator {:local/root "components/image-creator"}
poly/system {:local/root "components/system"}}}

:+extended {:extra-paths ["components/deps/test"]
:extra-deps {poly/image-creator-x {:local/root "components/image-creator-x"}
:+extended {:extra-deps {poly/image-creator-x {:local/root "components/image-creator-x"}
poly/system-x {:local/root "components/system-x"}}}

:test {:extra-paths ["components/change/test"
Expand Down
Binary file modified doc/images/production-systems/polylith.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/poly-rcf/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Example on how to run [Hyperfiddle rcf](https://github.com/hyperfiddle/rcf) tests with the `poly` tool.
Example on how to run [Hyperfiddle rcf](https://github.com/hyperfiddle/rcf) tests with [Polylith poly tool](https://polylith.gitbook.io/poly/).

I figured out that I could run the tests from the development project with `clojure -M:poly test :dev project:dev`. I then created `deps-rcf.edn` and `deps-261.edn` and tested both with the same statement by first copying them to `deps.edn`. I had to add `hyperfiddle/rcf` + `slf4j` to `bases/empty/deps.edn` for the `poly261` project to work. I also removed "src" from `:extra-paths` in the `:test` alias in `bases/rcf/deps.edn`, because it wasn't needed.

Expand Down
2 changes: 0 additions & 2 deletions next-release.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
|===
| Other changes

| New https://github.com/polyfy/polylith/blob/master/examples/poly-rcf/readme.md[poly-rcf] example workspace that shows how to run [Hyperfiddle rcf](https://github.com/hyperfiddle/rcf) tests with the `poly` tool.

|===

|===
Expand Down
1 change: 0 additions & 1 deletion projects/poly/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
polylith/shell {:local/root "../../components/shell"}
polylith/system {:local/root "../../components/system"}
polylith/tap {:local/root "../../components/tap"}
polylith/test {:local/root "../../components/test"}
polylith/test-runner-contract {:local/root "../../components/test-runner-contract"}
polylith/test-runner-orchestrator {:local/root "../../components/test-runner-orchestrator"}
polylith/text-table {:local/root "../../components/text-table"}
Expand Down
Loading

0 comments on commit 68b7739

Please sign in to comment.