mirror of
https://github.com/opdavies/build-configs.git
synced 2025-01-22 18:27:31 +00:00
parent
31ef9b2968
commit
892f602159
38
run
38
run
|
@ -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}"
|
||||
|
|
Loading…
Reference in a new issue