Skip to content

Commit b074022

Browse files
committed
Unify build process
1 parent bb12d62 commit b074022

File tree

4 files changed

+29
-207
lines changed

4 files changed

+29
-207
lines changed

demo/comprehensive_demo.cpp

Lines changed: 0 additions & 170 deletions
This file was deleted.

rebuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
rm -rf _build && mkdir _build && cd _build && cmake .. && cmake --build .
1+
rm -rf build && mkdir build && cd build && cmake .. && cmake --build .
22

33

run_all_demos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo
1818
# Check if demos are built
1919
if [ ! -d "build/bin" ]; then
2020
echo -e "${RED}Error: build/bin directory not found!${NC}"
21-
echo "Please build the project first with: mkdir -p build && cd build && cmake .. && make"
21+
echo "Please build the project first with: ./rebuild.sh"
2222
exit 1
2323
fi
2424

run_all_tests.sh

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
#!/bin/bash
22

33
# Test runner script for utest library
4-
# Compiles and runs all test*.cpp files in tests/ directory
4+
# Runs all pre-built test binaries from the build directory
55

66
echo "========================================"
77
echo "Running all utest library tests"
88
echo "========================================"
99

1010
# Set up variables
11-
TEST_DIR="tests"
12-
INCLUDE_DIR="include"
11+
BUILD_DIR="build/bin/tests"
1312
FAILED_TESTS=0
1413
TOTAL_TESTS=0
1514
PASS_COUNT=0
1615

16+
# Check if tests are built
17+
if [ ! -d "$BUILD_DIR" ]; then
18+
echo "Error: $BUILD_DIR directory not found!"
19+
echo "Please build the project first with: ./rebuild.sh"
20+
exit 1
21+
fi
22+
1723
# Function to run a single test
1824
run_test() {
19-
local test_file="$1"
20-
local test_name=$(basename "$test_file" .cpp)
21-
local test_exec="$TEST_DIR/$test_name"
25+
local test_exec="$1"
26+
local test_name=$(basename "$test_exec")
2227

2328
echo ""
2429
echo "========================================="
25-
echo "Compiling and running: $test_name"
30+
echo "Running: $test_name"
2631
echo "========================================="
2732

28-
# Compile the test
29-
if g++ -std=c++11 -I "$INCLUDE_DIR" "$test_file" -o "$test_exec" 2>/dev/null; then
30-
echo "✓ Compilation successful"
31-
33+
if [ -f "$test_exec" ]; then
3234
# Run the test and capture exit code
3335
if "$test_exec" > /dev/null 2>&1; then
3436
local exit_code=$?
@@ -46,38 +48,28 @@ run_test() {
4648
fi
4749
fi
4850
else
49-
echo "Compilation failed"
51+
echo "Test executable not found: $test_exec"
5052
((FAILED_TESTS++))
5153
fi
5254

5355
((TOTAL_TESTS++))
54-
55-
# Clean up executable
56-
if [ -f "$test_exec" ]; then
57-
rm "$test_exec"
58-
fi
5956
}
6057

6158
# Function to run detailed test output
6259
run_test_detailed() {
63-
local test_file="$1"
64-
local test_name=$(basename "$test_file" .cpp)
65-
local test_exec="$TEST_DIR/$test_name"
60+
local test_exec="$1"
61+
local test_name=$(basename "$test_exec")
6662

6763
echo ""
6864
echo "========================================="
6965
echo "Running detailed output for: $test_name"
7066
echo "========================================="
7167

72-
# Compile the test
73-
if g++ -std=c++11 -I "$INCLUDE_DIR" "$test_file" -o "$test_exec" 2>/dev/null; then
68+
if [ -f "$test_exec" ]; then
7469
# Run the test with full output
7570
"$test_exec" || true
76-
fi
77-
78-
# Clean up executable
79-
if [ -f "$test_exec" ]; then
80-
rm "$test_exec"
71+
else
72+
echo "✗ Test executable not found: $test_exec"
8173
fi
8274
}
8375

@@ -88,17 +80,17 @@ cd "$(dirname "$0")"
8880
if [[ "$1" == "--detailed" ]] || [[ "$1" == "-d" ]]; then
8981
echo "Running in detailed mode..."
9082

91-
# Find and run all test*.cpp files with detailed output
92-
for test_file in "$TEST_DIR"/test*.cpp; do
93-
if [ -f "$test_file" ]; then
94-
run_test_detailed "$test_file"
83+
# Find and run all test executables with detailed output
84+
for test_exec in "$BUILD_DIR"/test*; do
85+
if [ -f "$test_exec" ]; then
86+
run_test_detailed "$test_exec"
9587
fi
9688
done
9789
else
98-
# Find and run all test*.cpp files
99-
for test_file in "$TEST_DIR"/test*.cpp; do
100-
if [ -f "$test_file" ]; then
101-
run_test "$test_file"
90+
# Find and run all test executables
91+
for test_exec in "$BUILD_DIR"/test*; do
92+
if [ -f "$test_exec" ]; then
93+
run_test "$test_exec"
10294
fi
10395
done
10496

0 commit comments

Comments
 (0)