From: Scott Worley Date: Sat, 23 May 2020 01:07:37 +0000 (-0700) Subject: tests: Depend upon /bin/sh supporting traps X-Git-Tag: 1.3~8 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/d9a1088a3c1c6131fbd1bd5ea2a2dc10e2427eb2?ds=inline tests: Depend upon /bin/sh supporting traps --- diff --git a/tests/alias.sh b/tests/alias.sh index 5083999..368fc1e 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -13,8 +13,6 @@ python3 ./pinch.py pin "$conf" actual_env_command=`python3 ./pinch.py update --dry-run "$conf"` -foo_cleanup - expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "bar"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\''$' if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then diff --git a/tests/core.sh b/tests/core.sh index da0d991..5ef652e 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,8 +8,6 @@ python3 ./pinch.py pin "$conf" actual_env_command=`python3 ./pinch.py update --dry-run "$conf"` -foo_cleanup - expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\''$' if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then diff --git a/tests/lib/test-setup.sh b/tests/lib/test-setup.sh index 12cf525..4ccc8d9 100644 --- a/tests/lib/test-setup.sh +++ b/tests/lib/test-setup.sh @@ -21,6 +21,9 @@ EOF } -foo_cleanup() { - rm -rf "$repo_dir" "$conf" +test_cleanup() { + if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi + if [ "$conf" ];then rm "$conf"; fi } + +trap test_cleanup EXIT INT TERM diff --git a/tests/multi-update.sh b/tests/multi-update.sh index d6a6d54..74899ff 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -15,7 +15,6 @@ python3 ./pinch.py pin "$conf2" actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` -foo_cleanup rm -rf "$conf2" expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "bar"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\''$' diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index 5f51cc0..dec02f0 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,8 +17,6 @@ python3 ./pinch.py pin "$conf" actual_env_command=`python3 ./pinch.py update --dry-run "$conf"` -foo_cleanup - expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "/nix/store/.{32}-\1.tar.xz"; \}'\''$' if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then diff --git a/tests/reject-duplicates.sh b/tests/reject-duplicates.sh index 8a630b0..a6978f8 100755 --- a/tests/reject-duplicates.sh +++ b/tests/reject-duplicates.sh @@ -20,10 +20,4 @@ else echo PASS fi -foo_cleanup - -repo_dir=$repo_dir1 -repo=$repo1 -conf=$conf1 - -foo_cleanup +rm -rf "$repo_dir1" "$repo1" "$conf1" diff --git a/tests/reject-nonancestor.sh b/tests/reject-nonancestor.sh index 5608761..f8cc2e9 100755 --- a/tests/reject-nonancestor.sh +++ b/tests/reject-nonancestor.sh @@ -19,5 +19,3 @@ if python3 ./pinch.py pin "$conf";then else echo PASS fi - -foo_cleanup