D8336: tests: use `f --hexdump` to print file content

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

D8336: tests: use `f --hexdump` to print file content

valentin.gatienbaron (Valentin Gatien-Baron)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8336

AFFECTED FILES
  tests/test-mactext.t

CHANGE DETAILS

diff --git a/tests/test-mactext.t b/tests/test-mactext.t
--- a/tests/test-mactext.t
+++ b/tests/test-mactext.t
@@ -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.|



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8336: tests: use `f --hexdump` to print file content

valentin.gatienbaron (Valentin Gatien-Baron)
marmoute added a comment.
marmoute accepted this revision.


  sure

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8336/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8336

To: indygreg, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8336: tests: use `f --hexdump` to print file content

valentin.gatienbaron (Valentin Gatien-Baron)
In reply to this post by valentin.gatienbaron (Valentin Gatien-Baron)
Closed by commit rHGda9b7f9635a2: tests: use `f --hexdump` to print file content (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8336?vs=20902&id=20941

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8336/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8336

AFFECTED FILES
  tests/test-mactext.t

CHANGE DETAILS

diff --git a/tests/test-mactext.t b/tests/test-mactext.t
--- a/tests/test-mactext.t
+++ b/tests/test-mactext.t
@@ -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.|



To: indygreg, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel