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 <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2021-10-11 13:03:02 -04:00 committed by mergify[bot]
parent 689ee58bf8
commit fc3ffc95e4
1 changed files with 21 additions and 8 deletions

View File

@ -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)