Skip to content

[llvm-lit] Lit's built-in cat command not handling carriage returns correctly #106302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
connieyzhu opened this issue Aug 27, 2024 · 0 comments

Comments

@connieyzhu
Copy link
Contributor

When using lit's internal shell to run clang-tools-extra/test/clang-apply-replacements/crlf.cpp, the test fails. Upon further inspection, this is due to lit's built-in cat command not behaving the same as many systems' cat (e.g. Linux). It is not able to identify carriage returns (^M) in files.

This problem was diagnosed by running cat %S/Inputs/crlf/crlf.cpp (in line 2 of the above file) with both the internal shell and with a Linux shell, and redirecting output to two different files. When analyzing the files with cat -e in the Linux shell, the following is displayed:

cat %S/Inputs/crlf/crlf.cpp run with Linux shell (expected output):

^M$
// This file intentionally uses a CRLF newlines!^M$
^M$
void foo() {^M$
  int *x = 0;^M$
}^M$

cat %S/Inputs/crlf/crlf.cpp run with lit internal shell (actual output):

$
// This file intentionally uses a CRLF newlines!$
$
void foo() {$
  int *x = 0;$
}$

This poses an issue, as the tests in this file rely on precise character offset to make text replacements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants