4NK_template/scripts/agents/tests_agent.sh

51 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Chargement env utilisateur (~/.4nk_template/.env)
"$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/env/ensure_env.sh" || true
if [[ -f "${HOME}/.4nk_template/.env" ]]; then
set -a
. "${HOME}/.4nk_template/.env"
set +a
fi
TARGET_DIR="${1:-.}"
OUTPUT_DIR="${2:-tests/reports/agents}"
mkdir -p "$OUTPUT_DIR"
SUMMARY_FILE="$OUTPUT_DIR/tests_agent.md"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh" || true
echo "# Agent Tests" > "$SUMMARY_FILE"
echo >> "$SUMMARY_FILE"
# Vérifier existence structure
pushd "$TARGET_DIR" >/dev/null
need=(tests/unit tests/integration tests/connectivity tests/external tests/performance tests/logs tests/reports)
missing=()
for d in "${need[@]}"; do [[ -d "$d" ]] || missing+=("$d"); done
echo "## Résultats locaux" >> "$SUMMARY_FILE"
if ((${#missing[@]}==0)); then
echo "- Structure de tests conforme au template." >> "$SUMMARY_FILE"
else
echo "- Dossiers manquants:" >> "$SUMMARY_FILE"
for m in "${missing[@]}"; do echo " - $m" >> "$SUMMARY_FILE"; done
if [[ "${AUTO_FIX:-0}" == "1" ]]; then
echo >> "$SUMMARY_FILE"
echo "## Autocorrections" >> "$SUMMARY_FILE"
for m in "${missing[@]}"; do
mkdir -p "$m" && echo "- Créé: $m" >> "$SUMMARY_FILE"
done
mkdir -p tests/reports/agents tests/logs || true
fi
fi
PROMPT=$(cat <<'EOF'
Propose un plan court pour renforcer la pyramide de tests (unit, integration, connectivity, external, performance) pour ce template, avec 5 actions.
EOF
)
scripts/agents/ai_prompt.sh "$PROMPT" >> "$SUMMARY_FILE" || true
echo "Rapport: $SUMMARY_FILE"
popd >/dev/null