mirror of
https://github.com/elyby/chrly.git
synced 2024-12-28 16:00:18 +05:30
28 lines
650 B
Bash
Executable File
28 lines
650 B
Bash
Executable File
#!/bin/sh
|
|
# Based on https://github.com/mlafeldt/chef-runner/blob/34269dbb726c243dff9764007e7bd7f0fe9ee331/script/test
|
|
# 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=$(go list ./... | grep -v /vendor/)
|
|
verbose=
|
|
fi
|
|
|
|
exec go test ${GOTESTOPTS:-$verbose} $pkg
|