blob: 6931de60bbd5fcef8b0546809b4762bc2359812c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/bin/dash
# Test startup, create a temporary directory and cd into it with files.
tmp_dir=$(mktemp --directory --quiet --tmpdir=./)
if [ "$(find tigger-* | wc -l)" -le 0 ]; then
printf "error: no tigger commands found, cannot run tests\n" >&2
exit 1
fi
cp tigger-* "$tmp_dir"/
cd "$tmp_dir" || exit
# Functions to test if the return value was 0 or non-zero.
assert_good_exec () {
printf "%s: " "$1"
if $1; then
return
fi
printf "test failed, previous command expected zero output code\n" >&2
rm -rf ../"$tmp_dir"
exit 1
}
# Functions to test if the return value was 0 or non-zero.
assert_bad_exec () {
printf "%s: " "$1"
if ! $1; then
return
fi
printf "test failed, previous command expected non-zero output code\n" >&2
rm -rf ../"$tmp_dir"
exit 1
}
printf "starting tests: output and order will be printed\n\n"
# End of test startup
# The purpose of this test is to ensure that tigger-rm'ing a file can still be
# retrieved later (provided it was in a different commit).
assert_good_exec "./tigger-init"
printf "contents" > a
assert_good_exec "./tigger-add a"
assert_good_exec "./tigger-commit -m commitmessage"
assert_good_exec "./tigger-rm a"
assert_good_exec "./tigger-commit -m commitmessage"
# Ensure it was deleted.
if [ -e a ]; then
printf "error: file was not deleted after git rm\n" >&2
exit 1
fi
# Ensure it can be later retrieved.
assert_good_exec "./tigger-show 0:a"
if [ "$(./tigger-show 0:a)" = "" ]; then
printf "error: file was not retrievable after git rm\n" >&2
exit 1
fi
# Test teardown/cleanup
printf "\ntest completed successfully\n"
rm -rf ../"$tmp_dir"
exit 0
|