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:
- Launch a separate shell and Julia REPL.
- Activate your package
devortestenvironment.
$ 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"]
- 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.
- 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