Skip to content
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

CHECK-EMPTY with windows line breaks #27

Closed
ythri opened this issue Jul 23, 2024 · 1 comment · Fixed by #30
Closed

CHECK-EMPTY with windows line breaks #27

ythri opened this issue Jul 23, 2024 · 1 comment · Fixed by #30
Labels
bug Something isn't working parity Diverging from upstream FileCheck

Comments

@ythri
Copy link

ythri commented Jul 23, 2024

Hi,

I found two more things that I use in tests where this filecheck seems to diverge from the official LLVM FileCheck. I have fixed my tests locally since those issues easy to bypass, but I assume you may want to know about them anyway.

The first is about CHECK-EMPTY and windows line breaks ("\r\n" instead of just "\n").
E.g. the string 1\r\n2\r\n\r\n3 fails for the directives:

CHECK: 1
CHECK-NEXT: 2
CHECK-EMPTY:
CHECK-NEXT: 3

but works with FileCheck-14 (which is the version I currently have installed.

i.e.

$ echo -e "1\r\n2\r\n\r\n3" | hexdump -C
00000000  31 0d 0a 32 0d 0a 0d 0a  33 0a                    |1..2....3.|
$ echo -e "1\r\n2\r\n\r\n3" | FileCheck-14 test.itest
$ echo -e "1\r\n2\r\n\r\n3" | filecheck test.itest
test.itest:3: error: CHECK-EMPTY: is not on the line after the previous match
Current position at <stdin>:2:1

^

CHECK: 1 and CHECK-NEXT: 2 seem to match fine (even with --match-full-lines) but CHECK-EMPTY fails. As soon as I change the third line break to a unix line break (even keeping the others as \r\n), it works:

echo -e "1\r\n2\r\n\n3" | filecheck test.itest

but still fails with --match-full-lines:

echo -e "1\r\n2\r\n\n3" | filecheck test.itest --match-full-lines
test.itest:3: error: CHECK-EMPTY: is not on the line after the previous match
Current position at <stdin>:1:2
2
 ^

I I change the line break after the 2 to a unix line break, it works again

echo -e "1\r\n2\n\n3" | filecheck test.itest --match-full-lines

Changing all line breaks to unix line breaks right before AND after any CHECK-EMPTY directive seems to solve all problems.

All these failing tests work with llvm FileCheck-14. This might be due to the canonicalization mentioned here: https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-FileCheck-strict-whitespace

Cheers. I will create another issue for the second problem I found.

@AntonLydike AntonLydike added bug Something isn't working parity Diverging from upstream FileCheck labels Jul 24, 2024
@AntonLydike
Copy link
Owner

Thanks! Indeed, I hadn't considered Windows line breaks when writing this! I'll take a look what's going on here and will try to work on a fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parity Diverging from upstream FileCheck
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants