#!/bin/sh
# Scarica il corpus `html5lib-tests/tokenizer`, lo stesso da cui il WPT genera i
# propri test di parsing HTML. Senza questo, `wpt` (e quindi la CI) non ha niente
# da misurare: il corpus è nel repository perché la CI deve essere deterministica
# e non dipendere dalla rete, ma se serve rigenerarlo questo script lo rifà.
#
# Uso: scripts/scarica-corpus.sh [cartella]
set -eu
DESTINAZIONE=${1:-cases/html5lib}
BASE="https://raw.githubusercontent.com/html5lib/html5lib-tests/master/tokenizer"
FILE="contentModelFlags domjs entities escapeFlag namedEntities numericEntities
pendingSpecChanges test1 test2 test3 test4 unicodeChars
unicodeCharsProblematic xmlViolation"
mkdir -p "$DESTINAZIONE"
for nome in $FILE; do
printf '%-28s ' "$nome"
if curl -fsS --max-time 90 -o "$DESTINAZIONE/$nome.test" "$BASE/$nome.test"; then
echo "ok"
else
echo "FALLITO"
rm -f "$DESTINAZIONE/$nome.test"
fi
done
echo "corpus in $DESTINAZIONE"