mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-09 20:19:08 +00:00
Merge pull request #76 from adisbladis/unit-test-subdirs
Run unit tests under subdirs
This commit is contained in:
commit
a1ab7d6ed6
1 changed files with 15 additions and 5 deletions
|
@ -285,12 +285,22 @@ let
|
||||||
exclude+='\)'
|
exclude+='\)'
|
||||||
|
|
||||||
buildGoDir() {
|
buildGoDir() {
|
||||||
local d; local cmd;
|
local cmd="$1" dir="$2"
|
||||||
cmd="$1"
|
|
||||||
d="$2"
|
|
||||||
. $TMPDIR/buildFlagsArray
|
. $TMPDIR/buildFlagsArray
|
||||||
|
|
||||||
|
declare -a flags
|
||||||
|
flags+=($buildFlags "''${buildFlagsArray[@]}")
|
||||||
|
flags+=(''${tags:+-tags=${lib.concatStringsSep "," tags}})
|
||||||
|
flags+=(''${ldflags:+-ldflags="$ldflags"})
|
||||||
|
flags+=("-v" "-p" "$NIX_BUILD_CORES")
|
||||||
|
|
||||||
|
if [ "$cmd" = "test" ]; then
|
||||||
|
flags+=($checkFlags)
|
||||||
|
fi
|
||||||
|
|
||||||
local OUT
|
local OUT
|
||||||
if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then
|
if ! OUT="$(go $cmd "''${flags[@]}" $dir 2>&1)"; then
|
||||||
if echo "$OUT" | grep -qE 'imports .*?: no Go files in'; then
|
if echo "$OUT" | grep -qE 'imports .*?: no Go files in'; then
|
||||||
echo "$OUT" >&2
|
echo "$OUT" >&2
|
||||||
return 1
|
return 1
|
||||||
|
@ -352,7 +362,7 @@ let
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
|
|
||||||
for pkg in $(getGoDirs test); do
|
for pkg in $(getGoDirs test); do
|
||||||
buildGoDir test $checkFlags "$pkg"
|
buildGoDir test "$pkg"
|
||||||
done
|
done
|
||||||
|
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
|
|
Loading…
Reference in a new issue