In test-driven development, the process of "update file"-> "execute test command in console" was tedious. So here's how to automate this process.
sudo apt install inotify-tools
Create the following script and place it at the root of your project.
#!/usr/bin/env bash TEST_RUNNER="pytest -s tests" #Specify the test command you want to execute TARGETS="./src ./tests" #Specify the monitored directory while inotifywait -r -e modify -e create -e delete $TARGETS; do $TEST_RUNNER done
Execution authority is also granted.
chmod +x ./autorun.sh
-[How to use the inotify wait command](https://qiita.com/hana_shin/items/9e03ad7a40b4fd7afb67#4-%E3%83%A2%E3%83%8B%E3%82%BF%E3%83%BC%E3 % 82% AA% E3% 83% 97% E3% 82% B7% E3% 83% A7% E3% 83% B3% E3% 81% AE% E4% BD% BF% E3% 81% 84% E6% 96 % B9-m)