Files
cfree/tests/widget_tests.sh
root cd5f07f619 CMake handling: generate CMakeLists.txt, build with CMake from the designer, open/build existing CMake projects
- Generator emits CMakeLists.txt alongside Makefile (cmake_minimum_required
  3.10, project(<Class> CXX), C++17, PkgConfig gtk+-3.0, explicit source
  list, add_executable(app ...), GTK include/link wiring); exe named app
  to match the Makefile target.
- New src/cmake_build.h/.cpp: cmake_lists_text, cmake_build_project
  (configure + build, captured output), cmake_project_exists,
  CMakeSettings persisted to ~/.config/fdesigner/cmake.conf
  (FDESIGNER_CMAKE_CONF override for tests).
- Designer File menu: Build with CMake... (last generated project, or
  pick a folder), Open CMake Project... (any dir with a CMakeLists.txt),
  CMake Settings...; Generate now offers Build with CMake (the default
  build path for generated projects) and reports the log + exe path.
- Self-test gains a CMake phase (settings round-trip, CMakeLists.txt
  markers, real console build, broken-file failure, cmake build of the
  generated GTK project); file count 4+2N -> 5+2N.
- New tests/cmake_tests.sh + tests/cmake_probe.cpp (31 checks); matrix
  and widget test harnesses link cmake_build.cpp; tests/out/ gitignored.
- DESIGN.md: CMake handling section.
2026-11-25 06:59:14 -05:00

68 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Lazarus-widget tests: designer self-test (Phase 7 places, edits, drags,
# deletes and generates every new widget), then a generator-API project
# holding every new widget: per-widget code markers, a -Wall -Wextra
# compile of the generated app, and a brief run under Xvfb.
set -u
cd "$(dirname "$0")/.."
pass=0; fail=0; failed=""
ok() { echo "PASS $1"; pass=$((pass+1)); }
bad() { echo "FAIL $1"; fail=$((fail+1)); failed="$failed $1"; }
echo "== building fdesigner =="
if make > /tmp/widget_make.log 2>&1; then ok make; else
bad make; cat /tmp/widget_make.log; exit 1
fi
echo "== designer self-test (includes Phase 7 Lazarus widgets) =="
if FDESIGNER_SELFTEST=1 timeout 60 xvfb-run -a ./fdesigner \
> /tmp/widget_selftest.log 2>&1; then
if grep -q "SELFTEST PASS" /tmp/widget_selftest.log; then ok selftest;
else bad "selftest(no PASS line)"; tail -20 /tmp/widget_selftest.log; fi
else
bad selftest; tail -20 /tmp/widget_selftest.log
fi
grep -E "GENERATED7" /tmp/widget_selftest.log || true
echo "== widget generator test (per-widget markers) =="
if g++ -O2 -Wall -Wextra -std=c++17 -o /tmp/widget_tests \
tests/widget_tests.cpp src/generator.cpp src/cmake_build.cpp src/project_io.cpp; then
rm -rf /tmp/fdesigner_widgets_gen
if /tmp/widget_tests /tmp/fdesigner_widgets_gen; then
ok widget-markers
else
bad widget-markers
fi
else
bad widget-tests-build
fi
echo "== compile generated project (all new widgets) =="
if (cd /tmp/fdesigner_widgets_gen && \
make CXXFLAGS="-O2 -Wall -Wextra -std=c++17" >build.log 2>&1); then
if grep -q "warning" /tmp/fdesigner_widgets_gen/build.log; then
bad "generated-compile(warnings)"
grep "warning" /tmp/fdesigner_widgets_gen/build.log | head
else ok generated-compile; fi
else
bad generated-compile; cat /tmp/fdesigner_widgets_gen/build.log
fi
echo "== run generated project briefly =="
timeout 3 xvfb-run -a /tmp/fdesigner_widgets_gen/app \
> /tmp/fdesigner_widgets_gen/run.log 2>&1
rc=$?
if [ $rc -ne 124 ]; then
bad "generated-run(exit $rc)"; cat /tmp/fdesigner_widgets_gen/run.log
else
badlog=$(grep -E "CRITICAL|WARNING \*\*" \
/tmp/fdesigner_widgets_gen/run.log | grep -v "Could not load a pixbuf" || true)
if [ -n "$badlog" ]; then
bad "generated-run(runtime warnings)"; echo "$badlog"
else ok generated-run; fi
fi
echo "== widget_tests: $pass passed, $fail failed ==$failed"
[ $fail -eq 0 ]