Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (22 sloc) 513 Bytes
#!/bin/sh
# Run package tests for a file/directory, or all tests if no argument is passed.
# Useful to e.g. execute package tests for the file currently open in Vim.
# Usage: script/test [path]
set -e
go_pkg_from_path() {
path=$1
if test -d "$path"; then
dir="$path"
else
dir=$(dirname "$path")
fi
(cd "$dir" && go list)
}
if test $# -gt 0; then
pkg=$(go_pkg_from_path "$1")
verbose=-v
else
pkg=./...
verbose=
fi
exec go test ${GOTESTOPTS:-$verbose} "$pkg"