Brenden
Brenden

Reputation: 7908

`go test` file modification monitoring for automated testing

Is there a way to have go test run whenever a project's files are modified?

Perhaps there is a good general solution to run a command when files in a path are modified that could be used for this use?

Upvotes: 4

Views: 1002

Answers (1)

nemo
nemo

Reputation: 57599

You can use inotifywait for that. Example watching some dir and executing go test on close while having data written:

inotifywait -e close_write <dir> | while read file; do go test; done

Or you write your own tool in go utilizing the howeyc/fsnotify package: Similar example application.

There's also rerun, written in ruby:

rerun go test

Above command will watch the current directory for changes and run go test when a change occurs.

Upvotes: 3

Related Questions