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 |
||
9 |
class TestMissing(TestCaseInTempDir): |
|
10 |
def test_missing(self): |
|
1185.54.21
by Aaron Bentley
Fixed up tests |
11 |
missing = "You are missing 1 revision(s):" |
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
12 |
|
13 |
# create a source branch
|
|
14 |
os.mkdir('a') |
|
15 |
os.chdir('a') |
|
16 |
self.capture('init') |
|
17 |
open('a', 'wb').write('initial\n') |
|
18 |
self.capture('add a') |
|
19 |
self.capture('commit -m inital') |
|
20 |
||
21 |
# clone and add a differing revision
|
|
22 |
self.capture('branch . ../b') |
|
23 |
os.chdir('../b') |
|
24 |
open('a', 'ab').write('more\n') |
|
25 |
self.capture('commit -m more') |
|
26 |
||
27 |
# compare a against b
|
|
28 |
os.chdir('../a') |
|
1185.54.21
by Aaron Bentley
Fixed up tests |
29 |
lines = self.capture('missing ../b', retcode=1).splitlines() |
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
30 |
# we're missing the extra revision here
|
31 |
self.assertEqual(missing, lines[0]) |
|
32 |
self.assertEqual(8, len(lines)) |
|
33 |
||
34 |
# get extra revision from b
|
|
35 |
self.capture('merge ../b') |
|
36 |
self.capture('commit -m merge') |
|
37 |
||
38 |
# compare again, but now we have the 'merge' commit extra
|
|
1185.54.21
by Aaron Bentley
Fixed up tests |
39 |
lines = self.capture('missing ../b', retcode=1).splitlines() |
40 |
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 |
41 |
self.assertEqual(8, len(lines)) |
1185.54.22
by Aaron Bentley
Test every option for "bzr missing" |
42 |
lines2 = self.capture('missing ../b --mine-only', retcode=1) |
43 |
lines2 = lines2.splitlines() |
|
44 |
self.assertEqual(lines, lines2) |
|
45 |
lines3 = self.capture('missing ../b --theirs-only', retcode=1) |
|
46 |
lines3 = lines3.splitlines() |
|
47 |
self.assertEqual(0, len(lines3)) |
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
48 |
|
49 |
# relative to a, missing the 'merge' commit
|
|
50 |
os.chdir('../b') |
|
1185.54.21
by Aaron Bentley
Fixed up tests |
51 |
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 |
52 |
self.assertEqual(missing, lines[0]) |
53 |
self.assertEqual(8, len(lines)) |
|
1185.54.22
by Aaron Bentley
Test every option for "bzr missing" |
54 |
lines2 = self.capture('missing ../a --theirs-only', retcode=1) |
55 |
lines2 = lines2.splitlines() |
|
56 |
self.assertEqual(lines, lines2) |
|
57 |
lines3 = self.capture('missing ../a --mine-only', retcode=1) |
|
58 |
lines3 = lines3.splitlines() |
|
59 |
self.assertEqual(0, len(lines3)) |
|
60 |
lines4 = self.capture('missing ../a --short', retcode=1) |
|
61 |
lines4 = lines4.splitlines() |
|
62 |
self.assertEqual(4, len(lines4)) |
|
63 |
lines5 = self.capture('missing ../a --line', retcode=1) |
|
64 |
lines5 = lines5.splitlines() |
|
65 |
self.assertEqual(2, len(lines5)) |
|
66 |
lines6 = self.capture('missing ../a --reverse', retcode=1) |
|
67 |
lines6 = lines6.splitlines() |
|
68 |
self.assertEqual(lines6, lines) |
|
69 |
lines7 = self.capture('missing ../a --show-ids', retcode=1) |
|
70 |
lines7 = lines7.splitlines() |
|
71 |
self.assertEqual(11, len(lines7)) |
|
72 |
lines8 = self.capture('missing ../a --verbose', retcode=1) |
|
73 |
lines8 = lines8.splitlines() |
|
74 |
self.assertEqual("modified:", lines8[-2]) |
|
75 |
self.assertEqual(" a", lines8[-1]) |
|
76 |
||
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
77 |
|
78 |
# after a pull we're back on track
|
|
79 |
self.capture('pull') |
|
1185.54.21
by Aaron Bentley
Fixed up tests |
80 |
self.assertEqual("Branches are up to date.\n", |
81 |
self.capture('missing ../a')) |
|
1185.55.1
by Wouter van Heyst
Add testcase for missing command, improved with feedback from Robert |
82 |