Skip to content

Instantly share code, notes, and snippets.

@baldwindavid
Created October 26, 2025 18:42
Show Gist options
  • Save baldwindavid/4b5e8548376fcaec1f84fec3534217cf to your computer and use it in GitHub Desktop.
Save baldwindavid/4b5e8548376fcaec1f84fec3534217cf to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# Usage: go_test_package.sh <file>
# Runs all tests in the package containing the file
input="${1:-}"
if [[ -z "$input" ]]; then
echo "Error: No file provided"
exit 1
fi
# Validate file exists
if [[ ! -f "$input" ]]; then
echo "Error: File not found: $input"
exit 1
fi
# Get the directory of the file (the package directory)
package_dir=$(dirname "$input")
# Change to the package directory and run all tests
cd "$package_dir"
# Run all tests in the package with gotestsum testdox format
# Always exit 0 so Helix shows the output even on test failures
gotestsum --format testdox || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment