Run tests on src file change: Best practice

I’ll endeavor to revise the selected solution to point to any better alternatives proposed…

Current best practice appears to be set-out in this SO answer by anowacki:

  1. Launch a separate shell and Julia REPL.
  2. Activate your package dev or test environment.
$ cd ~/src/your-package
$ julia --project=.

A. Using 3-rd-party Packages (Blocked by Watcher issue #2)
Add test related packages to Project.toml

[extras]
Test = "<uuid-here>"
Watcher = "<uuid-here>"

[targets]
test = ["Test", "Watcher"]
  1. Cut-and-paste the following:
$ julia -e "using Watcher"

B. Using only Base or Stdlib

NOTE:
The following does not trigger test runs when you create or delete a file. Only when you add/remove content to a file. To delete a file: first remove all content (a test run will be triggered), then delete the empty file.

  1. Cut-and-paste the following:
$ julia --project=.
julia> import Pkg; import FileWatching: watch_file

julia> @async while true
           event = watch_file("src")
           if event.changed
               try
                   Pkg.pkg"test"
               catch err
                   @warn("Error during testing:\n$err")
               end
           end
       end