Skip to content

Commit ae0de54

Browse files
committed
Fix run-tests.sh to auto-detect CMake build directory for CI compatibility
1 parent b0cd26a commit ae0de54

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

test-high/run-tests.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,37 @@
1919
# For additional information about the PCG random number generation scheme,
2020
# visit http://www.pcg-random.org/.
2121
#
22-
# Determine where the executables are (standard Makefile behavior)
22+
# Determine where the executables are
23+
# Priority: Current Dir (Makefile) -> ../build/test-high (CMake)
2324
BASEDIR=$(dirname "$0")
2425
cd "$BASEDIR"
2526

2627
BINDIR="."
2728

29+
# Check if executables are in current directory (Makefile build)
30+
if [ ! -f "./check-pcg32" ] && [ ! -f "./check-pcg32.exe" ]; then
31+
# Try CMake build directories
32+
if [ -f "../build/test-high/check-pcg32" ]; then
33+
BINDIR="../build/test-high"
34+
elif [ -f "../build/test-high/Release/check-pcg32.exe" ]; then
35+
BINDIR="../build/test-high/Release"
36+
elif [ -f "../build/test-high/Debug/check-pcg32.exe" ]; then
37+
BINDIR="../build/test-high/Debug"
38+
else
39+
echo "ERROR: Cannot find test executables. Please build the project first." >&2
40+
exit 1
41+
fi
42+
fi
43+
2844
# Function to run a test, handling potential .exe extension
2945
run_test() {
3046
TEST_NAME=$1
31-
if [ -f "./$TEST_NAME.exe" ]; then
32-
"./$TEST_NAME.exe"
33-
elif [ -f "./$TEST_NAME" ]; then
34-
"./$TEST_NAME"
47+
if [ -f "$BINDIR/$TEST_NAME.exe" ]; then
48+
"$BINDIR/$TEST_NAME.exe"
49+
elif [ -f "$BINDIR/$TEST_NAME" ]; then
50+
"$BINDIR/$TEST_NAME"
3551
else
36-
echo "ERROR: $TEST_NAME not found in $PWD" >&2
52+
echo "ERROR: $TEST_NAME not found in $BINDIR" >&2
3753
return 1
3854
fi
3955
}

0 commit comments

Comments
 (0)