[PATCH] D43165: [lit] Fix problem in how Python versions open files with different encodings

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 18:22:01 PST 2018


zturner added a comment.

In https://reviews.llvm.org/D43165#1015131, @zturner wrote:

> In https://reviews.llvm.org/D43165#1015130, @zturner wrote:
>
> > I checked the code and this happens indirectly inside of a call to `compareDirectoryTrees`.  So indeed, it would be hard to explicitly request a binary diff.  Instead, could we //detect// if a file is binary, and if it is fall back to a binary diff?  For example, using code like this <http://code.activestate.com/recipes/173220/>.  We could put this in a function named `lit.util.is_binary(file)` and inside of `compareDirectoryTrees` we could call this function and then branch to the appropriate diff function.
> >
> > Thoughts?
>
>
> There's also `mimetypes.guess_type(file)` which might be helpful here.


Another option, what if we compared all files as binary?  We aren't actually interested in the specific places where files differ, we only ever care that they do differ.  This wouldn't work if we compare generated files against checked in files, because in that case we'd need line ending translation, but if we're only ever comparing generated files against generated files, it seems like binary should be sufficient?

Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D43165





More information about the llvm-commits mailing list