summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 17:35:53 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 17:35:53 +0100
commit28a12a7a7f367e8f2a309f7ebb297bab94d610c7 (patch)
tree65950fa6df7b5a6412d5dbe52645ca2324d0da0c /scripts
parent9583dcc3d7b84e77a8a4d658c737ccba2a250373 (diff)
test: Add HTML Gantt chart output test for seq_compiler
- Created test_gantt_html.sh: bash script that verifies HTML/SVG output - Checks for: HTML structure, title, h1 heading, SVG elements, rectangles, text labels - Added GanttHtmlOutputTest to CMake test suite - Reuses test_gantt.seq from previous test All 30 tests pass (was 29).
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/test_gantt_html.sh102
1 files changed, 102 insertions, 0 deletions
diff --git a/scripts/test_gantt_html.sh b/scripts/test_gantt_html.sh
new file mode 100755
index 0000000..d7a5777
--- /dev/null
+++ b/scripts/test_gantt_html.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+# Test script for seq_compiler HTML Gantt chart output
+
+set -e # Exit on error
+
+# Arguments
+SEQ_COMPILER=$1
+INPUT_SEQ=$2
+OUTPUT_HTML=$3
+
+if [ -z "$SEQ_COMPILER" ] || [ -z "$INPUT_SEQ" ] || [ -z "$OUTPUT_HTML" ]; then
+ echo "Usage: $0 <seq_compiler> <input.seq> <output.html>"
+ exit 1
+fi
+
+# Clean up any existing output
+rm -f "$OUTPUT_HTML"
+
+# Run seq_compiler with HTML Gantt output
+"$SEQ_COMPILER" "$INPUT_SEQ" "--gantt-html=$OUTPUT_HTML" > /dev/null 2>&1
+
+# Check output file exists
+if [ ! -f "$OUTPUT_HTML" ]; then
+ echo "ERROR: HTML output file not created"
+ exit 1
+fi
+
+# Verify key content exists
+ERRORS=0
+
+# Check for HTML structure
+if ! grep -q "<!DOCTYPE html>" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing HTML doctype"
+ ERRORS=$((ERRORS + 1))
+fi
+
+if ! grep -q "<html>" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing <html> tag"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for title (matches actual format: "Demo Timeline - BPM <bpm>")
+if ! grep -q "<title>Demo Timeline" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing page title"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for main heading
+if ! grep -q "<h1>Demo Timeline Gantt Chart</h1>" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing main heading"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for SVG content
+if ! grep -q "<svg" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing SVG element"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for timeline visualization (rectangles for sequences)
+if ! grep -q "<rect" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing SVG rectangles (sequence bars)"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for text labels
+if ! grep -q "<text" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing SVG text labels"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check for time axis elements
+if ! grep -q "Time axis" "$OUTPUT_HTML"; then
+ echo "ERROR: Missing time axis comment"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Check file is not empty (HTML should be larger than ASCII)
+FILE_SIZE=$(wc -c < "$OUTPUT_HTML")
+if [ "$FILE_SIZE" -lt 500 ]; then
+ echo "ERROR: HTML output is too small ($FILE_SIZE bytes)"
+ ERRORS=$((ERRORS + 1))
+fi
+
+# Verify it's valid HTML (basic check - no unclosed tags)
+OPEN_TAGS=$(grep -o "<[^/][^>]*>" "$OUTPUT_HTML" | wc -l)
+CLOSE_TAGS=$(grep -o "</[^>]*>" "$OUTPUT_HTML" | wc -l)
+if [ "$OPEN_TAGS" -ne "$CLOSE_TAGS" ]; then
+ echo "WARNING: HTML tag mismatch (open=$OPEN_TAGS, close=$CLOSE_TAGS)"
+ # Don't fail on this - some self-closing tags might not match
+fi
+
+if [ $ERRORS -eq 0 ]; then
+ echo "✓ HTML Gantt chart output test passed"
+ exit 0
+else
+ echo "✗ HTML Gantt chart output test failed ($ERRORS errors)"
+ echo "--- Output file size: $FILE_SIZE bytes ---"
+ echo "--- First 50 lines ---"
+ head -50 "$OUTPUT_HTML"
+ exit 1
+fi