Skip to content

Commit 38470aa

Browse files
authored
Merge pull request #233 from lambdaisland/arne/reload-cleanup
Fix and clean up load-error handling, remove Orchestra
2 parents 1bd5a09 + d5ecf30 commit 38470aa

File tree

20 files changed

+249
-232
lines changed

20 files changed

+249
-232
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- kaocha/execute:
2727
args: "integration --reporter documentation --plugin cloverage --codecov"
2828
clojure_version: << parameters.clojure_version >>
29-
- kaocha/execute:
30-
args: "generative-fdef-checks --reporter documentation"
31-
clojure_version: << parameters.clojure_version >>
3229
- kaocha/upload_codecov:
3330
flags: integration
3431
file: target/coverage/integration*/codecov.json

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
## Added
44

55
## Fixed
6+
7+
- Fix load-error handling in `kaocha.watch`
68
- Fix `could not resolve symbol require` error that occured sporadically when requiring certain kaocha namespaces.
79
- Fix printing of boolean options in the print-invocations plugin
10+
- Fix Java reflection warning in the Notifier plugin
811

912
## Changed
1013

14+
- [BREAKING] Remove the Orchestra dependency, and no longer auto-instrument.
15+
You'll have to list Orchestra in your own `deps.edn`/`project.clj` if you want
16+
to use the Orchestra plugin.
17+
- Version bumps of Clojure, tools.cli, spec.alpha, expound
18+
1119
# 1.0.861 (2021-05-21 / dbfd6e8)
1220

1321
## Added
22+
1423
- Formatting of failed test results using deep-diff can be disabled with `--diff-style :none` on the command line or `:diff-style :none` in `tests.edn`.
1524

1625
## Fixed
26+
1727
- Fix at least some cases of syntax errors being suppressed by the "no tests found" message.
1828

1929
## Changed

bin/kaocha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
clojure -J-Dline.separator=$'\n' -A:dev:test -m kaocha.runner "$@"
2+
clojure -J-Dline.separator=$'\n' -A:dev:test -M -m kaocha.runner "$@"

deps.edn

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
{:paths ["src" "resources"]
22

33
:deps
4-
{org.clojure/clojure {:mvn/version "1.10.1"}
5-
org.clojure/spec.alpha {:mvn/version "0.2.187"}
6-
org.clojure/tools.cli {:mvn/version "1.0.194"}
4+
{org.clojure/clojure {:mvn/version "1.10.3"}
5+
org.clojure/spec.alpha {:mvn/version "0.2.194"}
6+
org.clojure/tools.cli {:mvn/version "1.0.206"}
77
lambdaisland/tools.namespace {:mvn/version "0.0-237"}
88
lambdaisland/deep-diff {:mvn/version "0.0-47"}
99
org.tcrawley/dynapath {:mvn/version "1.1.0"}
1010
slingshot/slingshot {:mvn/version "0.12.2"}
1111
hawk/hawk {:mvn/version "0.2.11"}
12-
expound/expound {:mvn/version "0.8.5"}
13-
orchestra/orchestra {:mvn/version "2020.07.12-1"}
12+
expound/expound {:mvn/version "0.8.9"}
1413
aero/aero {:mvn/version "1.1.6"}
1514
progrock/progrock {:mvn/version "0.1.2"}
1615
meta-merge/meta-merge {:mvn/version "1.0.0"}}
1716

1817
:aliases
1918
{:test
20-
{:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
21-
lambdaisland/kaocha-cucumber {:mvn/version "0.0-53" :exclusions [lambdaisland/kaocha]}
22-
lambdaisland/kaocha-cloverage {:mvn/version "1.0.75" :exclusions [lambdaisland/kaocha]}
23-
nubank/matcher-combinators {:mvn/version "1.5.2"}
24-
akvo/fs {:mvn/version "20180904-152732.6dad3934"}}}
19+
{:extra-paths ["test/shared" "test/unit"]
20+
:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
21+
lambdaisland/kaocha-cucumber {:mvn/version "0.0-53" :exclusions [lambdaisland/kaocha]}
22+
lambdaisland/kaocha-cloverage {:mvn/version "1.0.75" :exclusions [lambdaisland/kaocha]}
23+
nubank/matcher-combinators {:mvn/version "1.5.2"}
24+
akvo/fs {:mvn/version "20180904-152732.6dad3934"}
25+
orchestra/orchestra {:mvn/version "2020.07.12-1"}}}
2526

2627
:dev
27-
{}}}
28+
{:extra-paths ["dev"]
29+
:extra-deps {djblue/portal {:mvn/version "RELEASE"}}}}}

dev/user.clj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns user)
2+
3+
(defmacro jit [sym]
4+
`(requiring-resolve '~sym))
5+
6+
(def portal-instance (atom nil))
7+
8+
(defn portal
9+
"Open a Portal window and register a tap handler for it. The result can be
10+
treated like an atom."
11+
[]
12+
;; Portal is both an IPersistentMap and an IDeref, which confuses pprint.
13+
(prefer-method @(jit clojure.pprint/simple-dispatch) clojure.lang.IPersistentMap clojure.lang.IDeref)
14+
(let [p ((jit portal.api/open) @portal-instance)]
15+
(reset! portal-instance p)
16+
(add-tap (jit portal.api/submit))
17+
p))

src/kaocha/api.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[kaocha.plugin :as plugin]
1010
[kaocha.report :as report]
1111
[kaocha.result :as result]
12+
[kaocha.util :as util]
1213
[kaocha.stacktrace :as stacktrace]
1314
[kaocha.testable :as testable]
1415
[slingshot.slingshot :refer [try+ throw+]]))
@@ -72,10 +73,10 @@
7273
(if (:kaocha/fail-fast (ex-data e))
7374
(throw e)
7475
(do
75-
(output/error "Error in reporter: " (ex-data e) " when processing " (:type m))
76+
(output/error "Error in reporter: " (ex-data e) " when processing " (pr-str (util/minimal-test-event m)))
7677
(stacktrace/print-cause-trace e))))
7778
(catch Throwable t
78-
(output/error "Error in reporter: " (.getClass t) " when processing " (:type m))
79+
(output/error "Error in reporter: " (.getClass t) " when processing " (pr-str (util/minimal-test-event m)))
7980
(stacktrace/print-cause-trace t))))))
8081

8182
(catch :kaocha/reporter-not-found {:kaocha/keys [reporter-not-found]}
@@ -101,7 +102,7 @@
101102
(when-not (some #(or (hierarchy/leaf? %)
102103
(::testable/load-error %))
103104
(testable/test-seq test-plan))
104-
105+
105106
(output/warn (str "No tests were found, make sure :test-paths and "
106107
":ns-patterns are configured correctly in tests.edn."))
107108
(throw+ {:kaocha/early-exit 0 }))

src/kaocha/plugin/notifier.clj

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111
[clojure.java.io :as io]
1212
[slingshot.slingshot :refer [throw+]])
1313
(:import [java.nio.file Files]
14-
[java.io IOException]
15-
[java.awt SystemTray TrayIcon TrayIcon$MessageType Toolkit]))
14+
[java.io IOException]
15+
[java.awt SystemTray TrayIcon TrayIcon$MessageType Toolkit]))
1616

1717
;; special thanks for terminal-notify stuff to
1818
;; https://github.com/glittershark/midje-notifier/blob/master/src/midje/notifier.clj
1919

2020
(defn exists? [program]
2121
(let [cmd (if (platform/on-windows?)
2222
"where.exe" "which" )]
23-
(try
23+
(try
2424
(= 0 (:exit (sh cmd program)))
2525
(catch IOException e ;in the unlikely event where.exe or which isn't available
2626
(output/warn (format "Unable to determine whether '%s' exists. Notifications may not work." program)) ))))
2727

28-
2928
(defn detect-command []
3029
(cond
3130
(exists? "notify-send")
@@ -64,32 +63,31 @@
6463
(io/copy (io/make-input-stream resource {}) file)
6564
(str file)))))))
6665

67-
6866
(def tray-icon
6967
"Creates a system tray icon."
7068
(memoize
71-
(fn [icon-path]
72-
(let [tray-icon (-> (Toolkit/getDefaultToolkit)
73-
(.getImage icon-path)
74-
(TrayIcon. "Kaocha Notification"))]
75-
(doto (SystemTray/getSystemTray)
76-
(.add tray-icon))
77-
tray-icon))))
78-
79-
(defn send-tray-notification
69+
(fn [icon-path]
70+
(let [^java.awt.Toolkit toolkit (Toolkit/getDefaultToolkit)
71+
tray-icon (-> toolkit
72+
(.getImage ^String icon-path)
73+
(TrayIcon. "Kaocha Notification"))]
74+
(doto (SystemTray/getSystemTray)
75+
(.add tray-icon))
76+
tray-icon))))
77+
78+
(defn send-tray-notification
8079
"Use Java's built-in functionality to display a notification.
8180
8281
Not preferred over shelling out because the built-in notification sometimes
8382
looks out of place, and isn't consistently available on Linux."
8483
[result]
85-
(try
84+
(try
8685
(let [icon (tray-icon "kaocha/clojure_logo.png")
8786
urgency (if (result/failed? result) TrayIcon$MessageType/ERROR TrayIcon$MessageType/INFO) ]
8887
(.displayMessage icon (title result) (message result) urgency))
8988
(catch java.awt.HeadlessException e
9089
(output/warn (str "Notification not shown because system is headless. AWT error: " e)) )))
9190

92-
9391
(defn expand-command
9492
"Takes a command string including replacement patterns, and a map of
9593
replacements, and returns a vector of command + arguments.

src/kaocha/plugin/profiling.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
(when (::profiling? result)
4545
(let [tests (->> result
4646
testable/test-seq
47-
(remove :kaocha.test-plan/load-error)
47+
(remove ::testable/load-error)
4848
(remove ::testable/skip))
4949
types (group-by :kaocha.testable/type tests)
5050
total-dur (::duration result)

src/kaocha/report.clj

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,19 @@
8989
(kaocha.hierarchy/derive! :mismatch :kaocha/fail-type)
9090
```"
9191
(:refer-clojure :exclude [symbol])
92-
(:require [kaocha.core-ext :refer :all]
92+
(:require [clojure.string :as str]
93+
[clojure.test :as t]
94+
[kaocha.core-ext :refer :all]
95+
[kaocha.hierarchy :as hierarchy]
96+
[kaocha.history :as history]
97+
[kaocha.jit :refer [jit]]
9398
[kaocha.output :as output]
9499
[kaocha.plugin.capture-output :as capture]
95100
[kaocha.stacktrace :as stacktrace]
96101
[kaocha.testable :as testable]
97-
[clojure.test :as t]
98-
[slingshot.slingshot :refer [throw+]]
99-
[clojure.string :as str]
100-
[kaocha.history :as history]
101102
[kaocha.testable :as testable]
102-
[kaocha.hierarchy :as hierarchy]
103-
[kaocha.jit :refer [jit]]))
103+
[kaocha.util :as util]
104+
[slingshot.slingshot :refer [throw+]]))
104105

105106
(defonce clojure-test-report t/report)
106107

@@ -414,19 +415,7 @@
414415

415416
(defn debug [m]
416417
(t/with-test-out
417-
(prn (cond-> (select-keys m [:type
418-
:file
419-
:line
420-
:var
421-
:ns
422-
:expected
423-
:actual
424-
:message
425-
:kaocha/testable
426-
:debug
427-
::printed-expression])
428-
(:kaocha/testable m)
429-
(update :kaocha/testable select-keys [:kaocha.testable/id :kaocha.testable/type])))))
418+
(prn (util/minimal-test-event m))))
430419

431420

432421
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

src/kaocha/runner.clj

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,22 @@
22
(ns kaocha.runner
33
"Main entry point for command line use."
44
(:gen-class)
5-
(:require [kaocha.api :as api]
6-
[clojure.java.io :as io]
5+
(:require [clojure.java.io :as io]
76
[clojure.pprint :as pprint]
87
[clojure.set :as set]
98
[clojure.spec.alpha :as spec]
109
[clojure.string :as str]
1110
[clojure.tools.cli :as cli]
1211
[expound.alpha :as expound]
12+
[kaocha.api :as api]
1313
[kaocha.config :as config]
1414
[kaocha.jit :refer [jit]]
1515
[kaocha.output :as output]
1616
[kaocha.plugin :as plugin]
1717
[kaocha.result :as result]
1818
[kaocha.specs :as specs]
19-
[orchestra.spec.test :as orchestra]
20-
[slingshot.slingshot :refer [try+ throw+]])
21-
(:import [java.io File]))
22-
23-
(orchestra/instrument
24-
(filter #(or (str/starts-with? (str %) "kaocha.")
25-
(str/starts-with? (str %) "lambdaisland."))
26-
(map ns-name (all-ns))))
19+
[slingshot.slingshot :refer [throw+ try+]])
20+
(:import java.io.File))
2721

2822
(defn- accumulate [m k v]
2923
(update m k (fnil conj []) v))
@@ -159,17 +153,17 @@
159153
(config/load-config (if profile
160154
{:profile profile}
161155
{})))
162-
_check_config_file (when (not (. (File. (or config-file "tests.edn")) exists))
163-
(output/warn (format (str "Did not load a configuration file and using the defaults.\n"
156+
_check_config_file (when (not (. (File. (or config-file "tests.edn")) exists))
157+
(output/warn (format (str "Did not load a configuration file and using the defaults.\n"
164158
"This is fine for experimenting, but for long-term use, we recommend creating a configuration file to avoid changes in behavior between releases.\n"
165159
"To create a configuration file using the current defaults, create a file named tests.edn that contains '#%s {}'.")
166160
config/current-reader)))
167-
_check (try
161+
_check (try
168162
(specs/assert-spec :kaocha/config config)
169-
(catch AssertionError e
170-
(output/error "Invalid configuration file:\n"
163+
(catch AssertionError e
164+
(output/error "Invalid configuration file:\n"
171165
(.getMessage e))
172-
(throw+ {:kaocha/early-exit 252})))
166+
(throw+ {:kaocha/early-exit 252})))
173167
plugin-chain (plugin/load-all (concat (:kaocha/plugins config) plugin))
174168
cli-options (plugin/run-hook* plugin-chain :kaocha.hooks/cli-options cli-options)
175169

0 commit comments

Comments
 (0)