tobiko/tools/ci/make_report

49 lines
1.3 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() {
make_report_subunit
make_report_html
make_report_xml
}
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