mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
Merge pull request #3673 from jet47:colorize-run-test-script-3.0
This commit is contained in:
commit
5524e8d2c0
@ -1,25 +1,99 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Text style
|
||||
|
||||
TEXT_RED="$(tput setaf 1)"
|
||||
TEXT_GREEN="$(tput setaf 2)"
|
||||
TEXT_CYAN="$(tput setaf 6)"
|
||||
TEXT_RESET="$(tput sgr0)"
|
||||
|
||||
# Test binaries and data paths
|
||||
|
||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
# Run tests
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
FAILED_TESTS=""
|
||||
PASSED_TESTS=""
|
||||
|
||||
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*;
|
||||
do
|
||||
report="`basename "$t"`-`date --rfc-3339=date`.xml"
|
||||
"$t" --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:"$report"
|
||||
TEST_STATUS=$?
|
||||
if [ $TEST_STATUS -ne 0 ]; then
|
||||
SUMMARY_STATUS=$TEST_STATUS
|
||||
fi
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
cmd="$t --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:\"$report\""
|
||||
|
||||
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
||||
seg_reg="${seg_reg};s/\[==========\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [==========]
|
||||
seg_reg="${seg_reg};s/\[----------\]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [----------]
|
||||
seg_reg="${seg_reg};s/\[ RUN \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ RUN ]
|
||||
seg_reg="${seg_reg};s/\[ OK \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ OK ]
|
||||
seg_reg="${seg_reg};s/\[ FAILED \]/${TEXT_RED}&${TEXT_RESET}/g" # red for [ FAILED ]
|
||||
seg_reg="${seg_reg};s/\[ PASSED \]/${TEXT_GREEN}&${TEXT_RESET}/g" # green for [ PASSED ]
|
||||
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
||||
eval "$cmd" | sed -r "$seg_reg"
|
||||
|
||||
ret=${PIPESTATUS[0]}
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
||||
|
||||
if [ $ret -ne 0 ]; then
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}"
|
||||
SUMMARY_STATUS=1
|
||||
FAILED_TESTS="$FAILED_TESTS $test_name"
|
||||
else
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}"
|
||||
PASSED_TESTS="$PASSED_TESTS $test_name"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
for t in $OPENCV_PYTHON_TESTS;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
cmd="py.test --junitxml $report \"$OPENCV_TEST_PATH\"/$t"
|
||||
|
||||
seg_reg="s/^/${TEXT_CYAN}[$test_name]${TEXT_RESET} /" # append test name
|
||||
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RUN : $cmd"
|
||||
eval "$cmd" | sed -r "$seg_reg"
|
||||
|
||||
ret=${PIPESTATUS[0]}
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} RETURN_CODE : $ret"
|
||||
|
||||
if [ $ret -ne 0 ]; then
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_RED}FAILED${TEXT_RESET}"
|
||||
SUMMARY_STATUS=1
|
||||
FAILED_TESTS="$FAILED_TESTS $test_name"
|
||||
else
|
||||
echo "${TEXT_CYAN}[$test_name]${TEXT_RESET} ${TEXT_GREEN}OK${TEXT_RESET}"
|
||||
PASSED_TESTS="$PASSED_TESTS $test_name"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
# Remove temporary test files
|
||||
|
||||
rm -f /tmp/__opencv_temp.*
|
||||
|
||||
# Report final status
|
||||
|
||||
echo "${TEXT_CYAN}===============================================================${TEXT_RESET}"
|
||||
echo "${TEXT_CYAN}PASSED TESTS : $PASSED_TESTS${TEXT_RESET}"
|
||||
echo "${TEXT_CYAN}FAILED TESTS : $FAILED_TESTS${TEXT_RESET}"
|
||||
if [ $SUMMARY_STATUS -eq 0 ]; then
|
||||
echo "All OpenCV tests finished successfully"
|
||||
echo "${TEXT_GREEN}STATUS : OK${TEXT_RESET}"
|
||||
echo "${TEXT_GREEN}STATUS : All OpenCV tests finished successfully${TEXT_RESET}"
|
||||
else
|
||||
echo "OpenCV tests finished with status $SUMMARY_STATUS"
|
||||
echo "${TEXT_RED}STATUS : FAIL${TEXT_RESET}"
|
||||
echo "${TEXT_RED}STATUS : OpenCV tests finished with status $SUMMARY_STATUS${TEXT_RESET}"
|
||||
fi
|
||||
|
||||
return $SUMMARY_STATUS
|
||||
exit $SUMMARY_STATUS
|
||||
|
Loading…
Reference in New Issue
Block a user