babashka / pod-babashka-filewatcher

Babashka filewatcher pod based on Rust notify
Eclipse Public License 1.0
23 stars 1 forks source link

Rust notify panic via pod #7

Open frenchy64 opened 1 year ago

frenchy64 commented 1 year ago

I modified some code from here like so, but when I run it, the Rust library crashes.

#!/usr/bin/env bb

(require '[babashka.pods :as pods]
         '[babashka.tasks :as tasks])

(pods/load-pod 'org.babashka/filewatcher "0.0.1")
(require '[pod.babashka.filewatcher :as fw])

(let [running (atom false)]
  (defn run-tests []
    (when (= [false true] (reset-vals! running true))
      (try (tasks/shell "./run-tests")
           (finally (reset! running false))))))

(run-tests)

(def cwd (System/getProperty "user.dir"))

(require '[clojure.java.io :as io])

(fw/watch "src" (fn [event]
                  (when (= :write (:type event))
                    (run-tests))))

@(promise)
./watch.clj

Testing reascript-test.drum-notation-test

Testing reascript-test.drum-notation.pretty-test

Testing reascript-test.drum-notation.reorder-test

Testing reascript-test.drum-notation.rep-test

Testing reascript-test.drum-notation.solve-test

Ran 18 tests containing 56 assertions.
0 failures, 0 errors.
Test run at Sun Mar 12 23:27:54 2023, seed: 1678678074132
(...)(............)(..)(.)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PathNotFound', src/main.rs:148:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
borkdude commented 1 year ago

Could it be that the path you are watching does not exist? The error seems to come from here:

https://github.com/babashka/pod-babashka-filewatcher/blob/75b2e773c0d50aea0849b095fb43490289cf961b/src/main.rs#L148