Fix run-all-tests.sh script so it adds the replace directive

pull/20/head
Vinícius Garcia 2022-03-27 09:40:34 -03:00
parent f6ed380095
commit 34d0fc0236
2 changed files with 33 additions and 1 deletions

View File

@ -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.

16
scripts/run-with-replace.sh Executable file
View File

@ -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