mirror of https://github.com/ceph/go-ceph
entrypoint: handle the sub-packages separately
Run the tests for each sub-package as a separate invocation. Make the package selectable. This has a few small advantages: * When iterating on a single package the other packages do not run * Better coverage summary line printed after each test * Slightly better output with verbose test output Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
b177121473
commit
280b9b01d4
|
@ -1,2 +1,3 @@
|
|||
.build-docker
|
||||
*.swp
|
||||
*.out
|
||||
|
|
|
@ -6,10 +6,15 @@ TEST_RUN=ALL
|
|||
PAUSE=no
|
||||
MICRO_OSD_PATH="/micro-osd.sh"
|
||||
|
||||
CLI="$(getopt -o h --long test-run:,pause,micro-osd:,help -n "$0" -- "$@")"
|
||||
CLI="$(getopt -o h --long test-run:,test-pkg:,pause,micro-osd:,help -n "$0" -- "$@")"
|
||||
eval set -- "${CLI}"
|
||||
while true ; do
|
||||
case "$1" in
|
||||
--test-pkg)
|
||||
TEST_PKG="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--test-run)
|
||||
TEST_RUN="$2"
|
||||
shift
|
||||
|
@ -28,6 +33,7 @@ while true ; do
|
|||
echo "Options:"
|
||||
echo " --test-run=VALUE Run selected test or ALL, NONE"
|
||||
echo " ALL is the default"
|
||||
echo " --test-pkg=PKG Run only tests from PKG"
|
||||
echo " --pause Sleep forever after tests execute"
|
||||
echo " --micro-osd Specify path to micro-osd script"
|
||||
echo " -h|--help Display help text"
|
||||
|
@ -58,18 +64,31 @@ else
|
|||
diff -u <(echo -n) <(gofmt -d -s .)
|
||||
#go vet ./...
|
||||
#go list ./...
|
||||
echo "mode: count" > "cover.out"
|
||||
P=github.com/ceph/go-ceph
|
||||
testargs=(\
|
||||
"-covermode=count" \
|
||||
"-coverprofile=cover.out" \
|
||||
"-coverpkg=$P/cephfs,$P/rados,$P/rbd,$P/errutil")
|
||||
# disable caching of tests results
|
||||
testargs+=("-count=1")
|
||||
if [[ ${TEST_RUN} != ALL ]]; then
|
||||
testargs+=("-run" "${TEST_RUN}")
|
||||
fi
|
||||
pkgs=(\
|
||||
"cephfs" \
|
||||
"errutil" \
|
||||
"rados" \
|
||||
"rbd" \
|
||||
)
|
||||
for pkg in "${pkgs[@]}"; do
|
||||
if [[ "$TEST_PKG" && "$TEST_PKG" != "$pkg" ]]; then
|
||||
continue
|
||||
fi
|
||||
testargs=(\
|
||||
"-covermode=count" \
|
||||
"-coverprofile=$pkg.cover.out" \
|
||||
"-coverpkg=$P/$pkg")
|
||||
# disable caching of tests results
|
||||
testargs+=("-count=1")
|
||||
if [[ ${TEST_RUN} != ALL ]]; then
|
||||
testargs+=("-run" "${TEST_RUN}")
|
||||
fi
|
||||
|
||||
go test -v "${testargs[@]}" ./...
|
||||
go test -v "${testargs[@]}" "./$pkg"
|
||||
grep -v "^mode: count" "$pkg.cover.out" >> "cover.out"
|
||||
done
|
||||
mkdir -p /results/coverage
|
||||
go tool cover -html=cover.out -o /results/coverage/go-ceph.html
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue