/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
46
# invalid commands are detected
47
! bzr pants
48
49
# some experiments with renames
50
bzr init
51
echo "hello world" > test.txt
52
bzr unknowns
53
54
# should be the only unknown file
55
[ "`bzr unknowns`" = test.txt ]
56
253 by Martin Pool
- add test.sh for option parsing and status command
57
bzr status --all > status.tmp
58
! diff -u - status.tmp <<EOF
59
?       status.tmp
60
?       test.txt
61
EOF
62
272 by Martin Pool
- Add command aliases
63
# command alias
64
bzr st --all | diff -u - status.tmp
65
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
66
# can't rename unversioned files; use the regular unix rename command
67
! bzr rename test.txt new-test.txt
68
69
# ok, so now add it and see what happens
70
bzr add test.txt
71
[ -z "`bzr unknowns`" ]
72
73
# after adding even before committing you can rename files
74
bzr rename test.txt newname.txt
75
[ "`bzr status`" = "A       newname.txt" ]
76
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
77
[ `bzr revno` = 0 ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
78
bzr commit -m "add first revision"
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
79
[ `bzr revno` = 1 ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
80
81
# now more complicated renames
82
mkdir sub1
83
! bzr rename newname.txt sub1
84
! bzr rename newname.txt sub1/foo.txt
85
bzr add sub1
86
! bzr rename newname.txt sub1
87
88
bzr rename newname.txt sub1/foo.txt
89
[ -f sub1/foo.txt ]
90
[ ! -f newname.txt ]
91
92
bzr rename sub1/foo.txt newname.txt
93
[ -f newname.txt ]
94
95
bzr rename newname.txt sub1/foo.txt
96
bzr rename sub1/foo.txt sub1/bar.txt
97
98
cd sub1
99
mkdir sub2
100
bzr add sub2
101
bzr rename bar.txt sub2/bar.txt
102
cd sub2
103
bzr rename bar.txt ../../bar.txt
104
cd ../../
105
106
bzr commit -m "more renames"
177 by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken)
107
[ `bzr revno` = 2 ] 
108
109
# now try pulling that file back out, checking it was stored properly
110
[ "`bzr cat -r 1 newname.txt`" = "hello world" ]
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
111
171 by mbp at sourcefrog
better error message when working file rename fails
112
! bzr rename sub1 sub1/knotted-up
113
169 by mbp at sourcefrog
Start of shell-based black-box testing in test.sh
114
115
116
117
233 by mbp at sourcefrog
- more output from test.sh
118
# now test hardlinked branches in subdirectories
234 by mbp at sourcefrog
- check that commits to hardlinked trees work properly
119
cd ..
120
[ -d branch2 ] && rm -rf branch2
121
cp -al branch1 branch2
122
123
cd branch2
124
bzr log 
125
[ `bzr revno` = 2 ]
126
127
echo "added in branch2" > new-in-2.txt
128
bzr add new-in-2.txt
129
bzr commit -m "add file to branch 2 only"
130
131
[ `bzr revno` = 3 ]
132
133
cd ../branch1
134
[ `bzr revno` = 2 ]
135
249 by mbp at sourcefrog
- Check repository from test.sh
136
bzr check
137
233 by mbp at sourcefrog
- more output from test.sh
138
139
echo "tests completed ok" >&3