[PATCH] D68664: [lit] Clean up internal diff's encoding handling

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 07:58:36 PDT 2019


jdenny updated this revision to Diff 224051.
jdenny added a comment.

Removed commented code pointed out during review.

Changed `diff.decode(errors="replace")` to `diff.decode(errors="backslashreplace")` so the test suite doesn't fail at  `sys.stdout.write(diff)` when running with python3.  The test's commands worked fine when running interactively from a shell prompt, apparently because stdout is then different.  Sorry, I must have forgotten to re-run the actual test suite with python3 after making some change here.

In any case, `backslashreplace` results in output like the following, where `\xff` represents the bytes that cannot be rendered:

   foo
  -bar
  +bar\xff\xff
   baz

That seems better than `ignore`, which just drops them altogether:

   foo
  -bar
  +bar
   baz


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68664/new/

https://reviews.llvm.org/D68664

Files:
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-encodings.txt
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.bin
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.utf16
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.utf8
  llvm/utils/lit/tests/max-failures.py
  llvm/utils/lit/tests/shtest-shell.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68664.224051.patch
Type: text/x-patch
Size: 6059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191009/5ff0daf0/attachment.bin>


More information about the llvm-commits mailing list