diff --git a/run-all-tests.sh b/run-all-tests.sh index 5fd405f..cd0aa92 100755 --- a/run-all-tests.sh +++ b/run-all-tests.sh @@ -1,6 +1,22 @@ #!/usr/bin/env bash +# Make sure the script will stop on error: +set -ueo pipefail + # Generate the coverate.txt file for all modules: -find . -name go.mod -execdir go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/vingarcia/ksql ./... \; + +# Run ksql root module tests: +go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/vingarcia/ksql ./... + +# Run the tests for the examples module: +( cd examples ; go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/vingarcia/ksql ./... ) + +# Make sure the run-with-replace.sh is on PATH: +export PATH=$PATH:$(pwd)/scripts + +# Then for each adapter run the tests with the replace directive: +for dir in $(find adapters -name go.mod -printf '%h\n'); do + ( cd $dir ; run-with-replace.sh go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/vingarcia/ksql ./... ) +done # codecov will find all `coverate.txt` files, so it will work fine. diff --git a/scripts/run-with-replace.sh b/scripts/run-with-replace.sh new file mode 100755 index 0000000..5d8bdae --- /dev/null +++ b/scripts/run-with-replace.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Update go.mod with replace so testing will +# run against the local version of ksql: +echo "replace github.com/vingarcia/ksql => ../../" >> go.mod +go mod tidy +go test + +# Save whether the tests succeeded or not: +tests_succedeed=$? + +# Undo the changes: +git checkout go.mod go.sum > /dev/null + +# Return error if the tests failed: +test $tests_succedeed -eq 0