~bzr-pqm/bzr/bzr.dev

169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
1
#! /bin/sh -pe
2
3
# Simple shell-based tests for bzr.
4
5
# This is meant to exercise the external behaviour, command line
6
# parsing and similar things and compliment the inwardly-turned
7
# testing done by doctest.
8
9
# This must already exist and be in the right place
10
if ! [ -d bzr-test.tmp ] 
11
then
233 by mbp at sourcefrog
- more output from test.sh
12
    echo "please create directory bzr-test.tmp"
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
13
    exit 1
14
fi
15
233 by mbp at sourcefrog
- more output from test.sh
16
echo "testing `which bzr`"
17
bzr --version | head -n 1
18
echo
19
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
20
rm -rf bzr-test.tmp
21
mkdir bzr-test.tmp
22
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
23
# save it for real errors
24
exec 3>&2
25
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
26
exec > bzr-test.log
27
exec 2>&1 
28
set -x
29
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
30
quitter() {
31
    echo "tests failed, look in bzr-test.log" >&3; exit 2; 
32
}
33
34
trap quitter ERR
35
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
36
cd bzr-test.tmp 
37
rm -rf .bzr
38
233 by mbp at sourcefrog
- more output from test.sh
39
mkdir branch1
40
cd branch1
41
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
42
# some information commands
43
bzr help
44
bzr version
45
273 by Martin Pool
- New 'bzr help commands'
46
[ $(bzr help commands | wc -l) -gt 20 ]
47
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
48
# invalid commands are detected
49
! bzr pants
50
277 by Martin Pool
Doc
51
# TODO: test unicode user names
52
53
bzr help
54
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
55
# some experiments with renames
56
bzr init
57
echo "hello world" > test.txt
58
bzr unknowns
59
60
# should be the only unknown file
61
[ "`bzr unknowns`" = test.txt ]
62
253 by Martin Pool
- add test.sh for option parsing and status command
63
bzr status --all > status.tmp
64
! diff -u - status.tmp <<EOF
65
?       status.tmp
66
?       test.txt
67
EOF
68
272 by Martin Pool
- Add command aliases
69
# command alias
70
bzr st --all | diff -u - status.tmp
71
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
72
# can't rename unversioned files; use the regular unix rename command
73
! bzr rename test.txt new-test.txt
74
75
# ok, so now add it and see what happens
76
bzr add test.txt
77
[ -z "`bzr unknowns`" ]
78
79
# after adding even before committing you can rename files
80
bzr rename test.txt newname.txt
81
[ "`bzr status`" = "A       newname.txt" ]
82
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
83
[ `bzr revno` = 0 ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
84
bzr commit -m "add first revision"
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
85
[ `bzr revno` = 1 ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
86
87
# now more complicated renames
88
mkdir sub1
89
! bzr rename newname.txt sub1
90
! bzr rename newname.txt sub1/foo.txt
91
bzr add sub1
92
! bzr rename newname.txt sub1
93
94
bzr rename newname.txt sub1/foo.txt
95
[ -f sub1/foo.txt ]
96
[ ! -f newname.txt ]
97
98
bzr rename sub1/foo.txt newname.txt
99
[ -f newname.txt ]
100
101
bzr rename newname.txt sub1/foo.txt
102
bzr rename sub1/foo.txt sub1/bar.txt
103
104
cd sub1
105
mkdir sub2
106
bzr add sub2
107
bzr rename bar.txt sub2/bar.txt
108
cd sub2
109
bzr rename bar.txt ../../bar.txt
110
cd ../../
111
112
bzr commit -m "more renames"
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
113
[ `bzr revno` = 2 ] 
114
115
# now try pulling that file back out, checking it was stored properly
116
[ "`bzr cat -r 1 newname.txt`" = "hello world" ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
117
171 by mbp at sourcefrog
better error message when working file rename fails
118
! bzr rename sub1 sub1/knotted-up
119
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
120
121
122
123
233 by mbp at sourcefrog
- more output from test.sh
124
# now test hardlinked branches in subdirectories
234 by mbp at sourcefrog
- check that commits to hardlinked trees work properly
125
cd ..
126
[ -d branch2 ] && rm -rf branch2
127
cp -al branch1 branch2
128
129
cd branch2
130
bzr log 
131
[ `bzr revno` = 2 ]
132
133
echo "added in branch2" > new-in-2.txt
134
bzr add new-in-2.txt
135
bzr commit -m "add file to branch 2 only"
136
137
[ `bzr revno` = 3 ]
138
139
cd ../branch1
140
[ `bzr revno` = 2 ]
141
249 by mbp at sourcefrog
- Check repository from test.sh
142
bzr check
143
233 by mbp at sourcefrog
- more output from test.sh
144
145
echo "tests completed ok" >&3