forked from OSchip/llvm-project
[clangd] Avoid combinatorial explosion in CodeCompleteTests.
Summary: This test dominates our unit test runtime, and the change speeds it up by 10x. We lose coverage of some combinations of flags, but I'm not sure that's finding many bugs. 3300 -> 300ms on my machine (3800 -> 800ms for the whole of CompletionTest). Reviewers: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42063 llvm-svn: 322547
This commit is contained in:
parent
4cab0fec44
commit
2c3849af22
|
@ -255,26 +255,26 @@ void TestGlobalScopeCompletion(clangd::CodeCompleteOptions Opts) {
|
|||
}
|
||||
|
||||
TEST(CompletionTest, CompletionOptions) {
|
||||
clangd::CodeCompleteOptions Opts;
|
||||
for (bool IncludeMacros : {true, false}) {
|
||||
Opts.IncludeMacros = IncludeMacros;
|
||||
for (bool IncludeGlobals : {true, false}) {
|
||||
Opts.IncludeGlobals = IncludeGlobals;
|
||||
for (bool IncludeBriefComments : {true, false}) {
|
||||
Opts.IncludeBriefComments = IncludeBriefComments;
|
||||
for (bool EnableSnippets : {true, false}) {
|
||||
Opts.EnableSnippets = EnableSnippets;
|
||||
for (bool IncludeCodePatterns : {true, false}) {
|
||||
Opts.IncludeCodePatterns = IncludeCodePatterns;
|
||||
for (bool IncludeIneligibleResults : {true, false}) {
|
||||
Opts.IncludeIneligibleResults = IncludeIneligibleResults;
|
||||
TestAfterDotCompletion(Opts);
|
||||
TestGlobalScopeCompletion(Opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
auto Test = [&](const clangd::CodeCompleteOptions &Opts) {
|
||||
TestAfterDotCompletion(Opts);
|
||||
TestGlobalScopeCompletion(Opts);
|
||||
};
|
||||
// We used to test every combination of options, but that got too slow (2^N).
|
||||
auto Flags = {
|
||||
&clangd::CodeCompleteOptions::IncludeMacros,
|
||||
&clangd::CodeCompleteOptions::IncludeGlobals,
|
||||
&clangd::CodeCompleteOptions::IncludeBriefComments,
|
||||
&clangd::CodeCompleteOptions::EnableSnippets,
|
||||
&clangd::CodeCompleteOptions::IncludeCodePatterns,
|
||||
&clangd::CodeCompleteOptions::IncludeIneligibleResults,
|
||||
};
|
||||
// Test default options.
|
||||
Test({});
|
||||
// Test with one flag flipped.
|
||||
for (auto &F : Flags) {
|
||||
clangd::CodeCompleteOptions O;
|
||||
O.*F ^= true;
|
||||
Test(O);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue