Make test failures easier to see and understand.

This commit is contained in:
Jeffrey Regan
2018-02-13 13:20:03 -08:00
parent a90a3cff3a
commit 824b51eb84

View File

@@ -10,28 +10,47 @@ cd "$base_dir" || {
rc=0 rc=0
go_dirs() { function go_dirs {
go list -f '{{.Dir}}' ./... | tr '\n' '\0' go list -f '{{.Dir}}' ./... | tr '\n' '\0'
} }
echo "Running go fmt" function runTest {
diff <(echo -n) <(go_dirs | xargs -0 gofmt -s -d -l) local name=$1
rc=$((rc || $?)) local result="SUCCESS"
printf "============== begin %s\n" "$name"
$name
local code=$?
rc=$((rc || $code))
if [ $code -ne 0 ]; then
result="FAILURE"
fi
printf "============== end %s : %s code=%d\n\n\n" "$name" "$result" $code
}
echo "Running goimports" function testGoFmt {
diff -u <(echo -n) <(go_dirs | xargs -0 goimports -l) diff <(echo -n) <(go_dirs | xargs -0 gofmt -s -d -l)
rc=$((rc || $?)) }
echo "Running go vet" function testGoImports {
go vet -all ./... diff -u <(echo -n) <(go_dirs | xargs -0 goimports -l)
rc=$((rc || $?)) }
echo "Running go test" function testGoVet {
go test -v ./... go vet -all ./...
rc=$((rc || $?)) }
echo "Testing kinflate demos" function testGoTest {
mdrip --mode test --label test ./cmd/kinflate go test -v ./...
rc=$((rc || $?)) }
function testTutorial {
mdrip --mode test --label test ./cmd/kinflate
}
runTest testGoFmt
runTest testGoImports
runTest testGoVet
runTest testGoTest
runTest testTutorial
exit $rc exit $rc