Skip to content

Commit 7fa2f8b

Browse files
committed
Updated documentation and shell scripts
1 parent 579f716 commit 7fa2f8b

File tree

6 files changed

+140
-43
lines changed

6 files changed

+140
-43
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ install_manifest.txt
5050
# Package files
5151
*.deb
5252
*.rpm
53-
*.dmg
53+
*.dmg
54+
55+
# Miscellaneous
56+
*.log
57+
*.tmp
58+
todo.md

README.md

Lines changed: 87 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ cmake --build .
5858
sudo cmake --install .
5959
```
6060

61+
## Helper Scripts
62+
63+
The project includes several helper scripts for common tasks:
64+
65+
- **`rebuild.sh`** - Clean and rebuild the entire project from scratch
66+
- **`run_demos.sh`** - Execute all demo programs sequentially with detailed output and summary
67+
- **`run_tests.sh`** - Run all test executables with summary reporting (use `--detailed` for full output)
68+
- **`build_docs.sh`** - Generate Doxygen documentation in HTML format
69+
70+
Usage examples:
71+
```bash
72+
# Quick rebuild
73+
./rebuild.sh
74+
75+
# Run all demos with colored output
76+
./run_demos.sh
77+
78+
# Run tests with summary only
79+
./run_tests.sh
80+
81+
# Run tests with detailed output
82+
./run_tests.sh --detailed
83+
84+
# Generate documentation
85+
./build_docs.sh
86+
```
87+
6188
## CMake Options
6289

6390
- `UTEST_BUILD_DEMO`: Build the demo project (ON by default)
@@ -139,24 +166,68 @@ See tests in "tests" subdirectory and the "demo" directory for more examples.
139166

140167
## Demo Project
141168

142-
The demo project demonstrates various aspects of the library:
143-
- Basic assertions (equality, true/false)
144-
- Assertions with custom error messages
145-
- Testing exceptions
146-
- Complex test scenarios with collections
169+
The demo project demonstrates various aspects of the library across multiple executable demos:
170+
171+
### Available Demos
172+
173+
#### 1. Core Features Demo (`utest_demo`)
174+
- **File**: `demo_core_features.cpp`
175+
- **Executable**: `./bin/utest_demo`
176+
- **Features demonstrated**:
177+
- Basic assertions (equality, true/false)
178+
- Assertions with custom error messages
179+
- Exception testing with lambda functions
180+
- Complex test scenarios with collections and vectors
181+
- String comparisons and container operations
182+
183+
#### 2. Unicode Checkmarks Demo (`demo_unicode_checkmarks`)
184+
- **File**: `demo_unicode_checkmarks.cpp`
185+
- **Executable**: `./bin/demo_unicode_checkmarks`
186+
- **Features demonstrated**:
187+
- Default Unicode checkmark output format
188+
- Test grouping with `UTEST_FUNC_DEF2` syntax
189+
- Multiple grouped test scenarios
190+
- Various assertion types (GT, GTE, NEQ, etc.)
191+
192+
#### 3. Verbose Mode Demo (`demo_verbose_mode`)
193+
- **File**: `demo_verbose_mode.cpp`
194+
- **Executable**: `./bin/demo_verbose_mode`
195+
- **Features demonstrated**:
196+
- Verbose output mode showing test names before execution
197+
- Performance timing measurements
198+
- Grouped test organization and display
199+
- Test progress tracking
200+
201+
#### 4. Failure Handling Demo (`demo_with_failure`)
202+
- **File**: `demo_with_failure.cpp`
203+
- **Executable**: `./bin/demo_with_failure`
204+
- **Features demonstrated**:
205+
- Intentional test failures for error reporting demonstration
206+
- Comprehensive error messages with file/line information
207+
- Mixed passing and failing tests in the same runner
208+
- Error handling and exit code behavior
209+
210+
#### 5. No Tests Scenario Demo (`demo_no_tests`)
211+
- **File**: `demo_no_tests.cpp`
212+
- **Executable**: `./bin/demo_no_tests`
213+
- **Features demonstrated**:
214+
- Behavior when no tests are registered or executed
215+
- Default failure handling for empty test suites
216+
- Use of `UTEST_ALLOW_EMPTY_TESTS()` for conditional testing
147217

148218
To run all demos:
149219
```bash
150220
mkdir _build && cd _build
151221
cmake ..
152222
cmake --build .
153-
./run_all_demos.sh
223+
./run_demos.sh
154224
```
155225

156226
To run individual demos:
157227
```bash
158228
./bin/utest_demo # Core features demo
159-
./bin/demo_unicode_checkmarks # Unicode checkmarks demo
229+
./bin/demo_unicode_checkmarks # Unicode checkmarks demo
230+
./bin/demo_verbose_mode # Verbose mode demo
160231
./bin/demo_with_failure # Failure handling demo
161232
./bin/demo_no_tests # No tests scenario demo
162233
```
@@ -208,7 +279,7 @@ make: *** [Makefile:84: test] Error 8
208279

209280
### Configuration Macros
210281
- `UTEST_ALLOW_EMPTY_TESTS()` - Allow test runner to succeed even when no tests are run
211-
- `UTEST_USE_ASCII_CHECKMARKS()` - Use ASCII [OK]/[FAIL] instead of Unicode ✓/✗
282+
- `UTEST_USE_ASCII_CHECKMARKS()` - Use ASCII [OK]/[FAIL] instead of Unicode checkmarks
212283
- `UTEST_SHOW_PERFORMANCE()` - Enable performance timing for each test
213284
- `UTEST_ENABLE_VERBOSE_MODE()` - Show test names before execution (useful for debugging)
214285

@@ -246,9 +317,9 @@ make: *** [Makefile:84: test] Error 8
246317

247318
## Build Organization
248319

249-
The build system now organizes binaries into dedicated subdirectories:
320+
The build system organizes binaries into dedicated subdirectories:
250321
- Main demo: `bin/utest_demo`
251-
- Additional demos: `bin/demo_with_failure`, `bin/demo_no_tests`
322+
- Additional demos: `bin/demo_unicode_checkmarks`, `bin/demo_verbose_mode`, `bin/demo_with_failure`, `bin/demo_no_tests`
252323
- Tests: `bin/tests/test_*`
253324

254325
## Handling No Tests Scenario
@@ -290,8 +361,8 @@ UTEST_FUNC2(ModuleA, Feature2);
290361
In the test summary, tests with the same group name will be displayed together:
291362
```
292363
ModuleA:
293-
Feature1
294-
Feature2
364+
[OK] Feature1
365+
[OK] Feature2
295366
```
296367
297368
### Performance Timing
@@ -306,7 +377,7 @@ UTEST_EPILOG();
306377

307378
Output will show timing information:
308379
```
309-
Test [my_test] succeeded (1.234ms)
380+
[OK] Test [my_test] succeeded (1.234ms)
310381
```
311382

312383
### Verbose Mode
@@ -322,21 +393,21 @@ UTEST_EPILOG();
322393
Output will show test names before execution:
323394
```
324395
Running test: my_test
325-
Test [my_test] succeeded (1.234ms)
396+
[OK] Test [my_test] succeeded (1.234ms)
326397
```
327398
328399
For grouped tests:
329400
```
330401
Running test: GroupName::TestName
331-
Test [GroupName::TestName] succeeded (1.234ms)
402+
[OK] Test [GroupName::TestName] succeeded (1.234ms)
332403
```
333404
334405
### ASCII Checkmarks
335406
For environments that don't support Unicode characters:
336407
337408
```cpp
338409
UTEST_PROLOG();
339-
UTEST_USE_ASCII_CHECKMARKS(); // Use [OK]/[FAIL] instead of ✓/✗
410+
UTEST_USE_ASCII_CHECKMARKS(); // Use [OK]/[FAIL] instead of Unicode checkmarks
340411
UTEST_FUNC(my_test);
341412
UTEST_EPILOG();
342413
```

build_docs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ doxygen Doxyfile
4949

5050
if [ $? -eq 0 ]; then
5151
echo
52-
echo -e "${GREEN} Documentation generated successfully!${NC}"
52+
echo -e "${GREEN}[OK] Documentation generated successfully!${NC}"
5353
echo
5454
echo -e "${BLUE}Documentation location:${NC}"
5555
echo " HTML: $(pwd)/docs/html/index.html"
@@ -68,7 +68,7 @@ if [ $? -eq 0 ]; then
6868
fi
6969
fi
7070
else
71-
echo -e "${RED} Documentation generation failed!${NC}"
71+
echo -e "${RED}[FAIL] Documentation generation failed!${NC}"
7272
echo "Check the Doxygen output above for error details."
7373
exit 1
7474
fi

rebuild.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
rm -rf build && mkdir build && cd build && cmake .. && cmake --build .
1+
#!/bin/bash
2+
3+
echo "========================================"
4+
echo "Rebuilding utest library project"
5+
echo "========================================"
6+
7+
echo "Cleaning previous build..."
8+
rm -rf build && mkdir build && cd build
9+
10+
echo "Configuring with CMake..."
11+
cmake ..
12+
13+
echo "Building project..."
14+
cmake --build .
15+
16+
echo "Build completed successfully!"
217

318

run_all_demos.sh renamed to run_demos.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# run_all_demos.sh - Script to run all demo programs for utest library
3+
# run_demos.sh - Script to run all demo programs for utest library
44

55
# Colors for output
66
RED='\033[0;31m'
@@ -43,28 +43,28 @@ run_demo() {
4343
if [ "$demo_name" = "demo_with_failure" ]; then
4444
# This demo is expected to fail
4545
if [ $exit_code -ne 0 ]; then
46-
echo -e "${YELLOW} Demo completed with expected failure (exit code: $exit_code)${NC}"
46+
echo -e "${YELLOW}[WARNING] Demo completed with expected failure (exit code: $exit_code)${NC}"
4747
return 0
4848
else
49-
echo -e "${RED} Demo was expected to fail but succeeded (exit code: $exit_code)${NC}"
49+
echo -e "${RED}[FAIL] Demo was expected to fail but succeeded (exit code: $exit_code)${NC}"
5050
return 1
5151
fi
5252
elif [ "$demo_name" = "demo_no_tests" ]; then
5353
# This demo might succeed or fail depending on configuration
54-
echo -e "${GREEN} Demo completed (exit code: $exit_code)${NC}"
54+
echo -e "${GREEN}[OK] Demo completed (exit code: $exit_code)${NC}"
5555
return 0
5656
else
5757
# Normal demos should succeed
5858
if [ $exit_code -eq 0 ]; then
59-
echo -e "${GREEN} Demo completed successfully${NC}"
59+
echo -e "${GREEN}[OK] Demo completed successfully${NC}"
6060
return 0
6161
else
62-
echo -e "${RED} Demo failed unexpectedly (exit code: $exit_code)${NC}"
62+
echo -e "${RED}[FAIL] Demo failed unexpectedly (exit code: $exit_code)${NC}"
6363
return 1
6464
fi
6565
fi
6666
else
67-
echo -e "${RED} Demo executable not found: $demo_path${NC}"
67+
echo -e "${RED}[FAIL] Demo executable not found: $demo_path${NC}"
6868
return 1
6969
fi
7070

@@ -81,22 +81,27 @@ echo -e "${YELLOW}Running all utest framework demos...${NC}"
8181
echo
8282

8383
# Main demo - core functionality
84-
echo -e "${BLUE}>>> Demo 1/4: Core Features${NC}"
84+
echo -e "${BLUE}>>> Demo 1/5: Core Features${NC}"
8585
((TOTAL_DEMOS++))
8686
run_demo "utest_demo" "Core Features Demo" || ((FAILED_DEMOS++))
8787

8888
# Unicode checkmarks demo
89-
echo -e "${BLUE}>>> Demo 2/4: Unicode Checkmarks${NC}"
89+
echo -e "${BLUE}>>> Demo 2/5: Unicode Checkmarks${NC}"
9090
((TOTAL_DEMOS++))
9191
run_demo "demo_unicode_checkmarks" "Unicode Checkmarks Demo" || ((FAILED_DEMOS++))
9292

93+
# Verbose mode demo
94+
echo -e "${BLUE}>>> Demo 3/5: Verbose Mode${NC}"
95+
((TOTAL_DEMOS++))
96+
run_demo "demo_verbose_mode" "Verbose Mode Demo" || ((FAILED_DEMOS++))
97+
9398
# Failure handling demo
94-
echo -e "${BLUE}>>> Demo 3/4: Failure Handling${NC}"
99+
echo -e "${BLUE}>>> Demo 4/5: Failure Handling${NC}"
95100
((TOTAL_DEMOS++))
96101
run_demo "demo_with_failure" "Failure Handling Demo" || ((FAILED_DEMOS++))
97102

98103
# No tests scenario demo
99-
echo -e "${BLUE}>>> Demo 4/4: No Tests Scenario${NC}"
104+
echo -e "${BLUE}>>> Demo 5/5: No Tests Scenario${NC}"
100105
((TOTAL_DEMOS++))
101106
run_demo "demo_no_tests" "No Tests Scenario Demo" || ((FAILED_DEMOS++))
102107

@@ -106,7 +111,7 @@ echo -e "${BLUE} Demo Summary${NC}"
106111
echo -e "${BLUE}===============================================${NC}"
107112

108113
if [ $FAILED_DEMOS -eq 0 ]; then
109-
echo -e "${GREEN} All $TOTAL_DEMOS demos completed successfully!${NC}"
114+
echo -e "${GREEN}[OK] All $TOTAL_DEMOS demos completed successfully!${NC}"
110115
echo
111116
echo -e "${CYAN}The utest framework is working correctly and ready for use.${NC}"
112117
echo
@@ -117,12 +122,13 @@ if [ $FAILED_DEMOS -eq 0 ]; then
117122
echo " • Performance timing with microsecond precision"
118123
echo " • Test grouping and organization"
119124
echo " • Configurable output formats (ASCII/Unicode)"
120-
echo " • Comprehensive error reporting"
121-
echo " • Robust failure handling"
125+
echo " • Verbose mode for detailed test execution tracking"
126+
echo " • Comprehensive error reporting and failure handling"
127+
echo " • Empty test suite scenarios and configuration"
122128
echo
123-
echo -e "${GREEN}All demos completed successfully! 🎉${NC}"
129+
echo -e "${GREEN}All demos completed successfully!${NC}"
124130
else
125-
echo -e "${RED} $FAILED_DEMOS out of $TOTAL_DEMOS demos failed${NC}"
131+
echo -e "${RED}[FAIL] $FAILED_DEMOS out of $TOTAL_DEMOS demos failed${NC}"
126132
echo
127133
echo -e "${YELLOW}Please check the output above for details.${NC}"
128134
exit 1

run_all_tests.sh renamed to run_tests.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Test runner script for utest library
3+
# run_tests.sh - Test runner script for utest library
44
# Runs all pre-built test binaries from the build directory
55

66
echo "========================================"
@@ -34,11 +34,11 @@ run_test() {
3434
# Run the test and capture exit code
3535
if "$test_exec" > /dev/null 2>&1; then
3636
local exit_code=$?
37-
echo " Test execution successful (exit code: $exit_code)"
37+
echo "[OK] Test execution successful (exit code: $exit_code)"
3838
((PASS_COUNT++))
3939
else
4040
local exit_code=$?
41-
echo " Test execution failed (exit code: $exit_code)"
41+
echo "[FAIL] Test execution failed (exit code: $exit_code)"
4242
# For tests designed to fail (like test_no_tests), this is expected
4343
if [[ "$test_name" == "test_no_tests" ]] || [[ "$test_name" == *"failure"* ]]; then
4444
echo " (This test is designed to fail - expected behavior)"
@@ -48,7 +48,7 @@ run_test() {
4848
fi
4949
fi
5050
else
51-
echo " Test executable not found: $test_exec"
51+
echo "[FAIL] Test executable not found: $test_exec"
5252
((FAILED_TESTS++))
5353
fi
5454

@@ -69,7 +69,7 @@ run_test_detailed() {
6969
# Run the test with full output
7070
"$test_exec" || true
7171
else
72-
echo " Test executable not found: $test_exec"
72+
echo "[FAIL] Test executable not found: $test_exec"
7373
fi
7474
}
7575

@@ -104,10 +104,10 @@ else
104104
echo "Passed tests: $PASS_COUNT"
105105

106106
if [ $FAILED_TESTS -eq 0 ]; then
107-
echo " All tests passed!"
107+
echo "[OK] All tests passed!"
108108
exit 0
109109
else
110-
echo " Some tests failed!"
110+
echo "[FAIL] Some tests failed!"
111111
echo ""
112112
echo "Run with --detailed flag to see full test output"
113113
exit 1

0 commit comments

Comments
 (0)