entrypoint: move go test setup an invocation into a function

A little refactoring to move the setup of the pkg test calls into a
function to ease future changes.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-02-03 13:55:03 -05:00 committed by Niels de Vos
parent 25bd9f0bed
commit 3ca24f63c5
1 changed files with 38 additions and 32 deletions

View File

@ -51,29 +51,10 @@ while true ; do
esac esac
done done
test_go_ceph() { test_pkg() {
mkdir -p /tmp/ceph local pkg="$1"
"${MICRO_OSD_PATH}" /tmp/ceph
export CEPH_CONF=/tmp/ceph/ceph.conf
if [[ ${TEST_RUN} == NONE ]]; then
echo "skipping test execution"
else
go get -t -v ./...
diff -u <(echo -n) <(gofmt -d -s .)
#go vet ./...
#go list ./...
echo "mode: count" > "cover.out"
P=github.com/ceph/go-ceph
pkgs=(\
"cephfs" \
"errutil" \
"rados" \
"rbd" \
)
for pkg in "${pkgs[@]}"; do
if [[ "$TEST_PKG" && "$TEST_PKG" != "$pkg" ]]; then if [[ "$TEST_PKG" && "$TEST_PKG" != "$pkg" ]]; then
continue return 0
fi fi
testargs=(\ testargs=(\
"-covermode=count" \ "-covermode=count" \
@ -87,10 +68,35 @@ test_go_ceph() {
go test -v "${testargs[@]}" "./$pkg" go test -v "${testargs[@]}" "./$pkg"
grep -v "^mode: count" "$pkg.cover.out" >> "cover.out" grep -v "^mode: count" "$pkg.cover.out" >> "cover.out"
}
test_go_ceph() {
mkdir -p /tmp/ceph
"${MICRO_OSD_PATH}" /tmp/ceph
export CEPH_CONF=/tmp/ceph/ceph.conf
if [[ ${TEST_RUN} == NONE ]]; then
echo "skipping test execution"
return 0
fi
go get -t -v ./...
diff -u <(echo -n) <(gofmt -d -s .)
#go vet ./...
#go list ./...
echo "mode: count" > "cover.out"
P=github.com/ceph/go-ceph
pkgs=(\
"cephfs" \
"errutil" \
"rados" \
"rbd" \
)
for pkg in "${pkgs[@]}"; do
test_pkg "$pkg"
done done
mkdir -p /results/coverage mkdir -p /results/coverage
go tool cover -html=cover.out -o /results/coverage/go-ceph.html go tool cover -html=cover.out -o /results/coverage/go-ceph.html
fi
} }
pause_if_needed() { pause_if_needed() {