diff --git a/cpp/scripts/check_tested.sh b/cpp/scripts/check_tested.sh new file mode 100755 index 00000000..3c7fe3c8 --- /dev/null +++ b/cpp/scripts/check_tested.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# CI gate (issue 0048): falla si una funcion C++ creada en los ultimos N dias +# no tiene `tested: true` en su frontmatter del .md. +# +# Uso: +# cpp/scripts/check_tested.sh [days] # default: 30 +# +# Requiere que registry.db este actualizada (corre `fn index` antes). +set -euo pipefail +DAYS="${1:-30}" +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +DB="$ROOT/registry.db" +if [ ! -f "$DB" ]; then + echo "WARN: registry.db not found at $DB; run 'fn index' first." + exit 0 +fi + +UNTESTED=$(sqlite3 "$DB" \ + "SELECT id FROM functions WHERE lang='cpp' AND tested=0 \ + AND (created_at IS NULL OR created_at > datetime('now','-${DAYS} days'));") +if [ -n "$UNTESTED" ]; then + echo "FAIL: las siguientes funciones C++ recientes no tienen tested:true en .md:" + echo "$UNTESTED" + echo "" + echo "Anade un test (cpp/tests/test_.cpp) y marca el frontmatter del .md con tested:true." + exit 1 +fi +echo "OK: todas las funciones C++ recientes (<= ${DAYS}d) tienen tests." diff --git a/cpp/scripts/run_tests.sh b/cpp/scripts/run_tests.sh index b2f269d4..7cd6bea8 100755 --- a/cpp/scripts/run_tests.sh +++ b/cpp/scripts/run_tests.sh @@ -5,3 +5,7 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)" cmake -S "$ROOT" -B "$ROOT/build" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build "$ROOT/build" -j"$(nproc)" ctest --test-dir "$ROOT/build" --output-on-failure + +# CI gate (issue 0048): toda funcion C++ creada en los ultimos 30 dias debe +# tener tested:true en el .md. No-op si no hay registry.db. +"$ROOT/scripts/check_tested.sh" 30 diff --git a/cpp/scripts/update_goldens.sh b/cpp/scripts/update_goldens.sh new file mode 100755 index 00000000..03b3a147 --- /dev/null +++ b/cpp/scripts/update_goldens.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Regenera los golden screenshots para el test visual (issue 0048). +# +# Uso: +# cpp/scripts/update_goldens.sh +# +# Compila primitives_gallery, lo lanza con --capture sobre cpp/tests/golden/, +# y deja PNG por demo. Use LIBGL_ALWAYS_SOFTWARE=1 si no hay GPU/driver. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cmake -S "$ROOT" -B "$ROOT/build" -DCMAKE_BUILD_TYPE=Release +cmake --build "$ROOT/build" --target primitives_gallery -j"$(nproc)" +mkdir -p "$ROOT/tests/golden" +LIBGL_ALWAYS_SOFTWARE=1 \ + "$ROOT/build/apps/primitives_gallery/primitives_gallery" \ + --capture "$ROOT/tests/golden" +echo "Goldens regenerated: $ROOT/tests/golden/"