[clangd] Disable background-index on lit-tests by default
authorKadir Cetinkaya <kadircet@google.com>
Fri, 19 Jul 2019 13:40:30 +0000 (13:40 +0000)
committerKadir Cetinkaya <kadircet@google.com>
Fri, 19 Jul 2019 13:40:30 +0000 (13:40 +0000)
Summary:
Since background-index can perform disk writes, we don't want to turn
it on tests that won't clear it.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 366575

clang-tools-extra/clangd/tool/ClangdMain.cpp

index 5db3d5c..60f1e42 100644 (file)
@@ -355,8 +355,12 @@ int main(int argc, char *argv[]) {
     InputStyle = JSONStreamStyle::Delimited;
     LogLevel = Logger::Verbose;
     PrettyPrint = true;
+    // Disable background index on lit tests by default to prevent disk writes.
+    if (!EnableBackgroundIndex.getNumOccurrences())
+      EnableBackgroundIndex = false;
     // Ensure background index makes progress.
-    BackgroundQueue::preventThreadStarvationInTests();
+    else if (EnableBackgroundIndex)
+      BackgroundQueue::preventThreadStarvationInTests();
   }
   if (Test || EnableTestScheme) {
     static URISchemeRegistry::Add<TestScheme> X(