bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
1 |
"""Black-box tests for bzr missing.
|
2 |
"""
|
|
3 |
||
4 |
import os |
|
5 |
||
6 |
from bzrlib.branch import Branch |
|
7 |
from bzrlib.tests import TestCaseInTempDir |
|
8 |
||
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
9 |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
10 |
class TestMissing(TestCaseInTempDir): |
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
11 |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
12 |
def test_missing(self): |
|
1185.54.21
by Aaron Bentley
Fixed up tests |
13 |
missing = "You are missing 1 revision(s):" |
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
14 |
|
15 |
# create a source branch
|
|
16 |
os.mkdir('a') |
|
17 |
os.chdir('a') |
|
18 |
self.capture('init') |
|
19 |
open('a', 'wb').write('initial\n') |
|
20 |
self.capture('add a') |
|
21 |
self.capture('commit -m inital') |
|
22 |
||
23 |
# clone and add a differing revision
|
|
24 |
self.capture('branch . ../b') |
|
25 |
os.chdir('../b') |
|
26 |
open('a', 'ab').write('more\n') |
|
27 |
self.capture('commit -m more') |
|
28 |
||
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
29 |
# run missing in a against b
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
30 |
os.chdir('../a') |
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
31 |
# this should not require missing to take out a write lock on a
|
32 |
# or b. So we take a write lock on both to test that at the same
|
|
33 |
# time. This may let the test pass while the default branch is an
|
|
34 |
# os-locking branch, but it will trigger failures with lockdir based
|
|
35 |
# branches.
|
|
36 |
branch_a = Branch.open('.') |
|
37 |
branch_a.lock_write() |
|
38 |
branch_b = Branch.open('../b') |
|
39 |
branch_b.lock_write() |
|
40 |
out,err = self.run_bzr('missing', '../b', retcode=1) |
|
41 |
lines = out.splitlines() |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
42 |
# we're missing the extra revision here
|
43 |
self.assertEqual(missing, lines[0]) |
|
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
44 |
# and we expect 8 lines of output which we trust at the moment to be
|
45 |
# good.
|
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
46 |
self.assertEqual(8, len(lines)) |
|
1607.1.15
by Robert Collins
Change missing to not require a write lock unless it is setting the parent. |
47 |
# we do not expect any error output.
|
48 |
self.assertEqual('', err) |
|
49 |
# unlock the branches for the rest of the test
|
|
50 |
branch_a.unlock() |
|
51 |
branch_b.unlock() |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
52 |
|
53 |
# get extra revision from b
|
|
54 |
self.capture('merge ../b') |
|
55 |
self.capture('commit -m merge') |
|
56 |
||
57 |
# compare again, but now we have the 'merge' commit extra
|
|
|
1185.54.21
by Aaron Bentley
Fixed up tests |
58 |
lines = self.capture('missing ../b', retcode=1).splitlines() |
59 |
self.assertEqual("You have 1 extra revision(s):", lines[0]) |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
60 |
self.assertEqual(8, len(lines)) |
|
1185.54.22
by Aaron Bentley
Test every option for "bzr missing" |
61 |
lines2 = self.capture('missing ../b --mine-only', retcode=1) |
62 |
lines2 = lines2.splitlines() |
|
63 |
self.assertEqual(lines, lines2) |
|
64 |
lines3 = self.capture('missing ../b --theirs-only', retcode=1) |
|
65 |
lines3 = lines3.splitlines() |
|
66 |
self.assertEqual(0, len(lines3)) |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
67 |
|
68 |
# relative to a, missing the 'merge' commit
|
|
69 |
os.chdir('../b') |
|
|
1185.54.21
by Aaron Bentley
Fixed up tests |
70 |
lines = self.capture('missing ../a', retcode=1).splitlines() |
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
71 |
self.assertEqual(missing, lines[0]) |
72 |
self.assertEqual(8, len(lines)) |
|
|
1185.54.22
by Aaron Bentley
Test every option for "bzr missing" |
73 |
lines2 = self.capture('missing ../a --theirs-only', retcode=1) |
74 |
lines2 = lines2.splitlines() |
|
75 |
self.assertEqual(lines, lines2) |
|
76 |
lines3 = self.capture('missing ../a --mine-only', retcode=1) |
|
77 |
lines3 = lines3.splitlines() |
|
78 |
self.assertEqual(0, len(lines3)) |
|
79 |
lines4 = self.capture('missing ../a --short', retcode=1) |
|
80 |
lines4 = lines4.splitlines() |
|
81 |
self.assertEqual(4, len(lines4)) |
|
82 |
lines5 = self.capture('missing ../a --line', retcode=1) |
|
83 |
lines5 = lines5.splitlines() |
|
84 |
self.assertEqual(2, len(lines5)) |
|
85 |
lines6 = self.capture('missing ../a --reverse', retcode=1) |
|
86 |
lines6 = lines6.splitlines() |
|
87 |
self.assertEqual(lines6, lines) |
|
88 |
lines7 = self.capture('missing ../a --show-ids', retcode=1) |
|
89 |
lines7 = lines7.splitlines() |
|
90 |
self.assertEqual(11, len(lines7)) |
|
91 |
lines8 = self.capture('missing ../a --verbose', retcode=1) |
|
92 |
lines8 = lines8.splitlines() |
|
93 |
self.assertEqual("modified:", lines8[-2]) |
|
94 |
self.assertEqual(" a", lines8[-1]) |
|
95 |
||
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
96 |
|
97 |
# after a pull we're back on track
|
|
98 |
self.capture('pull') |
|
|
1185.54.21
by Aaron Bentley
Fixed up tests |
99 |
self.assertEqual("Branches are up to date.\n", |
100 |
self.capture('missing ../a')) |
|
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
101 |