Skip to content

Commit 8df63c3

Browse files
committed
make formatter output test part of integration
1 parent 0b250f0 commit 8df63c3

5 files changed

Lines changed: 63 additions & 39 deletions

File tree

.github/workflows/linux-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ jobs:
136136
- name: Run Integration Tests
137137
run: |
138138
chmod +x test/integration/run_test.sh
139+
chmod +x test/integration/test_formatter_stdout.sh
139140
./test/integration/run_test.sh
140141
141142
# ---------------------------------------------------------

GEMINI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ctest
8181

8282
There is also a script to test the formatter's stdout functionality:
8383
```bash
84-
./test_formatter_stdout.sh
84+
./test/integration/test_formatter_stdout.sh
8585
```
8686
8787
### Running the CLI Tools

test/integration/run_test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ if ! grep -q -e "--- ITINERARIES ---" "$SUMMARY_TXT"; then
6666
exit 1
6767
fi
6868

69-
echo "All checks passed."
69+
echo "All checks passed for file output mode."
7070

7171
# Cleanup
7272
rm "$SOLUTION_JSON" "$SUMMARY_TXT"
7373

74+
echo "Running stdout formatter test..."
75+
./test/integration/test_formatter_stdout.sh
76+
7477
echo "Integration test passed!"
7578
exit 0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# Test the formatter's ability to print to stdout
3+
4+
# Exit on error
5+
set -e
6+
7+
# Path to the executables
8+
BUILD_DIR="build"
9+
FORMATTER="$BUILD_DIR/jres_formatter"
10+
SOLVER="$BUILD_DIR/jres_solver"
11+
INPUT_FILE="data/24h_race.json"
12+
SOLUTION_FILE="/tmp/test_solution_stdout.json"
13+
14+
# Make sure we are in the project root
15+
if [ ! -f "CMakeLists.txt" ]; then
16+
echo "Error: This script must be run from the project root directory."
17+
exit 1
18+
fi
19+
20+
# Make sure binaries exist
21+
if [ ! -f "$SOLVER" ]; then
22+
echo "Error: Solver binary not found at $SOLVER. Build the project first."
23+
exit 1
24+
fi
25+
if [ ! -f "$FORMATTER" ]; then
26+
echo "Error: Formatter binary not found at $FORMATTER. Build the project first."
27+
exit 1
28+
fi
29+
30+
# Cleanup previous runs
31+
rm -f "$SOLUTION_FILE"
32+
33+
echo "Running solver to generate solution..."
34+
$SOLVER -i $INPUT_FILE -s sequential -o $SOLUTION_FILE --quiet
35+
36+
if [ ! -f "$SOLUTION_FILE" ]; then
37+
echo "Error: Solver failed to generate solution file."
38+
exit 1
39+
fi
40+
41+
echo "Running formatter without -o flag..."
42+
# Run the formatter and capture stdout
43+
OUTPUT=$($FORMATTER -i "$SOLUTION_FILE")
44+
45+
# Check if the output contains expected strings from the summary report
46+
if [[ "$OUTPUT" == *"--- DRIVER SUMMARY ---"* ]] && [[ "$OUTPUT" == *"--- SCHEDULE ---"* ]]; then
47+
echo "Success: Formatter output to stdout detected."
48+
else
49+
echo "Error: Formatter did not print expected summary to stdout."
50+
echo "Output was:"
51+
echo "$OUTPUT"
52+
exit 1
53+
fi
54+
55+
# Clean up
56+
rm "$SOLUTION_FILE"
57+
exit 0

test_formatter_stdout.sh

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

0 commit comments

Comments
 (0)