Add more pre-run asserts for the DirCompletionAbsolute test

Summary:
The DirCompletionAbsolute is still randomly failing on the nodes even after D50722, so this patch adds more asserts
that verify certain properties on which the actual completion implementation relies on.

The first assert checks that the directory we complete on actually exists. If the directory doesn't exist on the
next CI failure, this assert should catch it and we know that the 0 matches come from a missing base directory.

The second assert is just checking that we are below the PATH_MAX limit that the completion checks against.
This check could randomly fail if the temporary directories we generate are sometimes longer than PATH_MAX,
and the assert can tell us that this is the reason we failed (instead of the mysterious '0 matches').

(As a sidenote: We shouldn't be checking against PATH_MAX anyway in the code (as this is just wrong). Also
the disk completion API really needs a better error mechanism than returning 0 on both error or no-results.)

Reviewers: aprantl, friss

Reviewed By: aprantl

Subscribers: abidh

Differential Revision: https://reviews.llvm.org/D51111

llvm-svn: 340589
This commit is contained in:
Raphael Isemann 2018-08-23 23:21:52 +00:00
parent 7a973fb7f2
commit 3e1c793e9d
1 changed files with 3 additions and 0 deletions

View File

@ -163,6 +163,9 @@ TEST_F(CompletionTest, DirCompletionAbsolute) {
// When a directory is specified that doesn't end in a slash, it searches
// for that directory, not items under it.
// Sanity check that the path we complete on exists and isn't too long.
ASSERT_TRUE(llvm::sys::fs::exists(BaseDir));
ASSERT_LE(BaseDir.size(), static_cast<size_t>(PATH_MAX));
size_t Count =
CommandCompletions::DiskDirectories(BaseDir, Results, Resolver);
ASSERT_EQ(1u, Count);