-
Notifications
You must be signed in to change notification settings - Fork 0
/
test05.sh
124 lines (87 loc) · 2.11 KB
/
test05.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/dash
# if .girt directory exist already, remove it for testing
if test -d ".girt/"
then
rm -r ".girt/"
fi
failed=0
###testing girt-show with different options###
echo ""
echo "<<<<<<<<<<<<<<<START>>>>>>>>>>>>>>>"
echo ""
# error - calling girt-show before init - exit 1
sh girt-show :a
test $? -eq 1 || failed=1
sh girt-init
# no argument - print usage and exit 1
sh girt-show
test $? -eq 1 || failed=1
# many arguments - print usage and exit 1
sh girt-show 1:a 2:a
test $? -eq 1 || failed=1
# incorrect commit - output message - exit 1
sh girt-show 1:a
test $? -eq 1 || failed=1
# incorrect filename - output message - exit 1
sh girt-show :a
test $? -eq 1 || failed=1
# creating files - add - commit
echo "***A***" >> a
echo "***B***" >> b
echo "***C***" >> c
sh girt-add a
sh girt-commit -m "commit-0 => committing a"
sh girt-add b
sh girt-commit -m "commit-1 => comitting b"
sh girt-add c
sh girt-commit -m "commit-2 => committing c"
# showing a - present in all three commits
sh girt-show 0:a
test $? -eq 0 || failed=1
sh girt-show 1:a
test $? -eq 0 || failed=1
sh girt-show 2:a
test $? -eq 0 || failed=1
# showing b - present in commit 1 and 2
sh girt-show 1:b
test $? -eq 0 || failed=1
sh girt-show 1:b
test $? -eq 0 || failed=1
# showing c - only in last commit
sh girt-show 2:c
test $? -eq 0 || failed=1
# b not present in commit 0 - output error - exit 1
sh girt-show 0:b
test $? -eq 1 || failed=1
# c not present in commit 0 and 1 - output error - exit 1
sh girt-show 0:c
test $? -eq 1 || failed=1
sh girt-show 1:c
test $? -eq 1 || failed=1
# modifying files and add them to index
echo "###A###" >> a
echo "###B###" >> b
echo "####C###" >> c
sh girt-add a b c
# showing their contents in index
sh girt-show :a
test $? -eq 0 || failed=1
sh girt-show :b
test $? -eq 0 || failed=1
sh girt-show :c
test $? -eq 0 || failed=1
rm -r .girt
rm a b c
echo ""
echo "<<<<<<<<<<<<<<<END>>>>>>>>>>>>>>>"
echo ""
if test "$failed" -eq 1
then
echo "***************TEST FAILED***************" 1>&2
echo ""
exit 1
else
echo "***************TEST PASSED***************" 1>&2
echo ""
exit 0
fi