lambdaisland / kaocha

Full featured next gen Clojure test runner
https://cljdoc.org/d/lambdaisland/kaocha/1.0.861/doc/1-introduction
Eclipse Public License 1.0
792 stars 81 forks source link

Kaocha Watch fails on WSL2 When Files Are Edited on Windows #408

Closed jsg24 closed 1 year ago

jsg24 commented 1 year ago

Hello,

I've been running into an issue where kaocha watch fails since I upgraded to WSL2.

I git-cloned the latest kaocha repo and ran the tests:

clj -M:test:test/run

This is what I got below:

kaocha.watch-test
  child-files-merged
  put-poll-test
  track-reload!-test
  watch-load-error-test
  glob-converted-unchanged-test
  glob-converted-test
  convert-test
  reload-test
    reloading a configuration file produces valid config
    reloading a configuration file produces the same config
    reloading a configuration file produces the same config when using a profile
  glob-test
  watch-test FAIL
  ignore-files-merged
  reload-config-test
  watch-set-dynamic-vars-test
  print-scheduled-operations-test
  make-queue-test
  drain-queue-test
WARNING: Notification not shown because system does not support it.
Consider disabling the notifier plugin when using in this context or installing
either notify-send (Linux) or terminal-notifier (macOS).

Randomized with --seed 480284797

FAIL in kaocha.watch-test/watch-test (main.java:40)
expected: (str/includes? (clojure.core/deref out-str) (str/replace "[(F)]\n\nFAIL in foo.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:yyy\n1 tests, 1 assertions, 1 failures.\n\n[watch] Reloading #{foo.bar-test}\n[watch] Re-running failed tests #{:foo.bar-test/xxx-test}\n[(F)]\n\nFAIL in foo.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:zzz" "foo" prefix))
  actual: (not (str/includes? "[(F)]\n\nFAIL in foo15497.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:zzz\n1 tests, 1 assertions, 1 failures.\n\n[watch] Reloading #{foo15497.bar-test}\n[watch] Re-running failed tests #{:foo15497.bar-test/xxx-test}\n[(F)]\n\nFAIL in foo15497.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:zzz\n1 tests, 1 assertions, 1 failures.\n\n" "[(F)]\n\nFAIL in foo15497.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:yyy\n1 tests, 1 assertions, 1 failures.\n\n[watch] Reloading #{foo15497.bar-test}\n[watch] Re-running failed tests #{:foo15497.bar-test/xxx-test}\n[(F)]\n\nFAIL in foo15497.bar-test/xxx-test (bar_test.clj:1)\nExpected:\n  :xxx\nActual:\n  -:xxx +:zzz"))
╭───── Test output ───────────────────────────────────────────────────────
│ SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
│ SLF4J: Defaulting to no-operation (NOP) logger implementation
│ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
╰─────────────────────────────────────────────────────────────────────────
174 tests, 434 assertions, 1 failures.

Please see my version of WSL below:

wsl --version

WSL version: 1.1.6.0
Kernel version: 5.15.90.1
WSLg version: 1.0.50
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2728

Thanks for any help in advance!

alysbrooks commented 1 year ago

kaocha.watch-test/watch-test is one of our more fragile tests, unfortunately, so the failing test may be a false positive. Are you seeing issues when you actually use --watch as well? That might be more informative, actually.

alysbrooks commented 1 year ago

Hmm, when using wdiff on the strings themselves, this looks similar to another failure we had (on #393). That was due to a code change, but that test may be that a lot of things cause the same error.

dmg46664 commented 1 year ago

Sorry! Freudian slip. I can confirm that when --watch is used it does not trigger reruns on file changes. cc: @jsg24

alysbrooks commented 1 year ago

Thanks for the confirmation. Do you know if --watch used to work on WSL2?

alysbrooks commented 1 year ago

Running Kaocha from the main branch, I'm seeing the error @jsg24 described occasionally, but --watch itself seems to work reliably. I'm running the (default?) Ubuntu for WSL2 on Windows 10 and making the modifications within WSL2 itself using Vim and on Windows using Notepad (it's a fresh install of Windows). @dmg46664 does that differ from your setup? What version of Kaocha are you using?

alysbrooks commented 1 year ago

I set this up purely for replicating this and future issues, so if it's the kind of issue that appears over a long programming session, I wouldn't see it.

alysbrooks commented 1 year ago

Okay, I was able to replicate the issue when the files are on Windows and I run Kaocha and edit them from WSL2. Is that where other people are seeing problems?

The WSL2 users in this thread are probably aware, but Microsoft seems to recommend against doing accessing files in Windows from WSL2, however:

We recommend against working across operating systems with your files, unless you have a specific reason for doing so.

jsg24 commented 1 year ago

Hi @alysbrooks , sorry for the delay.

Thanks for your reference to Microsoft's documentation. I was unaware that it's ill advised to mix systems.

Yes that is my case. Sometimes I like to use UX tools such as Vlaaad's Reveal nREPL which doesn't launch on WSL. At the same time, I run VSCode on WSL side of things. Many of the build pipeline runs better on WSL.

We also have a Windows build target so it's a pity that it's complicated to simply switch between systems.

For me the --watch feature never works in the default Beholder mode. I have found a way around this by using the deprecated :kaocha.watch/type :hawk . Although on my last attempt this took a really long time to run.

I'm going to try and experiment with dual booting Linux to solve my immediate issues.

Thanks again!

alysbrooks commented 1 year ago

Maybe you can keep the files on WSL rather than Windows and access them through the //wsl$ share? That seems to work better with --watch. You could also try using Hawk in its polling mode: https://github.com/lambdaisland/kaocha/blob/main/doc/07_watch_mode.md#configuring-the-watcher.

I suspect the issue is ultimately not in Kaocha, Hawk, or Beholder, and is instead in the file system driver (FUSE?), since the Windows partition is represented within WSL as a mounted drive.

alysbrooks commented 1 year ago

This does make we wonder if we should expose some sort of hook to trigger reloading for cases like this. (You can manually press enter in the terminal running kaocha with --watch to reload, too.)

jsg24 commented 1 year ago

Thanks for the enter tip! Didn't know about that.

I'm experimenting with a Linux setup so the issue is not as pressing.

dmg46664 commented 1 year ago

@alysbrooks I was just commenting on jsg's setup. I'm on MacOS.

alysbrooks commented 1 year ago

@dmg46664 Just to clarify, when you mentioned "when --watch is used it does not trigger reruns on file changes" you were referring to the behavior on jsg's setup?

alysbrooks commented 1 year ago

I would generally consider --watch not working on a specific platform to an urgent issue because it's basic functionality, but if it the problem only occurs when watching for changes on a Windows partition while Kaocha runs on WSL2, I probably would consider it low priority unless people are reporting it interferes with their workflows.

dmg46664 commented 1 year ago

@alysbrooks

you were referring to the behavior on jsg's setup?

Es muy correcto

oxalorg commented 1 year ago

Thanks for the great investigation everyone 🙏.

It seems like there isn't much we can do on Kaocha's end. I'll mark the issue as closed.