changeset 44642:da9b7f9635a2

tests: use `f --hexdump` to print file content The inline print.py in this test wasn't fully compatible with Python 3 because it was reading from sys.stdin, which already normalized line endings since it operates in the realm of str on Python 3. To do this correctly, we'd need to read from sys.stdin.buffer on Python 3. This would entail conditional code. I felt this was too much effort. So I just replaced the custom script with `f`, which already knows how to do the right thing. test-mactext.t now passes on Python 3 on Windows. Differential Revision: https://phab.mercurial-scm.org/D8336
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 28 Mar 2020 13:29:25 -0700
parents e74af49aa3c9
children 0437959de6f5
files tests/test-mactext.t
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-mactext.t	Sat Mar 28 13:12:43 2020 -0700
+++ b/tests/test-mactext.t	Sat Mar 28 13:29:25 2020 -0700
@@ -7,10 +7,6 @@
   >     data = data.replace(b'\n', b'\r')
   >     open(path, 'wb').write(data)
   > EOF
-  $ cat > print.py <<EOF
-  > import sys
-  > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
-  > EOF
   $ hg init
   $ echo '[hooks]' >> .hg/hgrc
   $ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
@@ -32,7 +28,9 @@
   rollback completed
   abort: pretxncommit.cr hook failed
   [255]
-  $ hg cat f | "$PYTHON" print.py
-  hello<LF>
-  $ cat f | "$PYTHON" print.py
-  hello<CR>
+  $ hg cat f | f --hexdump
+  
+  0000: 68 65 6c 6c 6f 0a                               |hello.|
+  $ f --hexdump f
+  f:
+  0000: 68 65 6c 6c 6f 0d                               |hello.|