Merge pull request #30176 from taosdata/fix/unit-no-test

test: enhance unit test script with output logging and error handling
This commit is contained in:
WANG Xu 2025-03-15 14:53:05 +08:00 committed by GitHub
commit 779668bb62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# set -x
function usage() { function usage() {
echo "$0" echo "$0"
echo -e "\t -e enterprise edition" echo -e "\t -e enterprise edition"
@ -24,24 +24,36 @@ while getopts "e:h" opt; do
esac esac
done done
script_dir=`dirname $0` script_dir=$(dirname "$0")
cd ${script_dir} cd "${script_dir}"
PWD=`pwd` PWD=$(pwd)
if [ $ent -eq 0 ]; then if [ $ent -eq 0 ]; then
cd ../../debug cd ../../debug
else else
cd ../../../debug cd ../../../debug
fi fi
PWD=$(pwd)
echo "PWD: $PWD"
set -e set -e
pgrep taosd || taosd >> /dev/null 2>&1 & pgrep taosd || taosd >> /dev/null 2>&1 &
sleep 10 sleep 10
ctest -E "cunit_test" -j8 # Run ctest and capture output and return code
ctest_output="unit-test.log"
ctest -E "cunit_test" -j8 2>&1 | tee "$ctest_output"
ctest_ret=${PIPESTATUS[0]}
ret=$? # Read the captured output
exit $ret ctest_output=$(cat "$ctest_output")
# Check if ctest failed or no tests were found
if [ $ctest_ret -ne 0 ]; then
echo "ctest failed, failing the script."
exit 1
elif echo "$ctest_output" | grep -q "No tests were found"; then
echo "No tests were found, failing the script."
exit 1
fi