changeset 47036:ea563187ee7c stable

tests: change the fixer commands to use the buffer attribute on stdio objects Otherwise `\r` was getting injected into the fixed lines and throwing off the commit hashes on Windows when the fixer is invoked with py3. Differential Revision: https://phab.mercurial-scm.org/D10637
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 02 May 2021 16:56:20 -0400
parents 9e3979a25bfe
children 3af293735d0f bea4717415c0
files tests/test-fix-topology.t tests/test-fix.t
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-fix-topology.t	Sat May 01 16:13:53 2021 -0400
+++ b/tests/test-fix-topology.t	Sun May 02 16:56:20 2021 -0400
@@ -6,7 +6,9 @@
   > from mercurial.utils.procutil import setbinary
   > setbinary(sys.stdin)
   > setbinary(sys.stdout)
-  > sys.stdout.write(sys.stdin.read().upper())
+  > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
+  > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
+  > stdout.write(stdin.read().upper())
   > EOF
   $ TESTLINES="foo\nbar\nbaz\n"
   $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
--- a/tests/test-fix.t	Sat May 01 16:13:53 2021 -0400
+++ b/tests/test-fix.t	Sun May 02 16:56:20 2021 -0400
@@ -7,19 +7,21 @@
   > from mercurial.utils.procutil import setbinary
   > setbinary(sys.stdin)
   > setbinary(sys.stdout)
+  > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
+  > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
   > lines = set()
   > for arg in sys.argv[1:]:
   >   if arg == 'all':
-  >     sys.stdout.write(sys.stdin.read().upper())
+  >     stdout.write(stdin.read().upper())
   >     sys.exit(0)
   >   else:
   >     first, last = arg.split('-')
   >     lines.update(range(int(first), int(last) + 1))
-  > for i, line in enumerate(sys.stdin.readlines()):
+  > for i, line in enumerate(stdin.readlines()):
   >   if i + 1 in lines:
-  >     sys.stdout.write(line.upper())
+  >     stdout.write(line.upper())
   >   else:
-  >     sys.stdout.write(line)
+  >     stdout.write(line)
   > EOF
   $ TESTLINES="foo\nbar\nbaz\nqux\n"
   $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY