Skip to content

Instantly share code, notes, and snippets.

@JonCanning
Last active June 6, 2024 06:23
Show Gist options
  • Save JonCanning/48bb00a02272c242355b2ee957687c44 to your computer and use it in GitHub Desktop.
Save JonCanning/48bb00a02272c242355b2ee957687c44 to your computer and use it in GitHub Desktop.
golang continuous testing
#!/bin/bash
fswatch -l 1 -o ./**/*.go --event=Updated | while read -r; do
clear
output=$(go test ./... 2>&1)
if echo "$output" | grep -- '- FAIL' > /dev/null; then
echo -e "\e[31m$(echo "$output" | awk '/--- FAIL/,/Test:/')\e[0m"
elif [ -z "$output" ]; then
echo -e "\e[31mBUILD FAILED\e[0m"
else
echo -e "\e[32mPASS\e[0m"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment