]> git.scottworley.com Git - pinch/commitdiff
tests: Depend upon /bin/sh supporting traps
authorScott Worley <scottworley@scottworley.com>
Sat, 23 May 2020 01:07:37 +0000 (18:07 -0700)
committerScott Worley <scottworley@scottworley.com>
Sat, 23 May 2020 04:25:09 +0000 (21:25 -0700)
tests/alias.sh
tests/core.sh
tests/lib/test-setup.sh
tests/multi-update.sh
tests/pin-twice.sh
tests/reject-duplicates.sh
tests/reject-nonancestor.sh

index 50839993f5a99ab404a4a996df313e12c18f0169..368fc1e55514c852cf2333268101fcbb630bcc90 100755 (executable)
@@ -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 '\''<nix/unpack-channel.nix>'\'' --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
index da0d991089fd915a8ba308776537be21657d4588..5ef652e69cd38d8f00a3f80ecf4e642955b68944 100755 (executable)
@@ -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 '\''<nix/unpack-channel.nix>'\'' --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
index 12cf525878a65dfbea6b14f095192098dc4d7c7d..4ccc8d9277e11d20f325fd2cb2edcc122b45fc5b 100644 (file)
@@ -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
index d6a6d54c704a5b086582bb5f3ff1fb1c66559ac8..74899ff00ac67718a8962d7ea52692816d94d61c 100755 (executable)
@@ -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 '\''<nix/unpack-channel.nix>'\'' --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"; \}'\''$'
index 5f51cc0bcd5191c9693f0ec4decbc72201711c20..dec02f06e5297b656cb87e5715c74f0c2564c848 100755 (executable)
@@ -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 '\''<nix/unpack-channel.nix>'\'' --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
index 8a630b049b10fdbfe47522d6865423358ca0c3c1..a6978f8dd3f0706bc2ddc507ecec57ad38a0b67e 100755 (executable)
@@ -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"
index 5608761b23e54d9909d78bfe99d7ec41cd22459e..f8cc2e98694b7cc1afbd5ce0042d7ab8a5ab0676 100755 (executable)
@@ -19,5 +19,3 @@ if python3 ./pinch.py pin "$conf";then
 else
   echo PASS
 fi
-
-foo_cleanup