#!/usr/bin/env bash set -o errexit set -o nounset function run_go_tests() { # Look for changed Go packages, and pass the list to `go test`. if test -e "./tool/go"; then GO="./tool/go" else GO=$(which go) fi CHANGED_PACKAGES=$( git ls-files --modified \ | xargs dirname \ | uniq \ | xargs -I '{}' echo "./{}" \ | tr '\n' ' ' ) print_info "-> $GO test $CHANGED_PACKAGES" "$GO" test $CHANGED_PACKAGES } function run_rust_tests() { print_info "-> cargo fmt" cargo fmt echo "" print_info "-> cargo build" cargo build echo "" print_info -n "-> cargo test" cargo test --quiet } if test -f Cargo.toml then run_rust_tests elif test -f go.mod then run_go_tests # If there's a `scripts` folder with a test script, run that elif find "scripts" -name 'run_*_tests.sh' >/dev/null 2>&1 then print_info "-> bash scripts/run_*_tests.sh" bash scripts/run_*_tests.sh else echo "No run_*_tests.sh runner found in scripts!" 2>&1 exit 1 fi