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
|
|
12 |
echo "please create bzr-test.tmp" |
|
13 |
exit 1 |
|
14 |
fi
|
|
15 |
||
16 |
rm -rf bzr-test.tmp |
|
17 |
mkdir bzr-test.tmp |
|
18 |
||
177
by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken) |
19 |
# save it for real errors
|
20 |
exec 3>&2 |
|
21 |
||
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
22 |
exec > bzr-test.log
|
23 |
exec 2>&1 |
|
24 |
set -x
|
|
25 |
||
177
by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken) |
26 |
quitter() { |
27 |
echo "tests failed, look in bzr-test.log" >&3; exit 2; |
|
28 |
}
|
|
29 |
||
30 |
trap quitter ERR
|
|
31 |
||
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
32 |
cd bzr-test.tmp
|
33 |
rm -rf .bzr |
|
34 |
||
35 |
# some information commands
|
|
36 |
bzr help
|
|
37 |
bzr version |
|
38 |
||
39 |
# invalid commands are detected
|
|
40 |
! bzr pants |
|
41 |
||
42 |
# some experiments with renames
|
|
43 |
bzr init |
|
44 |
echo "hello world" > test.txt |
|
45 |
bzr unknowns |
|
46 |
||
47 |
# should be the only unknown file
|
|
48 |
[ "`bzr unknowns`" = test.txt ] |
|
49 |
||
50 |
# can't rename unversioned files; use the regular unix rename command
|
|
51 |
! bzr rename test.txt new-test.txt |
|
52 |
||
53 |
# ok, so now add it and see what happens
|
|
54 |
bzr add test.txt |
|
55 |
[ -z "`bzr unknowns`" ] |
|
56 |
||
57 |
# after adding even before committing you can rename files
|
|
58 |
bzr rename test.txt newname.txt |
|
59 |
[ "`bzr status`" = "A newname.txt" ] |
|
60 |
||
177
by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken) |
61 |
[ `bzr revno` = 0 ] |
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
62 |
bzr commit -m "add first revision"
|
177
by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken) |
63 |
[ `bzr revno` = 1 ] |
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
64 |
|
65 |
# now more complicated renames
|
|
66 |
mkdir sub1 |
|
67 |
! bzr rename newname.txt sub1 |
|
68 |
! bzr rename newname.txt sub1/foo.txt |
|
69 |
bzr add sub1 |
|
70 |
! bzr rename newname.txt sub1 |
|
71 |
||
72 |
bzr rename newname.txt sub1/foo.txt |
|
73 |
[ -f sub1/foo.txt ] |
|
74 |
[ ! -f newname.txt ] |
|
75 |
||
76 |
bzr rename sub1/foo.txt newname.txt |
|
77 |
[ -f newname.txt ] |
|
78 |
||
79 |
bzr rename newname.txt sub1/foo.txt |
|
80 |
bzr rename sub1/foo.txt sub1/bar.txt |
|
81 |
||
82 |
cd sub1
|
|
83 |
mkdir sub2 |
|
84 |
bzr add sub2 |
|
85 |
bzr rename bar.txt sub2/bar.txt |
|
86 |
cd sub2
|
|
87 |
bzr rename bar.txt ../../bar.txt |
|
88 |
cd ../../
|
|
89 |
||
90 |
bzr commit -m "more renames"
|
|
177
by mbp at sourcefrog
- better output from test.sh- test.sh exercises cat command (currently broken) |
91 |
[ `bzr revno` = 2 ] |
92 |
||
93 |
# now try pulling that file back out, checking it was stored properly
|
|
94 |
[ "`bzr cat -r 1 newname.txt`" = "hello world" ] |
|
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
95 |
|
171
by mbp at sourcefrog
better error message when working file rename fails |
96 |
! bzr rename sub1 sub1/knotted-up |
97 |
||
169
by mbp at sourcefrog
Start of shell-based black-box testing in test.sh |
98 |
|
99 |
||
100 |
||
101 |