# HG changeset patch # User Augie Fackler # Date 1576077658 18000 # Node ID 1a318162f06f171f0fe1ebc26ff016ebbccc0dbd # Parent 513ebe91dc7228babfd1096617ba86dc172349d0 grep: update tests to cope with behavior change in hg 5.2 I wonder if we should make hglib's grep behave consistently across all hg versions somehow, but I'm not going to attempt that for now. diff -r 513ebe91dc72 -r 1a318162f06f tests/test-grep.py --- a/tests/test-grep.py Wed Dec 11 09:39:53 2019 -0500 +++ b/tests/test-grep.py Wed Dec 11 10:20:58 2019 -0500 @@ -10,13 +10,22 @@ # no match self.assertEquals(list(self.client.grep(b('c'))), []) - self.assertEquals(list(self.client.grep(b('a'))), - [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) - self.assertEquals(list(self.client.grep(b('a'), b('a'))), - [(b('a'), b('0'), b('a'))]) + if self.client.version >= (5, 2): + self.assertEquals(list(self.client.grep(b('a'))), + [(b('a'), b('a'), b('b'))]) + self.assertEquals(list(self.client.grep(b('a'), b('a'))), + [(b('a'), b('a'), b(''))]) - self.assertEquals(list(self.client.grep(b('b'))), - [(b('b'), b('0'), b('ab'))]) + self.assertEquals(list(self.client.grep(b('b'))), + [(b('b'), b('ab'), b(''))]) + else: + self.assertEquals(list(self.client.grep(b('a'))), + [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))]) + self.assertEquals(list(self.client.grep(b('a'), b('a'))), + [(b('a'), b('0'), b('a'))]) + + self.assertEquals(list(self.client.grep(b('b'))), + [(b('b'), b('0'), b('ab'))]) def test_options(self): self.append('a', 'a\n') @@ -27,16 +36,26 @@ (b('b'), b('0'), b('+'), b('ab'))], list(self.client.grep(b('a'), all=True))) - self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], - list(self.client.grep(b('a'), fileswithmatches=True))) + if self.client.version >= (5, 2): + self.assertEquals([(b('a'), b('b'))], + list(self.client.grep(b('a'), fileswithmatches=True))) + + self.assertEquals([(b('a'), b('1'), b('a'), b('b'))], + list(self.client.grep(b('a'), line=True))) - self.assertEquals([(b('a'), b('0'), b('1'), b('a')), - (b('b'), b('0'), b('1'), b('ab'))], - list(self.client.grep(b('a'), line=True))) + self.assertEquals([(b('a'), b('test'), b('a'), b('b'))], + list(self.client.grep(b('a'), user=True))) + else: + self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))], + list(self.client.grep(b('a'), fileswithmatches=True))) - self.assertEquals([(b('a'), b('0'), b('test'), b('a')), - (b('b'), b('0'), b('test'), b('ab'))], - list(self.client.grep(b('a'), user=True))) + self.assertEquals([(b('a'), b('0'), b('1'), b('a')), + (b('b'), b('0'), b('1'), b('ab'))], + list(self.client.grep(b('a'), line=True))) + + self.assertEquals([(b('a'), b('0'), b('test'), b('a')), + (b('b'), b('0'), b('test'), b('ab'))], + list(self.client.grep(b('a'), user=True))) self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')), (b('b'), b('0'), b('1'), b('+'), b('test'))],