[PATCH] D68839: [lit] Fix internal diff's --strip-trailing-cr and use it

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 15:21:30 PDT 2019


jdenny created this revision.
jdenny added reviewers: probinson, stella.stamenova, bd1976llvm, jlpeyton, rnk, mgorny.
Herald added a subscriber: delcypher.
Herald added a project: LLVM.
jdenny added a child revision: D66506: [lit] Fix internal env calling other internal commands.
jdenny added a parent revision: D68668: [lit] Extend internal diff to support -U.

Using GNU diff, `--strip-trailing-cr` removes a `\r` appearing before
a `\n` at the end of a line.  Without this patch, lit's internal diff
only removes `\r` if it appears as the last character.  That seems
useless.  This patch fixes that.

This patch also adds `--strip-trailing-cr` to some tests that fail on
Windows bots when D68664 <https://reviews.llvm.org/D68664> is applied.  Based on what I see in the bot 
logs, I think the following is happening.  In each test there, lit 
diff is comparing a file with `\r\n` line endings to a file with `\n`
line endings.  Without D68664 <https://reviews.llvm.org/D68664>, lit diff reads those files with
Python's universal newlines support activated, causing `\r` to be
dropped.  However, with D68664 <https://reviews.llvm.org/D68664>, lit diff reads the files in binary
mode instead and thus reports that every line is different, just as
GNU diff does (at least under Ubuntu).  Adding `--strip-trailing-cr`
to those tests restores the previous behavior while permitting the 
behavior of lit diff to be more like GNU diff.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68839

Files:
  llvm/test/MC/AsmParser/preserve-comments.s
  llvm/test/tools/llvm-cxxmap/remap.test
  llvm/test/tools/llvm-profdata/profile-symbol-list.test
  llvm/test/tools/llvm-profdata/roundtrip.test
  llvm/test/tools/llvm-profdata/sample-remap.test
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.dos
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.unix
  llvm/utils/lit/tests/Inputs/shtest-shell/diff-strip-trailing-cr.txt
  llvm/utils/lit/tests/max-failures.py
  llvm/utils/lit/tests/shtest-shell.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68839.224490.patch
Type: text/x-patch
Size: 8677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/5ba03117/attachment.bin>


More information about the llvm-commits mailing list