From f85a99a6c446a6808e12d051359bc319fab86769 Mon Sep 17 00:00:00 2001 From: Joakim Tengstrand Date: Tue, 7 Nov 2023 17:49:08 +0000 Subject: [PATCH] Don't validate data_readers.clj files (#382) Always consider data_readers.clj files as valid. --- .../core/workspace_clj/namespaces_from_disk.clj | 5 +++-- .../workspace_clj/namespaces_from_disk_test.clj | 15 ++++++++++++++- next-release.txt | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/components/workspace-clj/src/polylith/clj/core/workspace_clj/namespaces_from_disk.clj b/components/workspace-clj/src/polylith/clj/core/workspace_clj/namespaces_from_disk.clj index ad40bc850..adc8ad2ec 100644 --- a/components/workspace-clj/src/polylith/clj/core/workspace_clj/namespaces_from_disk.clj +++ b/components/workspace-clj/src/polylith/clj/core/workspace_clj/namespaces_from_disk.clj @@ -133,8 +133,9 @@ :imports []} (let [imports (imports content suffixed-top-ns interface-ns) ignore? (ignore-file? file-path files-to-ignore) - invalid? (and (not ignore?) - (-> content ns-with-name? not))] + invalid? (not (or ignore? + (str/ends-with? relative-path "/data_readers.clj") + (-> content ns-with-name?)))] (cond-> {:name ns-name :namespace (if (ns-with-name? content) (-> content second str) diff --git a/components/workspace-clj/test/polylith/clj/core/workspace_clj/namespaces_from_disk_test.clj b/components/workspace-clj/test/polylith/clj/core/workspace_clj/namespaces_from_disk_test.clj index 2dd6ed56e..26c8c2f3c 100644 --- a/components/workspace-clj/test/polylith/clj/core/workspace_clj/namespaces_from_disk_test.clj +++ b/components/workspace-clj/test/polylith/clj/core/workspace_clj/namespaces_from_disk_test.clj @@ -96,7 +96,20 @@ (with-redefs [file/read-file (fn [_] ['--]) from-disk/namespace-name (fn [_ _] "")] (is (= (from-disk/->namespace "." "" "" "" [] "path") - {:name "", :namespace "", :file-path "path", :imports [], :is-invalid true})))) + {:name "" + :namespace "" + :file-path "path" + :imports [] + :is-invalid true})))) + +(deftest ->namespace--ignore-data-readers + (with-redefs [file/read-file (fn [_] ['--]) + from-disk/namespace-name (fn [_ _] "")] + (is (= (from-disk/->namespace "." "" "" "" [] "path/data_readers.clj") + {:file-path "path/data_readers.clj" + :imports [] + :name "" + :namespace ""})))) (deftest ->namespace--read-namespace (with-redefs [file/read-file (fn [_] file-content) diff --git a/next-release.txt b/next-release.txt index 88cd3df7f..9cf7b4db1 100644 --- a/next-release.txt +++ b/next-release.txt @@ -24,6 +24,7 @@ Included in 0.2.18-SNAPSHOT #11: 309 Improve the performance of the poly commands by optimising the dependency calculations. 312 Build docs/example code should not use build-clj. 313 NPE when importing Java sub namespace. + 316 Don't validate data_readers.clj files. 318 Use cljdoc for the poly tool documentation. Moved back all the poly tool documentation to the GitHib repository together with the source code + updated the documentation + added new pages: Artifacts, Doc, Poly as a library, Tap, Test Runners, Validations, Source code, Polyx, and Maintenance.