From 25bd9f0bed3698e3c47ec8e236af8a06a72d001c Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 3 Feb 2020 13:47:12 -0500 Subject: [PATCH] entrypoint: wrap main code in a function As preparation for upcoming changes, move the main code of entrypoint.sh into functions. Best viewed by ignore whitespace. Signed-off-by: John Mulligan --- entrypoint.sh | 87 ++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4dddbf5..8142e1c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -51,46 +51,53 @@ while true ; do esac done -mkdir -p /tmp/ceph -"${MICRO_OSD_PATH}" /tmp/ceph -export CEPH_CONF=/tmp/ceph/ceph.conf +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" -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 - 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 + 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 + 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[@]}" "./$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 + 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 +} -if [[ ${PAUSE} = yes ]]; then - sleep infinity -fi +pause_if_needed() { + if [[ ${PAUSE} = yes ]]; then + sleep infinity + fi +} + +test_go_ceph +pause_if_needed