-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adding :with-repl option to start a clojure.main/repl in-between test execution #50
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c1a510c
Added :with-repl opt, enables basic REPL that behaves the same as
679e353
Now using clojure.main/repl instead.
a07cb93
Added `with-repl` sections in README.md and CHANGES.md
45aa3fc
Restored monitor-keystrokes back to use `(.read System/in)`.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,13 +163,27 @@ | |
(defn- something-changed? [x y] | ||
(not= x y)) | ||
|
||
(defn- monitor-keystrokes [keystroke-pressed] | ||
(def printing (atom false)) | ||
|
||
(defn- monitor-keystrokes [keystroke-pressed with-repl?] | ||
(future | ||
(loop [c (.read System/in)] | ||
(if (= c -1) | ||
(System/exit 0) | ||
(do (reset! keystroke-pressed true) | ||
(recur (.read System/in))))))) | ||
(let [run-test-refresh! #(do (reset! keystroke-pressed true) | ||
(reset! printing true))] | ||
(if with-repl? | ||
(clojure.main/repl | ||
:prompt #(do (while @printing (Thread/sleep 100)) | ||
(clojure.main/repl-prompt)) | ||
:read (fn [request-prompt request-exit] | ||
(if-let [line (read-line)] | ||
(if-not (empty? (clojure.string/trim line)) | ||
(read-string line) | ||
(do (run-test-refresh!) :run-tests)) | ||
(System/exit 0)))) | ||
(loop [line (read-line)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized now that this case (not |
||
(if-not line | ||
(System/exit 0) | ||
(run-test-refresh!)) | ||
(recur (read-line))))))) | ||
|
||
(defn- create-user-notifier [notify-command] | ||
(let [notify-command (if (string? notify-command) | ||
|
@@ -198,20 +212,24 @@ | |
keystroke-pressed (atom nil) | ||
selectors (second (:nses-and-selectors options)) | ||
report (:report options) | ||
run-once? (:run-once options)] | ||
run-once? (:run-once options) | ||
with-repl? (:with-repl options) | ||
monitoring? (atom false)] | ||
|
||
(when report | ||
(println "Using reporter:" report)) | ||
(when (:quiet options) | ||
(defmethod capture-report :begin-test-ns [m])) | ||
|
||
(when-not run-once? (monitor-keystrokes keystroke-pressed)) | ||
(loop [tracker (make-change-tracker)] | ||
(let [new-tracker (scan-for-changes tracker)] | ||
(let [new-tracker (scan-for-changes tracker) | ||
something-changed? (something-changed? new-tracker tracker)] | ||
(try | ||
(when (or @keystroke-pressed | ||
(something-changed? new-tracker tracker)) | ||
(when (or @keystroke-pressed something-changed?) | ||
(reset! keystroke-pressed nil) | ||
(reset! printing true) | ||
|
||
(when (and with-repl? @monitoring? something-changed?) (println)) | ||
(print-banner) | ||
|
||
(let [was-failed (tracking-failed-tests?) | ||
|
@@ -227,7 +245,17 @@ | |
(when (should-notify? result) | ||
(when should-growl | ||
(growl (:status result) (:message result))) | ||
(users-notifier (:message result))))) | ||
(users-notifier (:message result)))) | ||
(reset! printing false) | ||
|
||
(when (and with-repl? @monitoring? something-changed?) | ||
(clojure.main/repl-prompt) | ||
(flush)) | ||
|
||
(when (and (not run-once?) | ||
(not @monitoring?)) | ||
(monitor-keystrokes keystroke-pressed with-repl?) | ||
(reset! monitoring? true))) | ||
(catch Exception ex (.printStackTrace ex))) | ||
(Thread/sleep 200) | ||
(if-not run-once? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept getting warnings about some of my plugins not running with 1.6.0.