tobiko/tools/ci/make_report
Federico Ressi 5a41476432 Separate run_tox and make_report tasks
Change-Id: Ic064cdaa2b001358f3748b433baa1f9055db940a
2020-03-23 20:25:24 +00:00

51 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Produce test HTML report file into ${REPORT_DIR}
set -eu
# Imput paths
TOBIKO_TOX_DIR=${TOBIKO_TOX_DIR:-$(pwd)}
# Output dirs
TOBIKO_TEST_REPORT_DIR=${TOBIKO_TEST_REPORT_DIR:-${TOBIKO_TOX_DIR}}
# Output files
TOBIKO_TEST_REPORT_NAME=${TOBIKO_TEST_REPORT_NAME:-tobiko_results}
TOBIKO_TEST_REPORT_SUBUNIT=${TOBIKO_TEST_REPORT_SUBUNIT:-${TOBIKO_TEST_REPORT_DIR}/${TOBIKO_TEST_REPORT_NAME}.subunit}
TOBIKO_TEST_REPORT_HTML=${TOBIKO_TEST_REPORT_HTML:-${TOBIKO_TEST_REPORT_DIR}/${TOBIKO_TEST_REPORT_NAME}.html}
TOBIKO_TEST_REPORT_XML=${TOBIKO_TEST_REPORT_XML:-${TOBIKO_TEST_REPORT_DIR}/${TOBIKO_TEST_REPORT_NAME}.xml}
function make_report() {
if [[ -f .stestr/failing ]]; then
make_report_subunit
make_report_html
make_report_xml
fi
}
function make_report_subunit() {
mkdir -p $(dirname "${TOBIKO_TEST_REPORT_SUBUNIT}")
(
cd "${TOBIKO_TOX_DIR}"
stestr last --subunit --force-subunit-trace --all-attachments
) > "${TOBIKO_TEST_REPORT_SUBUNIT}"
}
function make_report_html() {
mkdir -p $(dirname "${TOBIKO_TEST_REPORT_HTML}")
subunit2html "${TOBIKO_TEST_REPORT_SUBUNIT}" "${TOBIKO_TEST_REPORT_HTML}" > /dev/null
}
function make_report_xml() {
mkdir -p $(dirname "${TOBIKO_TEST_REPORT_XML}")
subunit2junitxml "${TOBIKO_TEST_REPORT_SUBUNIT}" -o "${TOBIKO_TEST_REPORT_XML}" || true
}
make_report