Files
cnmcdee 127035101e Blank-lines guard test for the generator
The reported symptom (a blank line after every line of generated
source) was investigated Nov 29, 2026 and does NOT reproduce in the
current generator: all 16 gen_matrix cases measure a
blank-after-content ratio of 0.01-0.06 (section separators only),
while double-spaced output scores ~1.0. This guard pins the clean
output so a regression fails loudly: tests/blank_lines_guard.py
checks every generated .cpp/.h under tests/out/ for a
blank-after-content ratio >= 0.20, and run_matrix.sh runs it right
after generation. Scope is source files only (README/Makefile are
short files whose paragraph/rule breaks legitimately score 0.25-0.34).
Verified: PASS on clean output (16 files); FAILs a double-spaced
file at ratio 0.99. Matrix: all 16 cases + guard pass.
2026-11-30 04:21:02 +00:00

130 lines
5.3 KiB
Bash

#!/usr/bin/env bash
# Extensive generator compile test: generate the matrix of designs, then
# compile EVERY generated project with -Wall -Wextra and run it briefly
# under a virtual display. A generated app that starts and stays up
# (killed by timeout, exit 124) counts as a run pass.
set -u
cd "$(dirname "$0")/.."
echo "== building harness =="
g++ -O2 -Wall -std=c++17 -o tests/gen_matrix tests/gen_matrix.cpp src/generator.cpp src/cmake_build.cpp || exit 1
rm -rf tests/out
echo "== generating =="
tests/gen_matrix tests/out || exit 1
# Blank-lines guard: the generator must not emit a blank line after
# every line of generated source. (The symptom was investigated
# Nov 29, 2026 and does not reproduce in the current generator;
# this guard pins the clean output so a regression fails loudly.)
python3 tests/blank_lines_guard.py tests/out || exit 1
pass=0; fail=0; failed=""
for d in tests/out/*/; do
name=$(basename "$d")
if ! (cd "$d" && make CXXFLAGS="-O2 -Wall -Wextra -std=c++17" >build.log 2>&1); then
echo "FAIL $name (compile) — see $d/build.log"
fail=$((fail+1)); failed="$failed $name(compile)"; continue
fi
if grep -q "warning" "$d/build.log"; then
echo "FAIL $name (warnings) — see $d/build.log"
fail=$((fail+1)); failed="$failed $name(warnings)"; continue
fi
timeout 3 xvfb-run -a "$d/app" >"$d/run.log" 2>&1
rc=$?
if [ $rc -ne 124 ]; then
echo "FAIL $name (run exit $rc) — see $d/run.log"
fail=$((fail+1)); failed="$failed $name(run:$rc)"; continue
fi
# The Adwaita pixbuf-loader warning is VM environment noise (missing
# mime database under Xvfb), not a defect in generated code; any other
# CRITICAL/WARNING fails the case.
bad=$(grep -E "CRITICAL|WARNING \*\*" "$d/run.log" | grep -v "Could not load a pixbuf" || true)
if [ -n "$bad" ]; then
echo "FAIL $name (runtime warnings) — see $d/run.log"
fail=$((fail+1)); failed="$failed $name(runtime)"; continue
fi
echo "PASS $name"
pass=$((pass+1))
done
echo "== candle render test =="
if g++ -O2 -Wall -std=c++17 -o tests/out/14_stockchart/render_test \
tests/candle_render_test.cpp tests/out/14_stockchart/StockChart_001.cpp \
-Itests/out/14_stockchart $(pkg-config --cflags --libs gtk+-3.0) \
2>tests/out/14_stockchart/render_build.log; then
if timeout 10 xvfb-run -a tests/out/14_stockchart/render_test; then
echo "PASS candle-render"; pass=$((pass+1))
else
echo "FAIL candle-render"; fail=$((fail+1))
fi
else
echo "FAIL candle-render (build) — see tests/out/14_stockchart/render_build.log"
fail=$((fail+1))
fi
echo "== indicator render test =="
if g++ -O2 -Wall -std=c++17 -o tests/out/15_stockchart_indicators/render_test \
tests/indicator_render_test.cpp tests/out/15_stockchart_indicators/StockChart_001.cpp \
-Itests/out/15_stockchart_indicators $(pkg-config --cflags --libs gtk+-3.0) \
2>tests/out/15_stockchart_indicators/render_build.log; then
if timeout 10 xvfb-run -a tests/out/15_stockchart_indicators/render_test; then
echo "PASS indicator-render"; pass=$((pass+1))
else
echo "FAIL indicator-render"; fail=$((fail+1))
fi
else
echo "FAIL indicator-render (build) — see tests/out/15_stockchart_indicators/render_build.log"
fail=$((fail+1))
fi
echo "== drawings module test =="
if g++ -O2 -Wall -Wextra -std=c++17 -o tests/out/drawings_test \
tests/drawings_test.cpp -I src \
$(pkg-config --cflags --libs cairo) \
2>tests/out/drawings_build.log; then
if tests/out/drawings_test >tests/out/drawings_test.log 2>&1; then
echo "PASS drawings"; pass=$((pass+1))
else
echo "FAIL drawings — see tests/out/drawings_test.log"
fail=$((fail+1))
fi
else
echo "FAIL drawings (build) — see tests/out/drawings_build.log"
fail=$((fail+1))
fi
echo "== chart pro render test =="
if g++ -O2 -Wall -std=c++17 -o tests/out/16_stockchart_pro/render_test \
tests/chart_pro_render_test.cpp tests/out/16_stockchart_pro/StockChart_001.cpp \
-Itests/out/16_stockchart_pro $(pkg-config --cflags --libs gtk+-3.0) \
2>tests/out/16_stockchart_pro/render_build.log; then
if timeout 15 xvfb-run -a tests/out/16_stockchart_pro/render_test; then
echo "PASS chart-pro-render"; pass=$((pass+1))
else
echo "FAIL chart-pro-render"; fail=$((fail+1))
fi
else
echo "FAIL chart-pro-render (build) — see tests/out/16_stockchart_pro/render_build.log"
fail=$((fail+1))
fi
echo "== chart pro screenshot (1024x768) =="
if g++ -O2 -Wall -std=c++17 -o tests/out/16_stockchart_pro/screenshot \
tests/chart_screenshot.cpp tests/out/16_stockchart_pro/MyWindow.cpp \
tests/out/16_stockchart_pro/StockChart_001.cpp \
-Itests/out/16_stockchart_pro $(pkg-config --cflags --libs gtk+-3.0) \
2>tests/out/16_stockchart_pro/shot_build.log; then
if timeout 20 xvfb-run -a tests/out/16_stockchart_pro/screenshot \
tests/out/chart_pro_1024x768.png; then
echo "PASS chart-pro-screenshot"; pass=$((pass+1))
else
echo "FAIL chart-pro-screenshot"; fail=$((fail+1))
fi
else
echo "FAIL chart-pro-screenshot (build) — see tests/out/16_stockchart_pro/shot_build.log"
fail=$((fail+1))
fi
echo "== matrix: $pass passed, $fail failed =="
[ $fail -eq 0 ]