Details
- Reviewers
sammccall - Commits
- rG164a10dcf205: [clangd] Test against path insensitivity
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/unittests/TestFS.cpp | ||
---|---|---|
88 | This is clever, but I don't think it's a good idea. It's very surprising given the contract and historical behavior of this function, and can lead to spurious test failures in some legitimate uses, e.g in IncludeCleanerTests: // Note we deduped the names as _number_ of <built-in>s is uninteresting. EXPECT_THAT(ReferencedFileNames.keys(), UnorderedElementsAre("<built-in>", "<scratch space>", testPath("macros.h"))); (Not sure why this isn't failing, luck? Maybe you'll get more failures by adding more possible case variations?) The paths coming from testRoot get propagated around a lot, so lots of strings start having unpredictable case (which is the point!). Nevertheless I'm not confident many of them will be effectively tested, because the paths compared need to originate through independent calls to testRoot() rather than e.g. both resulting from relative paths resolved against a CWD set to testRoot() called once. |
clang-tools-extra/clangd/support/Path.h | ||
---|---|---|
50 ↗ | (On Diff #414326) | This function is a bit of a trap. c.f. pathStartsWith which understands path semantics: pathStartsWith("a/b", "a/bc") is false. This function returns true/false based on paths semantics, but the stripping is lexical:
It's safe where called here because we know testRoot() ends in a slash, but I'd probably inline it for that reason - it's not as reusable as it looks. Up to you, though. |
clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp | ||
277 | mac is the same as windows here I think. This should probably be #ifdef CLANGD_PATH_CASE_INSENSITIVE if possible? If you want to be really clever, you could keep the test on all platforms and just #ifdef the assertions to give opposite results. We don't want tests to pass if we are case insensitive everywhere, right? | |
281 | are the inline functions essential to this test? | |
294 | either a comment or a variable name explaining what we're doing here? // Providing the "wrong"-case drive letter in the query should still find the file. Why uppercase the drive letter only and not the whole filename? Then we could run the test on mac too | |
295 | May be nice to have an assertion that HeaderAbsPath != testPath(TU.HeaderFilename), so that we're not spuriously passing because testRoot() is "C:\" or "\\something" |
clang-tools-extra/clangd/support/Path.h | ||
---|---|---|
50 ↗ | (On Diff #414326) | fair point, moved into TestFS.cpp. |
clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp | ||
281 | yes, we need majority of the symbols to be defined in the header, so that the heuristic picks the header as the implementation file (if the header isn't ignored due to case-sensitive check of filepaths). adding a comment though. |
mac is the same as windows here I think.
This should probably be #ifdef CLANGD_PATH_CASE_INSENSITIVE if possible?
If you want to be really clever, you could keep the test on all platforms and just #ifdef the assertions to give opposite results. We don't want tests to pass if we are case insensitive everywhere, right?