Skip to content

Instantly share code, notes, and snippets.

@nyarly
Last active July 19, 2016 20:27
Show Gist options
  • Save nyarly/83d1803091455035c6cd2c6387194430 to your computer and use it in GitHub Desktop.
Save nyarly/83d1803091455035c6cd2c6387194430 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/fish
# XXX use git command to build this
set -l projname swaggering
set -l coverdir /tmp/{$projname}
set -l numpipes 2
set -l filter '\
{ gsub(/.*\\r/, "") };
{ gsub(/.*_obj_test/, ".") };
/^ok|^\?/ { lines = ""; print; next };
/^FAIL[[:space:]][[:alnum:]]/ { print "BEGIN " gp "/src/" $2; print lines; print "FAIL " gp "/src/" $2; lines = ""; next };
{ lines = lines "\n" $0 };
END { print lines }'
mkdir -p $coverdir
set -l result "succeeded"
for p in (go list ./...)
set -l fifodir (mktemp -d)
mkfifo $fifodir/{(seq $numpipes)}
awk -v gp=$GOPATH "$filter" < {$fifodir}/1 &
if not go build $p > {$fifodir}/1 2>&1
set result "failed"
continue
end
awk -v gp=$GOPATH "$filter" < {$fifodir}/2 &
if not go test -short -timeout 10s -coverprofile=$coverdir/(echo $p | sed 's#/##g').out $p >> {$fifodir}/2 2>&1
set result "failed"
end
end
legendary .cadre/coverage.vim $coverdir/*.out
while jobs | grep -q 'running'
sleep 0.1
end
if [ $result = "failed" ]
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment