set -e

source hack/common.sh
source hack/config.sh

if [ "${CI}" == "true" ]; then
    cat >>ci.bazelrc <<EOF
test --cache_test_results=no --runs_per_test=1
EOF
fi

rm -rf ${ARTIFACTS}/junit ${ARTIFACTS}/testlogs

function collect_results() {
    cd ${KUBEVIRT_DIR}
    mkdir -p ${ARTIFACTS}/junit/
    bazel run //tools/junit-merger:junit-merger -- -o ${ARTIFACTS}/junit/junit.unittests.xml $(find bazel-testlogs/ -name 'test.xml' -printf "%p ")

    for f in $(find bazel-out/ -name 'test.log'); do
        dir=${ARTIFACTS}/testlogs/$(dirname $f)
        mkdir -p ${dir}
        cp -f ${f} ${dir}/test.log
    done
}

trap collect_results EXIT

bazel test \
    --config=${ARCHITECTURE} \
    --features race \
    --test_output=errors -- //staging/src/kubevirt.io/client-go/... //pkg/... //cmd/... //tests/framework/...

set -e

source hack/common.sh
source hack/config.sh

rm -rf ${ARTIFACTS}/junit ${ARTIFACTS}/testlogs

if [ "${CI}" == "true" ]; then
    cat >>ci.bazelrc <<EOF
test --cache_test_results=no --runs_per_test=1
EOF

    function collect_results() {
        cd ${KUBEVIRT_DIR}
        mkdir -p ${ARTIFACTS}/junit/
        bazel run //tools/junit-merger:junit-merger -- -o ${ARTIFACTS}/junit/junit.unittests.xml $(find bazel-testlogs/ -name 'test.xml' -printf "%p ")

        for f in $(find bazel-out/ -name 'test.log'); do
            dir=${ARTIFACTS}/testlogs/$(dirname $f)
            mkdir -p ${dir}
            cp -f ${f} ${dir}/test.log
        done
    }
    trap collect_results EXIT
fi

bazel test \
    --config=${ARCHITECTURE} \
    --features race \
    --test_output=errors -- //staging/src/kubevirt.io/client-go/... //pkg/... //cmd/... //tests/framework/...

Move duplication check to CI only
Move duplication check to CI only

This is slightly inconvenient, but locally in `bazel-testlogs` there are
sometimes stale entries from moved packages which make the check fail.
It is inconveninent to be not informed locally, but at least on CI it is
right now 100% correct.

This should be a temporary measure. We can check for non-existing
packages in `bazel-buildlogs` and remove them on the long run.

Signed-off-by: Roman Mohr <6da0130c5aeef94e5bbaabadbf8017270be25c64@redhat.com>
