#!/bin/sh
# Wrapper for the RobotFramework test runner

scriptdir=`dirname "$0"`
. "$scriptdir/testenv.sh" || exit 1
pybot $args

# Some Jenkins plugins (like the Jenkins Performance Plugin) do not take
# testcase fullnames into account. Testnames with identical names but from
# different testsuites are considered a single testcase. This results in
# erroneous reports and graphs. We must patch the xunit file generated by
# RobotFramework and replace testcase names by their full names.

if [ -f xunit.xml ]; then
    echo "Generating XUnit report with full testcase names"
    perl "$VORPALINE_SOURCE_DIR/tools/jenkins/xunit_full_names.pl" xunit.xml > xunit_full_names.xml
fi

# Generate a Cobertura compatible coverage report
# This report will be digested by the Jenkins Cobertura Plugin to display
# coverage graphs

if [ "$VORPALINE_WITH_GCOV" = 1 ]; then
    echo "Generating coverage report"
    gcovr --xml --output=coverage.xml --verbose $VORPALINE_BUILD_DIR > coverage.log
fi
