-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_status_test01
executable file
·57 lines (44 loc) · 1017 Bytes
/
my_status_test01
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
#! /bin/dash
# PATH="$PATH:$(pwd)"
# # create a temporary directory for the test.
# test_dir=$(mktemp -d)
# cd "$test_dir" || exit 1
# create a temporary directory for the test.
test_dir="dir_test"
mkdir "$test_dir"
cd "$test_dir" || exit 1
# create some files to hold output.
expected_output=$(mktemp)
actual_output=$(mktemp)
# remove the temporary directory when the test is done.
# trap 'rm "$expected_output" "$actual_output" -rf "$test_dir"' INT HUP QUIT TERM EXIT
# create pigs repository
pigs-init
echo 1 >a
echo 2 >b
echo 3 >c
pigs-add a b c
pigs-commit -m "first commit"
echo 4 >>a
echo 5 >>b
echo 6 >>c
echo 7 >d
echo 8 >e
pigs-add b c d e
echo 9 >b
echo 0 >d
pigs-rm --cached a c
pigs-rm --force --cached b
pigs-rm --force --cached e
pigs-rm --force d
cat >"$expected_output" <<EOF
a - deleted from index
b - deleted from index
c - deleted from index
e - untracked
EOF
pigs-status >"$actual_output" 2>&1
if ! diff "$expected_output" "$actual_output"; then
echo "Failed test"
exit 1
fi