[lit] Clean up internal diff's encoding handling
authorJoel E. Denny <jdenny.ornl@gmail.com>
Thu, 10 Oct 2019 17:39:41 +0000 (17:39 +0000)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Thu, 10 Oct 2019 17:39:41 +0000 (17:39 +0000)
commit19e6bb25f05fa24ea445dd455c7f44fc3b036725
tree25be78f2d0df70fccaff0effd501c06d108b710c
parentdf35ec8289eec85e9a551578b1b7ae35b214860f
[lit] Clean up internal diff's encoding handling

As suggested by rnk at D67643#1673043, instead of reading files
multiple times until an appropriate encoding is found, read them once
as binary, and then try to decode what was read.

For python >= 3.5, don't fail when attempting to decode the
`diff_bytes` output in order to print it.

Finally, add some tests for encoding handling.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D68664

llvm-svn: 374389
llvm/utils/lit/lit/builtin_commands/diff.py
llvm/utils/lit/tests/Inputs/shtest-shell/diff-encodings.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.bin [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.utf16 [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.utf8 [new file with mode: 0644]
llvm/utils/lit/tests/max-failures.py
llvm/utils/lit/tests/shtest-shell.py