]> git.scottworley.com Git - pinch/commitdiff
Test
authorScott Worley <scottworley@scottworley.com>
Tue, 19 May 2020 06:05:59 +0000 (23:05 -0700)
committerScott Worley <scottworley@scottworley.com>
Tue, 19 May 2020 06:18:29 +0000 (23:18 -0700)
test.sh
tests/core.sh [new file with mode: 0755]

diff --git a/test.sh b/test.sh
index 3a3552316cfdbb932ad0c737232267ec46a331a6..9823458496987f3695c5015936c54aaa558b92d4 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -6,6 +6,10 @@ PARALLELISM=4
 
 find . -name '*.py' -print0 | xargs -0 mypy --strict --ignore-missing-imports
 
+for test in tests/*;do
+  "$test"
+done
+
 find . -name '*_test.py' -print0 | xargs -0 -r -n1 python3
 
 find . -name '*.py' -print0 | xargs -0 pylint --reports=n --persistent=n --ignore-imports=y -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods
diff --git a/tests/core.sh b/tests/core.sh
new file mode 100755 (executable)
index 0000000..bb64701
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+repo_dir="`mktemp -d`"
+repo="$repo_dir/repo"
+git init "$repo"
+(
+  cd "$repo"
+  echo Contents > test-file
+  git add test-file
+  git commit -m 'Commit message'
+)
+
+conf="`mktemp`"
+cat > "$conf" <<EOF
+[foo]
+git_repo = file://$repo
+git_ref = master
+EOF
+
+python3 ./pinch.py pin "$conf"
+
+actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
+
+rm -rf "$repo_dir" "$conf"
+
+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
+  echo PASS
+else
+  echo "Output:   $actual_env_command"
+  echo "does not match RE: $expected_env_command_RE"
+  exit 1
+fi