comparison tests/test_log.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
comparison
equal deleted inserted replaced
224:2ab42323f149 225:fba806958dba
1 from tests import common 1 from tests import common
2 import hglib 2 import hglib
3 from hglib.util import b 3 from hglib.util import b
4 import subprocess
4 5
5 class test_log(common.basetest): 6 class test_log(common.basetest):
6 def test_basic(self): 7 def test_basic(self):
7 self.append('a', 'a') 8 self.append('a', 'a')
8 rev0, node0 = self.client.commit(b('first'), addremove=True) 9 rev0, node0 = self.client.commit(b('first'), addremove=True)
32 self.client.commit(b('first'), addremove=True) 33 self.client.commit(b('first'), addremove=True)
33 revs = self.client.log(keyword=b(''), files=[b('foobar')]) 34 revs = self.client.log(keyword=b(''), files=[b('foobar')])
34 self.assertTrue(len(revs) == 1) 35 self.assertTrue(len(revs) == 1)
35 self.assertEqual(revs[0].rev, b('0')) 36 self.assertEqual(revs[0].rev, b('0'))
36 37
38 def test_null_byte(self):
39 self.append('a', 'a')
40 with open('commitmessagenullbyte', 'w') as f:
41 f.write('some message\0more stuff')
42 # use 'hg' directly here as hglib doesn't allow
43 # committing null byte descriptions
44 subprocess.check_call(["hg", "commit",
45 "-l", "commitmessagenullbyte", "--addremove", "-q"])
46 revs = self.client.log(revrange=b('.'))
47 self.assertEqual(revs[0].desc, b('some message\0more stuff'))
48
37 # def test_errors(self): 49 # def test_errors(self):
38 # self.assertRaisesRegexp(CommandError, 'abort: unknown revision', 50 # self.assertRaisesRegexp(CommandError, 'abort: unknown revision',
39 # self.client.log, 'foo') 51 # self.client.log, 'foo')
40 # self.append('a', 'a') 52 # self.append('a', 'a')
41 # self.client.commit('first', addremove=True) 53 # self.client.commit('first', addremove=True)