Revert "Remove bash snapshot tests"

This reverts commit 9a5ec76d7c.
This commit is contained in:
Oliver Davies 2023-12-16 00:39:11 +00:00
parent 31ef9b2968
commit 892f602159

38
run
View file

@ -37,6 +37,7 @@ function build {
function ci:test {
nix develop --command composer install
nix develop --command ./run test:snapshots
nix develop --command phpunit --testdox
}
@ -71,5 +72,42 @@ function test:create-snapshot {
git status "${output_path}"
}
# Generate a file and ensure it matches the expected version.
function test:snapshots {
rm -rf .ignored/snapshots
mkdir -p .ignored/snapshots
local configs=(
# TODO: add more configurations for different types and configurations.
drupal
drupal-commerce-kickstart
drupal-localgov
fractal
)
for config in "${configs[@]}"; do
config_file="tests/snapshots/configs/${config}.yaml"
input_path="tests/snapshots/output/${config}"
output_path=".ignored/snapshots/output/${config}"
cat "${config_file}"
./bin/build-configs app:generate --config-file "${config_file}" --output-dir "${output_path}"
find "${input_path}" -type f -print0 | while IFS= read -r -d '' original_file; do
generated_file="${output_path}/${original_file#"${input_path}"/}"
if cmp -s "${original_file}" "${generated_file}"; then
echo "Files match: ${original_file}"
else
# TODO: show the diff for all failed files. This will stop after the first failure.
echo "Files do not match: ${original_file}"
diff "${original_file}" "${generated_file}"
exit 1
fi
done
done
}
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"