From b002da89eb07c2c25cdb8b972b295d212f225cdc Mon Sep 17 00:00:00 2001 From: Toyam Cox Date: Thu, 5 Dec 2024 03:19:33 -0500 Subject: [PATCH] test(fixtures): Ease testing just one fixture --- fixtures/test-fixtures.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/fixtures/test-fixtures.sh b/fixtures/test-fixtures.sh index 2e58231..ec2eb4a 100755 --- a/fixtures/test-fixtures.sh +++ b/fixtures/test-fixtures.sh @@ -24,20 +24,29 @@ run_fixture() { return "$result" } +proc_fixture() { + # Since we are creating a subshell, all environment variables created by custom_env will be lost + # Return code is preserved + fixture="$1" + (run_fixture "$fixture") + exit_status=$? + if [ "$exit_status" -eq 0 ]; then + echo -e "[${GREEN}ok${NC}] $fixture" + else + echo -e "[${RED}fail${NC}] $fixture" + exit "$exit_status" + fi +} + main() { + [ $# -ne 0 ] && for fixture in "$@"; do + proc_fixture "$fixture" + done && exit 0 + find * -maxdepth 0 -type d -print0 | while IFS= read -r -d '' fixture; do - # Since we are creating a subshell, all environment variables created by custom_env will be lost - # Return code is preserved - (run_fixture "$fixture") - exit_status=$? - if [ "$exit_status" -eq 0 ]; then - echo -e "[${GREEN}ok${NC}] $fixture" - else - echo -e "[${RED}fail${NC}] $fixture" - exit "$exit_status" - fi + proc_fixture "$fixture" done } [ "$DEBUG" == 'true' ] && set -x && export RUST_LOG=debug -main +main "$@"