]> git.scottworley.com Git - pinch/blob - tests/multi-update.sh
24c22bc18eaa1dee6a54904e653309d0efb8d0a1
[pinch] / tests / multi-update.sh
1 #!/bin/sh
2
3 set -e
4
5 repo_dir="`mktemp -d`"
6 repo="$repo_dir/repo"
7 git init "$repo"
8 (
9 cd "$repo"
10 echo Contents > test-file
11 git add test-file
12 git commit -m 'Commit message'
13 )
14
15 conf1="`mktemp`"
16 cat > "$conf1" <<EOF
17 [foo]
18 git_repo = file://$repo
19 git_ref = master
20 EOF
21
22 conf2="`mktemp`"
23 cat > "$conf2" <<EOF
24 [bar]
25 alias_of = foo
26 EOF
27
28 python3 ./pinch.py pin "$conf1"
29 python3 ./pinch.py pin "$conf2"
30
31 actual_env_command=`python3 ./pinch.py update --dry-run "$conf1" "$conf2"`
32
33 rm -rf "$repo_dir" "$conf1" "$conf2"
34
35 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"; \}'\''$'
36
37 if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
38 echo PASS
39 else
40 echo "Output: $actual_env_command"
41 echo "does not match RE: $expected_env_command_RE"
42 exit 1
43 fi