This is an archive of the discontinued LLVM Phabricator instance.

Add CLANGD_INCLUDE_TESTS as a separate flag to control clangd tests
AbandonedPublic

Authored by hiraditya on Aug 22 2023, 5:06 PM.

Details

Summary
Keeping the default value ON to preserve the current behavior

Motivation:
1. Some of the clangd (TUSchedulerTests) tests intermittently fails. There are no internal changes to clang-tools-extra
directory. Either the test times out or it fails with mismatches.
2. It also makes sense to be able to disable clangd tests separately from the rest of clang-tools because clangd has it's own unittests directory.

Issue created: https://github.com/llvm/llvm-project/issues/64964
Previously reported issues: https://github.com/llvm/llvm-project/issues/59644, https://github.com/llvm/llvm-project/issues/50117, https://github.com/clangd/clangd/issues/1712

A typical output of ninja check-clang-tools

out/llvm-project/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:1354: Failure
Value of: S.blockUntilIdle(timeoutSeconds(10))
  Actual: false
Expected: true

Built preamble of size 207320 for file /clangd-test/foo.cpp version 3 in 5.44 seconds
Reusing preamble version 3 for version 4 of /clangd-test/foo.cpp
out/llvm-project/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:1318: Failure
Value of: Collector.diagVersions().back()
Expected: has a first field that is equal to "3", and has a second field that is equal to "3"
  Actual: ("3", "4"), whose second field does not match

out/llvm-project/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:1311
Value of: Collector.diagVersions().back()
Expected: has a first field that is equal to "3", and has a second field that is equal to "3"
  Actual: ("2", "3"), whose first field does not match
out/llvm-project/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:1318
Value of: Collector.diagVersions().back()
Expected: has a first field that is equal to "3", and has a second field that is equal to "3"
  Actual: ("3", "4"), whose second field does not match

Diff Detail

Event Timeline

hiraditya created this revision.Aug 22 2023, 5:06 PM
hiraditya requested review of this revision.Aug 22 2023, 5:06 PM
hiraditya updated this revision to Diff 552543.Aug 22 2023, 5:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 5:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
hiraditya edited the summary of this revision. (Show Details)Aug 24 2023, 11:30 AM
hiraditya edited the summary of this revision. (Show Details)
hiraditya edited the summary of this revision. (Show Details)Aug 24 2023, 1:21 PM
hiraditya added a subscriber: nridge.

Added previously reported issues shared by @nridge

bogner accepted this revision.Aug 25 2023, 12:11 AM

I'm not entirely convinced by the motivation (wouldn't it be better to just fix the tests?), but this seems like a perfectly reasonable flag to have.

This revision is now accepted and ready to land.Aug 25 2023, 12:11 AM
ilya-biryukov requested changes to this revision.Aug 25 2023, 1:28 AM
ilya-biryukov added a subscriber: sammccall.

Open question: I also feel like the best option here is to fix the tests, but I'm not sure how hard that would be. @sammccall any thoughts?
I suspect the particular tests are flaky is because they rely on timeouts, not sure it's easy to disentangle them. Therefore, some workaround seems reasonable

If we land this, we should ensure that when CLANG_INCLUDE_TESTS is off, Clangd tests don't run.
Clangd should respect the LLVM-wide options even if it has a more specific one for the project itself.

I'm marking as requiring changes mostly for the latter comment about CLANG_INCLUDE_TESTS.

This revision now requires changes to proceed.Aug 25 2023, 1:28 AM
hiraditya updated this revision to Diff 553738.Aug 26 2023, 8:41 AM

I'm marking as requiring changes mostly for the latter comment about CLANG_INCLUDE_TESTS.

Added CLANG_INCLUDE_TESTS to the conditional. btw when CLANG_INCLUDE_TESTS is OFF, ninja check-clang-tools target doesn't get created so adding CLANG_INCLUDE_TESTS here didn't seem necessary, although tbh i'm not too familiar with the build system.

Open question: I also feel like the best option here is to fix the tests, but I'm not sure how hard that would be. @sammccall any thoughts?
I suspect the particular tests are flaky is because they rely on timeouts, not sure it's easy to disentangle them. Therefore, some workaround seems reasonable

FWIW, i've put some details in https://github.com/llvm/llvm-project/issues/64964#issuecomment-1702249740 and we had some previous discussions but unfortunately these tests have timeouts as a "poor-mans-deadlock-detection". i don't think we can get rid of the timeouts, without sacrificing that detection.
I can't remember how misleading buildbot outputs were, when deadlocks happened, before we introduced timeouts though. So one alternative is let the buildbots hang instead.


Regarding the approach in this patch, I don't feel strongly about it but I don't think it's a good idea to let people build clangd, without testing it on environments they care about. They might suppress legitimate issues. (there's also some value though, e.g. maybe they already performed testing before, and don't want to run tests again, but in such a scenario we've non-check equivalents of targets to only run builds).

Are you building clangd deliberately or is it just being pulled in via check-clang-tools? If you don't want to ship clangd with your toolchain at all, I think it's better to set CLANG_ENABLE_CLANGD to OFF.

Open question: I also feel like the best option here is to fix the tests, but I'm not sure how hard that would be. @sammccall any thoughts?
I suspect the particular tests are flaky is because they rely on timeouts, not sure it's easy to disentangle them. Therefore, some workaround seems reasonable

FWIW, i've put some details in https://github.com/llvm/llvm-project/issues/64964#issuecomment-1702249740 and we had some previous discussions but unfortunately these tests have timeouts as a "poor-mans-deadlock-detection". i don't think we can get rid of the timeouts, without sacrificing that detection.
I can't remember how misleading buildbot outputs were, when deadlocks happened, before we introduced timeouts though. So one alternative is let the buildbots hang instead.


Regarding the approach in this patch, I don't feel strongly about it but I don't think it's a good idea to let people build clangd, without testing it on environments they care about. They might suppress legitimate issues. (there's also some value though, e.g. maybe they already performed testing before, and don't want to run tests again, but in such a scenario we've non-check equivalents of targets to only run builds).

This option only allows more flexibility to the developers and by default it is on so anyone who doesn't care about switching off the test on constrained systems can continue to do so. Do you have specific concerns on why this will prevent developers from testing?

Are you building clangd deliberately or is it just being pulled in via check-clang-tools? If you don't want to ship clangd with your toolchain at all, I think it's better to set CLANG_ENABLE_CLANGD to OFF.

We want to build clangd and it gets tested on a regular basis but the timeout happens on mac builds that are overloaded at times. I don't want to disable the build of clangd just because 1 test is failing.

hi @hiraditya , i believe your issues should disappear starting with 9a26d2c6d35f574d7a4b06a5a22f8a1c063cb664. LMK if you're still facing problems and want to move forward with such a patch

hiraditya abandoned this revision.Sep 15 2023, 10:16 AM