~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to test.sh

  • Committer: Martin Pool
  • Date: 2005-05-30 03:05:03 UTC
  • Revision ID: mbp@sourcefrog.net-20050530030503-8fd9959e40c31eeb
todo

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 directory bzr-test.tmp"
13
 
    exit 1
14
 
fi
15
 
 
16
 
echo "testing `which bzr`"
17
 
bzr --version | head -n 1
18
 
echo
19
 
 
20
 
rm -rf bzr-test.tmp
21
 
mkdir bzr-test.tmp
22
 
 
23
 
# save it for real errors
24
 
exec 3>&2
25
 
 
26
 
exec > bzr-test.log
27
 
exec 2>&1 
28
 
set -x
29
 
 
30
 
quitter() {
31
 
    echo "tests failed, look in bzr-test.log" >&3; exit 2; 
32
 
}
33
 
 
34
 
trap quitter ERR
35
 
 
36
 
cd bzr-test.tmp 
37
 
rm -rf .bzr
38
 
 
39
 
mkdir branch1
40
 
cd branch1
41
 
 
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
 
 
57
 
bzr status --all > status.tmp
58
 
! diff -u - status.tmp <<EOF
59
 
?       status.tmp
60
 
?       test.txt
61
 
EOF
62
 
 
63
 
# can't rename unversioned files; use the regular unix rename command
64
 
! bzr rename test.txt new-test.txt
65
 
 
66
 
# ok, so now add it and see what happens
67
 
bzr add test.txt
68
 
[ -z "`bzr unknowns`" ]
69
 
 
70
 
# after adding even before committing you can rename files
71
 
bzr rename test.txt newname.txt
72
 
[ "`bzr status`" = "A       newname.txt" ]
73
 
 
74
 
[ `bzr revno` = 0 ]
75
 
bzr commit -m "add first revision"
76
 
[ `bzr revno` = 1 ]
77
 
 
78
 
# now more complicated renames
79
 
mkdir sub1
80
 
! bzr rename newname.txt sub1
81
 
! bzr rename newname.txt sub1/foo.txt
82
 
bzr add sub1
83
 
! bzr rename newname.txt sub1
84
 
 
85
 
bzr rename newname.txt sub1/foo.txt
86
 
[ -f sub1/foo.txt ]
87
 
[ ! -f newname.txt ]
88
 
 
89
 
bzr rename sub1/foo.txt newname.txt
90
 
[ -f newname.txt ]
91
 
 
92
 
bzr rename newname.txt sub1/foo.txt
93
 
bzr rename sub1/foo.txt sub1/bar.txt
94
 
 
95
 
cd sub1
96
 
mkdir sub2
97
 
bzr add sub2
98
 
bzr rename bar.txt sub2/bar.txt
99
 
cd sub2
100
 
bzr rename bar.txt ../../bar.txt
101
 
cd ../../
102
 
 
103
 
bzr commit -m "more renames"
104
 
[ `bzr revno` = 2 ] 
105
 
 
106
 
# now try pulling that file back out, checking it was stored properly
107
 
[ "`bzr cat -r 1 newname.txt`" = "hello world" ]
108
 
 
109
 
! bzr rename sub1 sub1/knotted-up
110
 
 
111
 
 
112
 
 
113
 
 
114
 
 
115
 
# now test hardlinked branches in subdirectories
116
 
cd ..
117
 
[ -d branch2 ] && rm -rf branch2
118
 
cp -al branch1 branch2
119
 
 
120
 
cd branch2
121
 
bzr log 
122
 
[ `bzr revno` = 2 ]
123
 
 
124
 
echo "added in branch2" > new-in-2.txt
125
 
bzr add new-in-2.txt
126
 
bzr commit -m "add file to branch 2 only"
127
 
 
128
 
[ `bzr revno` = 3 ]
129
 
 
130
 
cd ../branch1
131
 
[ `bzr revno` = 2 ]
132
 
 
133
 
bzr check
134
 
 
135
 
 
136
 
echo "tests completed ok" >&3
 
 
b'\\ No newline at end of file'