Skip to content

Commit

Permalink
#95: add option to build script to run tests using xvbf
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Aug 27, 2024
1 parent 191407c commit e265208
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ VT_TV_COVERAGE_ENABLED=$(on_off ${VT_TV_COVERAGE_ENABLED:-OFF})
VT_TV_CLEAN=$(on_off ${VT_TV_CLEAN:-ON})
VT_TV_PYTHON_BINDINGS_ENABLED=$(on_off ${VT_TV_PYTHON_BINDINGS_ENABLED:-OFF})
VT_TV_WERROR_ENABLED=$(on_off ${VT_TV_WERROR_ENABLED:-OFF})
VT_TV_XVFB_ENABLED=$(on_off ${VT_TV_WERROR_ENABLED:-OFF})
# >> Run tests settings
VT_TV_RUN_TESTS=$(on_off ${VT_TV_RUN_TESTS:-OFF})
VT_TV_RUN_TESTS_FILTER=${VT_TV_RUN_TESTS_FILTER:-""}
Expand Down Expand Up @@ -76,6 +77,8 @@ help() {
-r --tests-run=[bool] Run unit tests (and build coverage report if coverage is enabled) (VT_TV_RUN_TESTS=$VT_TV_RUN_TESTS)
-f --tests-run-filter=[str] Filter unit test to run. (VT_TV_RUN_TESTS_FILTER=$VT_TV_RUN_TESTS_FILTER)
-x --xvfb=[bool] Use X Virtual Frame Buffer instead of default for rendering (VT_TV_XVFB_ENABLED=$VT_TV_XVFB_ENABLED)
-h --help Show help and default option values.
Examples:
Expand Down Expand Up @@ -123,6 +126,7 @@ while getopts btch-: OPT; do # allow -b -t -c -h, and --long_attr=value"
r | tests-run ) VT_TV_RUN_TESTS=$(on_off $OPTARG) ;;
f | tests-run-filter) VT_TV_RUN_TESTS_FILTER="$OPTARG" ;;
k | vtk-dir ) VTK_DIR=$(realpath "$OPTARG") ;;
x | xvfb ) VT_TV_XVFB_ENABLED=$(on_off $OPTARG) ;;
h | help ) help ;;

\? ) exit 2 ;; # bad short option (error reported via getopts)
Expand All @@ -142,6 +146,7 @@ echo VT_TV_PYTHON_BINDINGS_ENABLED=$VT_TV_PYTHON_BINDINGS_ENABLED
echo VT_TV_RUN_TESTS=$VT_TV_RUN_TESTS
echo VT_TV_TESTS_ENABLED=$VT_TV_TESTS_ENABLED
echo VT_TV_TEST_REPORT=$VT_TV_TEST_REPORT
echo VT_TV_XVFB_ENABLED=$VT_TV_XVFB_ENABLED
echo VT_TV_RUN_TESTS_FILTER=$VT_TV_RUN_TESTS_FILTER
echo VT_TV_COVERAGE_ENABLED=$VT_TV_COVERAGE_ENABLED
echo VT_TV_COVERAGE_REPORT=$VT_TV_COVERAGE_REPORT
Expand Down Expand Up @@ -208,10 +213,20 @@ if [[ "$VT_TV_RUN_TESTS" == "ON" ]]; then

gtest_cmd="\"$VT_TV_BUILD_DIR/tests/unit/AllTests\" $GTEST_OPTIONS"
echo "Run GTest..."

CURRENT_DISPLAY=$(echo $DISPLAY)
if [[ "$VT_TV_RUN_TESTS" == "ON" ]]; then
export DISPLAY=:99.0
Xvfb :99 -screen 0 1024x768x24 -nolisten tcp > /dev/null 2>&1 &
sleep 1s
fi
eval "$gtest_cmd" || true
if [[ "$VT_TV_RUN_TESTS" == "ON" ]]; then
pkill Xvfb
export DISPLAY=$CURRENT_DISPLAY
fi

echo "Tests done."

popd
fi

Expand Down

0 comments on commit e265208

Please sign in to comment.