Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
camsaul committed Feb 22, 2025
1 parent 9fcdf23 commit 7346d2a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
*.jar
.\#*
.clj-kondo/.deps.edn.md5sum
.cpcache
.lsp
.nrepl-port
/*.iml
/.clj-kondo/.cache
/.clj-kondo/methodical/
/.cpcache
/.eastwood
/.env
/.envrc
Expand All @@ -17,7 +18,6 @@
/.lein-failures
/.lein-plugins
/.lein-repl-history
/.nrepl-port
/.shadow-cljs
/build.xml
/checkouts
Expand Down
4 changes: 2 additions & 2 deletions mr-worldwide.build/src/mr_worldwide/build/artifacts.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns mr-worldwide.build.artifacts
(:require
[clojure.pprint :as pprint]
[clojure.tools.logging :as log]
[mr-worldwide.build.artifacts.clj :as clj]
[mr-worldwide.build.artifacts.cljs :as cljs]
[mr-worldwide.build.common :as common]
[mr-worldwide.build.util :as u]
[clojure.tools.logging :as log]))
[mr-worldwide.build.util :as u]))

(defn- config-file-contents [{:keys [packages bundle], :as config}]
{:pre [(seq packages) (string? bundle)]}
Expand Down
16 changes: 3 additions & 13 deletions mr-worldwide.build/src/mr_worldwide/build/artifacts/clj.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@
(set! *warn-on-reflection* true)

(defn- clj-message? [{:keys [source-references], :as _message}]
(let [paths (eduction
;; Sometimes 2 paths exist in a single string, space separated
(mapcat #(str/split % #" "))
;; Strip off the line number at the end of some paths
(map #(str/split % #":"))
(map first)
source-references)]
(some (fn [path]
(some
(fn [suffix]
(str/ends-with? path suffix))
[".clj" ".cljc"]))
paths)))
(some (fn [path]
(re-find #"\.cljc?(?::\d+)?$" path))
source-references))

(def ^:private apostrophe-regex
"Regex that matches incorrectly escaped apostrophe characters.
Expand Down
6 changes: 3 additions & 3 deletions mr-worldwide.build/src/mr_worldwide/build/artifacts/cljs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
(defn- js-or-cljs-message?
"Whether this i18n `message` comes from a frontend source file."
[{:keys [source-references], :as _message}]
(some (fn [file]
(some #(str/ends-with? file %)
[".cljs" ".cljc" ".js" ".jsx" ".ts" ".tsx"]))
(some (fn [path]
;; cljc, cljs, js, ts, jsx, tsx with optional line number
(re-find #"\.(?:(?:clj[cs])|(?:[jt]sx?))(?::\d+)?$" path))
source-references))

(defn- ->ttag-reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[mr-worldwide.build.artifacts.clj :as clj]
[mr-worldwide.build.artifacts.test-common :as test-common]))

(deftest edn-test
(deftest ^:parallel edn-test
(#'clj/write-edn-file! test-common/po-contents "/tmp/out.edn")
(is (= ["{"
":headers"
Expand Down Expand Up @@ -34,7 +34,7 @@
(testing "messages present in any .clj and .cljc files are detected as backend messages"
#_{:clj-kondo/ignore [:equals-true :equals-false]}
(are [source-references expected] (= expected
(@#'clj/clj-message? {:source-references source-references}))
(boolean (@#'clj/clj-message? {:source-references source-references})))
;; Simple .clj and .cljc files with and without line numbers
["test.clj"] true
["test.clj:123"] true
Expand All @@ -44,9 +44,9 @@
["src/metabase/query_processor/streaming/xlsx.clj"] true
["metabase/mbql/normalize.cljc:839"] true
["metabase/driver/common.clj:223"] true
["clj/mbql/src/metabase/mbql/normalize.clj"] true
["clj/mbql/src/metabase/mbql/normalize.clj"] true
["metabase_enterprise/audit_app/interface.clj:25"] true
["enterprise/clj/test/metabase_enterprise/serialization/load_test.clj"] true
["enterprise/clj/test/metabase_enterprise/serialization/load_test.clj"] true
["target/classes/metabase/request/util.clj"] true
;; Both a FE and a BE path
["frontend/src/metabase/browse/components/TableBrowser/TableBrowser.jsx:145"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@

(def po-contents
"Contents of a `.po` file."
{:headers {"MIME-Version" "1.0",
"Content-Type" "text/plain; charset=UTF-8",
"Content-Transfer-Encoding" "8bit",
"X-Generator" "POEditor.com",
"Project-Id-Version" "Metabase",
"Language" "es",
{:headers {"MIME-Version" "1.0"
"Content-Type" "text/plain; charset=UTF-8"
"Content-Transfer-Encoding" "8bit"
"X-Generator" "POEditor.com"
"Project-Id-Version" "Metabase"
"Language" "es"
"Plural-Forms" "nplurals=2; plural=(n != 1);"}
:messages messages})

0 comments on commit 7346d2a

Please sign in to comment.