Mercurial > hg
annotate tests/test-bdiff.py @ 31965:171de3152d50
obsolescence: add test case C-1 for obsolescence markers exchange
About 3 years ago, in August 2014, the logic to select what markers to select on
push was ported from the evolve extension to Mercurial core. However, for some
unclear reasons, the tests for that logic were not ported alongside.
I realised it a couple of weeks ago while working on another push related issue.
I've made a clean up pass on the tests and they are now ready to integrate the
core test suite. This series of changesets do not change any logic. I just adds
test for logic that has been around for about 10 versions of Mercurial.
They are a patch for each test case. It makes it easier to review and postpone
one with documentation issues without rejecting the wholes series.
This patch introduce C-1: Multiple pruned changeset atop each other
Each test case comes it in own test file. It help parallelism and does not
introduce a significant overhead from having a single unified giant test file.
Here are timing to support this claim.
# Multiple test files version:
# run-tests.py --local -j 1 test-exchange-*.t
53.40s user 6.82s system 85% cpu 1:10.76 total
52.79s user 6.97s system 85% cpu 1:09.97 total
52.94s user 6.82s system 85% cpu 1:09.69 total
# Single test file version:
# run-tests.py --local -j 1 test-exchange-obsmarkers.t
52.97s user 6.85s system 85% cpu 1:10.10 total
52.64s user 6.79s system 85% cpu 1:09.63 total
53.70s user 7.00s system 85% cpu 1:11.17 total
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 10 Apr 2017 16:50:41 +0200 |
parents | f2ad0d804700 |
children | ded48ad55146 |
rev | line source |
---|---|
28734
4e51f9d1683e
py3: use print_function in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28733
diff
changeset
|
1 from __future__ import absolute_import, print_function |
30592
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
2 import collections |
8656 | 3 import struct |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
4 import unittest |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
5 |
28733
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
6 from mercurial import ( |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
7 bdiff, |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
8 mpatch, |
2e54aaa65afc
py3: use absolute_import in test-bdiff.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
15530
diff
changeset
|
9 ) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
10 |
30592
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
11 class diffreplace( |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
12 collections.namedtuple('diffreplace', 'start end from_ to')): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
13 def __repr__(self): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
14 return 'diffreplace(%r, %r, %r, %r)' % self |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
15 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
16 class BdiffTests(unittest.TestCase): |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
17 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
18 def assert_bdiff_applies(self, a, b): |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
19 d = bdiff.bdiff(a, b) |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
20 c = a |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
21 if d: |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
22 c = mpatch.patches(a, [d]) |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
23 self.assertEqual( |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
24 c, b, ("bad diff+patch result from\n %r to\n " |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
25 "%r: \nbdiff: %r\npatched: %r" % (a, b, d, c[:200]))) |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
26 |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
27 def assert_bdiff(self, a, b): |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
28 self.assert_bdiff_applies(a, b) |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
29 self.assert_bdiff_applies(b, a) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
30 |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
31 def test_bdiff_basic(self): |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
32 cases = [ |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
33 ("a\nc\n\n\n\n", "a\nb\n\n\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
34 ("a\nb\nc\n", "a\nc\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
35 ("", ""), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
36 ("a\nb\nc", "a\nb\nc"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
37 ("a\nb\nc\nd\n", "a\nd\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
38 ("a\nb\nc\nd\n", "a\nc\ne\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
39 ("a\nb\nc\n", "a\nc\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
40 ("a\n", "c\na\nb\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
41 ("a\n", ""), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
42 ("a\n", "b\nc\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
43 ("a\n", "c\na\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
44 ("", "adjfkjdjksdhfksj"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
45 ("", "ab"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
46 ("", "abc"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
47 ("a", "a"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
48 ("ab", "ab"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
49 ("abc", "abc"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
50 ("a\n", "a\n"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
51 ("a\nb", "a\nb"), |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
52 ] |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
53 for a, b in cases: |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
54 self.assert_bdiff(a, b) |
400
8b067bde6679
Add a fast binary diff extension (not yet used)
mpm@selenic.com
parents:
diff
changeset
|
55 |
30592
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
56 def showdiff(self, a, b): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
57 bin = bdiff.bdiff(a, b) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
58 pos = 0 |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
59 q = 0 |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
60 actions = [] |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
61 while pos < len(bin): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
62 p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12]) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
63 pos += 12 |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
64 if p1: |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
65 actions.append(a[q:p1]) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
66 actions.append(diffreplace(p1, p2, a[p1:p2], bin[pos:pos + l])) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
67 pos += l |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
68 q = p2 |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
69 if q < len(a): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
70 actions.append(a[q:]) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
71 return actions |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
72 |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
73 def test_issue1295(self): |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
74 cases = [ |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
75 ("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\nx\n\nz\n", |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
76 ['x\n\nx\n\n', diffreplace(6, 6, '', 'y\n\n'), 'x\n\nx\n\nz\n']), |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
77 ("x\n\nx\n\nx\n\nx\n\nz\n", "x\n\nx\n\ny\n\nx\n\ny\n\nx\n\nz\n", |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
78 ['x\n\nx\n\n', |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
79 diffreplace(6, 6, '', 'y\n\n'), |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
80 'x\n\n', |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
81 diffreplace(9, 9, '', 'y\n\n'), |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
82 'x\n\nz\n']), |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
83 ] |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
84 for old, new, want in cases: |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
85 self.assertEqual(self.showdiff(old, new), want) |
0d8cada9998d
tests: update more of test-bdiff.py to use unittest (part 2 of 4)
Augie Fackler <augie@google.com>
parents:
30591
diff
changeset
|
86 |
30595
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
87 def test_issue1295_varies_on_pure(self): |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
88 # we should pick up abbbc. rather than bc.de as the longest match |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
89 got = self.showdiff("a\nb\nb\nb\nc\n.\nd\ne\n.\nf\n", |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
90 "a\nb\nb\na\nb\nb\nb\nc\n.\nb\nc\n.\nd\ne\nf\n") |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
91 want_c = ['a\nb\nb\n', |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
92 diffreplace(6, 6, '', 'a\nb\nb\nb\nc\n.\n'), |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
93 'b\nc\n.\nd\ne\n', |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
94 diffreplace(16, 18, '.\n', ''), |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
95 'f\n'] |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
96 want_pure = [diffreplace(0, 0, '', 'a\nb\nb\n'), |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
97 'a\nb\nb\nb\nc\n.\n', |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
98 diffreplace(12, 12, '', 'b\nc\n.\n'), |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
99 'd\ne\n', |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
100 diffreplace(16, 18, '.\n', ''), 'f\n'] |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
101 self.assert_(got in (want_c, want_pure), |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
102 'got: %r, wanted either %r or %r' % ( |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
103 got, want_c, want_pure)) |
99bd5479d58b
tests: fix test-bdiff to handle variance between pure and c bdiff code
Augie Fackler <augie@google.com>
parents:
30594
diff
changeset
|
104 |
30593
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
105 def test_fixws(self): |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
106 cases = [ |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
107 (" \ta\r b\t\n", "ab\n", 1), |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
108 (" \ta\r b\t\n", " a b\n", 0), |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
109 ("", "", 1), |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
110 ("", "", 0), |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
111 ] |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
112 for a, b, allws in cases: |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
113 c = bdiff.fixws(a, allws) |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
114 self.assertEqual( |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
115 c, b, 'fixws(%r) want %r got %r (allws=%r)' % (a, b, c, allws)) |
4286015285ec
tests: update more of test-bdiff.py to use unittest (part 3 of 4)
Augie Fackler <augie@google.com>
parents:
30592
diff
changeset
|
116 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
117 def test_nice_diff_for_trivial_change(self): |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
118 self.assertEqual(self.showdiff( |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
119 ''.join('<%s\n-\n' % i for i in range(5)), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
120 ''.join('>%s\n-\n' % i for i in range(5))), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
121 [diffreplace(0, 3, '<0\n', '>0\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
122 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
123 diffreplace(5, 8, '<1\n', '>1\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
124 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
125 diffreplace(10, 13, '<2\n', '>2\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
126 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
127 diffreplace(15, 18, '<3\n', '>3\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
128 '-\n', |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
129 diffreplace(20, 23, '<4\n', '>4\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
130 '-\n']) |
30427
ede7bc45bf0a
tests: make test-bdiff.py easier to maintain
Mads Kiilerich <madski@unity3d.com>
parents:
29013
diff
changeset
|
131 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
132 def test_prefer_appending(self): |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
133 # 1 line to 3 lines |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
134 self.assertEqual(self.showdiff('a\n', 'a\n' * 3), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
135 ['a\n', diffreplace(2, 2, '', 'a\na\n')]) |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
136 # 1 line to 5 lines |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
137 self.assertEqual(self.showdiff('a\n', 'a\n' * 5), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
138 ['a\n', diffreplace(2, 2, '', 'a\na\na\na\n')]) |
30428
3743e5dbb824
tests: explore some bdiff cases
Mads Kiilerich <madski@unity3d.com>
parents:
30427
diff
changeset
|
139 |
30594
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
140 def test_prefer_removing_trailing(self): |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
141 # 3 lines to 1 line |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
142 self.assertEqual(self.showdiff('a\n' * 3, 'a\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
143 ['a\n', diffreplace(2, 6, 'a\na\n', '')]) |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
144 # 5 lines to 1 line |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
145 self.assertEqual(self.showdiff('a\n' * 5, 'a\n'), |
ea648e8f8a34
tests: finish updating test-bdiff to unittest (part 4 of 4)
Augie Fackler <augie@google.com>
parents:
30593
diff
changeset
|
146 ['a\n', diffreplace(2, 10, 'a\na\na\na\n', '')]) |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
147 |
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
148 if __name__ == '__main__': |
30931
f2ad0d804700
test-bdiff: move import inside the function to avoid test failure
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30595
diff
changeset
|
149 import silenttestrunner |
30591
1b393a93a7df
tests: migrate test-bdiff.py to use unittest (part 1 of 4)
Augie Fackler <augie@google.com>
parents:
30433
diff
changeset
|
150 silenttestrunner.main(__name__) |