From fc3ffc95e471016ad672217969889e7bf790dce3 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 11 Oct 2021 13:03:02 -0400 Subject: [PATCH] entrypoint: support executing only implements tool The implements tool just does static code (ast) analysis. Support running it in the container, but on its own in the case you only want the implements tool output. Signed-off-by: John Mulligan --- entrypoint.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3e5161b..afc95b3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -85,7 +85,8 @@ while true ; do ;; -h|--help) echo "Options:" - echo " --test-run=VALUE Run selected test or ALL, NONE" + echo " --test-run=VALUE Run selected test or ALL, NONE," + echo " IMPLEMENTS" echo " ALL is the default" echo " --test-bench=VALUE Run selected benchmarks" echo " --test-pkg=PKG Run only tests from PKG" @@ -239,13 +240,9 @@ pre_all_tests() { echo "mode: count" > "cover.out" } -post_all_tests() { - if [[ ${COVERAGE} = yes ]]; then - mkdir -p "${RESULTS_DIR}/coverage" - show go tool cover -html=cover.out -o "${RESULTS_DIR}/coverage/go-ceph.html" - fi - if [[ ${COVERAGE} = yes ]] && command -v castxml >/dev/null ; then - mkdir -p "${RESULTS_DIR}/coverage" +implements_tool() { + if command -v castxml >/dev/null ; then + mkdir -p "${RESULTS_DIR}" show ./implements --list \ --report-json "${RESULTS_DIR}/implements.json" \ --report-text "${RESULTS_DIR}/implements.txt" \ @@ -255,6 +252,16 @@ post_all_tests() { fi } +post_all_tests() { + if [[ ${COVERAGE} = yes ]]; then + mkdir -p "${RESULTS_DIR}/coverage" + show go tool cover -html=cover.out -o "${RESULTS_DIR}/coverage/go-ceph.html" + fi + if [[ ${COVERAGE} = yes ]]; then + implements_tool + fi +} + test_go_ceph() { mkdir -p /tmp/ceph if ! [[ ${WAIT_FILES} ]]; then @@ -266,6 +273,12 @@ test_go_ceph() { echo "skipping test execution" return 0 fi + if [[ ${TEST_RUN} == IMPLEMENTS ]]; then + echo "skipping tests, executing implements tool" + pre_all_tests + implements_tool + return $? + fi PKG_PREFIX=github.com/ceph/go-ceph pkgs=$(go list ./... | sed -e "s,^${PKG_PREFIX}/\?,," | grep -v ^contrib)