Mercurial > python-hglib
annotate tests/test_heads.py @ 225:fba806958dba
tests: add regression test to check for null byte handling
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Tue, 14 Mar 2023 14:35:58 +0100 |
parents | a2afbf236ca8 |
children |
rev | line source |
---|---|
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
1 from tests import common |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
57
diff
changeset
|
2 from hglib.util import b |
225
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
3 import subprocess |
57 | 4 |
5 class test_heads(common.basetest): | |
6 def test_empty(self): | |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
7 self.assertEqual(self.client.heads(), []) |
57 | 8 |
9 def test_basic(self): | |
10 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
57
diff
changeset
|
11 rev, node0 = self.client.commit(b('first'), addremove=True) |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
12 self.assertEqual(self.client.heads(), [self.client.tip()]) |
57 | 13 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
57
diff
changeset
|
14 self.client.branch(b('foo')) |
57 | 15 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
57
diff
changeset
|
16 rev, node1 = self.client.commit(b('second')) |
57 | 17 |
221
a2afbf236ca8
hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
219
diff
changeset
|
18 self.assertEqual(self.client.heads(node0, topological=True), []) |
225
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
19 |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
20 def test_null_byte(self): |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
21 self.append('a', 'a') |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
22 with open('commitmessagenullbyte', 'w') as f: |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
23 f.write('some message\0more stuff') |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
24 # use 'hg' directly here as hglib doesn't allow |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
25 # committing null byte descriptions |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
26 subprocess.check_call(["hg", "commit", |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
27 "-l", "commitmessagenullbyte", "--addremove", "-q"]) |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
28 revs = self.client.heads() |
fba806958dba
tests: add regression test to check for null byte handling
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
221
diff
changeset
|
29 self.assertEqual(revs[0].desc, b('some message\0more stuff')) |