Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`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?

like image 918
Brenden Avatar asked Oct 24 '25 20:10

Brenden


1 Answers

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.

like image 102
nemo Avatar answered Oct 27 '25 12:10

nemo