Scénarios en Gherkin standard validés par l'analyseur officiel ; ADR amendables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
42ace839d2
commit
2ab30a4abe
+14
-10
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Vérifie la forme des scénarios d'utilisation (docs/scenarios/, ADR 0008) :
|
||||
# un titre « Fonctionnalité », au moins un « Scénario », des étapes qui
|
||||
# commencent par un mot-clé Gherkin français, chaque fichier dans l'index.
|
||||
# Vérifie les scénarios d'utilisation (docs/scenarios/, ADR 0008) :
|
||||
# chaque .feature est du Gherkin valide en français pour l'analyseur officiel
|
||||
# de Cucumber (dans Docker), et figure dans l'index README.md.
|
||||
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../docs/scenarios"
|
||||
@@ -12,14 +12,18 @@ report() {
|
||||
errors=$((errors + 1))
|
||||
}
|
||||
|
||||
for f in *.feature.md; do
|
||||
head -n1 "$f" | grep -qE '^# Fonctionnalité : .+' \
|
||||
|| report "$f : la première ligne doit être « # Fonctionnalité : … »"
|
||||
grep -qE '^## Scénario : .+' "$f" || report "$f : aucun « ## Scénario : … »"
|
||||
while IFS= read -r step; do
|
||||
report "$f : étape sans mot-clé Gherkin : $step"
|
||||
done < <(grep -E '^\* ' "$f" | grep -vE '^\* (Étant donné|Quand|Alors|Et|Mais) ' || true)
|
||||
features=(*.feature)
|
||||
[ -e "${features[0]}" ] || report "aucun scénario dans docs/scenarios/"
|
||||
|
||||
for f in "${features[@]}"; do
|
||||
[ -e "$f" ] || continue
|
||||
grep -qF "]($f)" README.md || report "$f : absent de l'index README.md"
|
||||
done
|
||||
|
||||
if ! docker image inspect "${GHERKIN_IMAGE:?lancer via make test}" >/dev/null 2>&1; then
|
||||
report "Analyseur Gherkin absent : lancer d'abord make setup"
|
||||
elif ! docker run --rm -v "$PWD:/src:ro" -w /src "$GHERKIN_IMAGE" "${features[@]}"; then
|
||||
report "scénarios invalides (voir ci-dessus)"
|
||||
fi
|
||||
|
||||
[ "$errors" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user