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

Please stop reporting clang-format errors in test directories #55982

Closed
AaronBallman opened this issue Jun 10, 2022 · 7 comments
Closed

Please stop reporting clang-format errors in test directories #55982

AaronBallman opened this issue Jun 10, 2022 · 7 comments
Labels
infrastructure Bugs about LLVM infrastructure

Comments

@AaronBallman
Copy link
Collaborator

The precommit CI pipeline reports clang-format errors, which is incredibly useful. However, it reports them in test files, which renders the functionality effectively useless because we've never enforced coding style in tests and so those false positive reports typically swamp the true positive issues.

Further, we now have people trying to add clang-format tags to the test files to work around this, which adds additional burden on reviewers to mention that these comments are distracting and unnecessary because tests aren't required to be formatted. (We should probably document this better in the coding style guide, but this has been the status quo for ages because test files often exceed 80 col limits when verifying diagnostics, we almost never follow the capitalization and indentation schemes, etc.

Can the precommit CI pipeline please stop reporting clang-format issues in tests?

@AaronBallman AaronBallman added the infrastructure Bugs about LLVM infrastructure label Jun 10, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 10, 2022

@llvm/issue-subscribers-infrastructure

@akyrtzi
Copy link
Contributor

akyrtzi commented Jun 10, 2022

we've never enforced coding style in tests

It's even worse than that, some tests are specifically written in a way to test something, and that way can be incompatible with the clang-format output.

@AaronBallman
Copy link
Collaborator Author

This has been extremely distracting as a code reviewer. Not being able to trust precommit CI failures because they're spurious ~90% of the time is training reviewers to ignore failing precommit CI and is wasting code review time where authors are adding formatting tags to tests and reviewers are asking to remove the formatting tags. Can this please be addressed?

CC @ChristianKuehnel @metaflow in case they can help out here.

@martinboehme
Copy link
Contributor

martinboehme commented Jun 28, 2022

It should be possible to do this simply by adding a .clang-format file to clang/test with this:

{
    "DisableFormat": true,
    "SortIncludes": "Never",
}

I notice however that clang/test already contains a .clang-format file with this:

BasedOnStyle: LLVM
ColumnLimit: 0
AlwaysBreakTemplateDeclarations: No

Looking at the history, it looks as if the intent was to make clang-format "do something useful" on tests. However, the back and forth on the formatting options seems to indicate that this wasn't really useful.

I propose the contents of the file should be changed to turn off formatting completely. I may submit a patch today if I get round to it.

Edit: Having taken a look at the clang-format documentation, I believe just the DisableFormat line should be sufficient.

@martinboehme
Copy link
Contributor

Patch submitted for review:

https://reviews.llvm.org/D128706

I'd like to make sure we have consensus that this is the right change to make, so I'd like multiple reviewers to weigh in. Do you have recommendations for who to add?

@AaronBallman
Copy link
Collaborator Author

Looking at the history, it looks as if the intent was to make clang-format "do something useful" on tests. However, the back and forth on the formatting options seems to indicate that this wasn't really useful.

Thank you for the sleuth work, I hadn't realized we already controlled this!

I'd like to make sure we have consensus that this is the right change to make, so I'd like multiple reviewers to weigh in. Do you have recommendations for who to add?

I mentioned this on the review, but because this is changing something that seems at least partially intentional, we should probably have an RFC on Discourse. Then the reviewers matter less, we're just checking that you did what you said you'd do in the RFC.

@martinboehme
Copy link
Contributor

I mentioned this on the review, but because this is changing something that seems at least partially intentional, we should probably have an RFC on Discourse. Then the reviewers matter less, we're just checking that you did what you said you'd do in the RFC.

Good idea -- done:

https://discourse.llvm.org/t/rfc-disable-clang-format-in-the-clang-test-tree/63498

mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
See discussion here:

llvm/llvm-project#55982

And the RFC here:
https://discourse.llvm.org/t/rfc-disable-clang-format-in-the-clang-test-tree/63498/2

We don't generally expect test files to be formatted according to the
style guide. Indeed, some tests may require specific formatting for the
purposes of the test.

When tests intentionally do not conform to the "correct" formatting,
this causes errors in the CI, which can drown out real errors and causes
people to stop trusting the CI over time.

From the history of the clang/test/.clang-format file, it looks as if
there have been attempts to make clang-format do a subset of formatting
that would be useful for tests. However, it looks as if it's hard to
make clang-format do exactly the right thing -- see the back-and-forth
between
13316a7
and
7b5bddf.

These changes disable the .clang-format file for clang/test, llvm/test,
and clang-tools-extra/test.

Fixes #55982
Differential Revision: https://reviews.llvm.org/D128706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Bugs about LLVM infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants