Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watching stops at compile error or compile #34

Closed
Kynde opened this issue Apr 3, 2019 · 4 comments
Closed

Watching stops at compile error or compile #34

Kynde opened this issue Apr 3, 2019 · 4 comments

Comments

@Kynde
Copy link
Contributor

Kynde commented Apr 3, 2019

If I hit a compile error during file watching I can't seem to get the file watcher working again without a restart. Pressing Enter recompiles and runs all tests but still I can't get it to go back to watching files even then.

Experienced in auto mode:

  • typo, :w
  • compiler error
  • fix typo, :w
  • nothing happens

Expected:

  • typo, :w
  • compiler error
  • fix typo, :w
  • recompile and run all tests and continue in auto mode

Also experienced in auto mode:

  • press enter
  • runs all tests
  • tweak a bit, :w
  • nothing happens

Expected:

  • press enter
  • runs all tests
  • tweak a bit, :w
  • runs affected tests and continue is auto mode

Maybe I'm missing an option or my use case is off, but I thought I'd ask away.

@miikka
Copy link
Contributor

miikka commented Apr 3, 2019

You're right – I can reproduce this and it's a bug. The fix might be as simple as adding a try-catch block that eats the exceptions in the watchtower on-change handler:

(watchtower.core/on-change (fn [~'_]
(println)
(metosin.bat-test.impl/run ~opts)))))

@Kynde
Copy link
Contributor Author

Kynde commented Apr 9, 2019

Indeed. Works like a charm.

diff --git a/src/leiningen/bat_test.clj b/src/leiningen/bat_test.clj
index 00719ed..bd8afb1 100644
--- a/src/leiningen/bat_test.clj
+++ b/src/leiningen/bat_test.clj
@@ -51,7 +51,10 @@
               (watchtower.core/file-filter (watchtower.core/extensions :clj :cljc))
               (watchtower.core/on-change (fn [~'_]
                                            (println)
-                                           (metosin.bat-test.impl/run ~opts)))))
+                                           (try
+                                             (metosin.bat-test.impl/run ~opts)
+                                             (catch Exception e#
+                                               (println e#)))))))
         `(let [summary# (metosin.bat-test.impl/run ~opts)
                exit-code# (+ (:fail summary# 0) (:error summary# 0))]
            (if ~(= :leiningen (:eval-in project))

You drop it in or you want a PR out of it?

@miikka
Copy link
Contributor

miikka commented May 2, 2019

@Kynde - sorry for the slow reply, I was on vacation - please do send a PR!

Kynde added a commit to Kynde/bat-test that referenced this issue May 13, 2019
This adds a simple try catch block to continue watching files
and retry compilation after changes as suggested by @miikka.

This fixes issue metosin#34
@miikka
Copy link
Contributor

miikka commented May 14, 2019

The fix is released in [metosin/bat-test "0.4.3"] 🎉

@miikka miikka closed this as completed May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants