1
1
package org .jetbrains .plugins .scala .compiler
2
2
3
+ import com .intellij .openapi .application .ApplicationManager
3
4
import com .intellij .openapi .externalSystem .model .ProjectSystemId
4
5
import com .intellij .openapi .module .Module
5
6
import com .intellij .openapi .projectRoots .{ProjectJdkTable , Sdk }
6
7
import com .intellij .openapi .roots .{CompilerModuleExtension , ModuleRootManager }
7
8
import com .intellij .openapi .vfs .VfsUtil
8
9
import com .intellij .platform .externalSystem .testFramework .ExternalSystemImportingTestCase
9
10
import com .intellij .testFramework .CompilerTester
11
+ import com .intellij .testFramework .common .ThreadLeakTracker
10
12
import org .jetbrains .annotations .Nullable
11
13
import org .jetbrains .plugins .scala .base .libraryLoaders .SmartJDKLoader
12
14
import org .jetbrains .plugins .scala .extensions .inWriteAction
@@ -50,6 +52,8 @@ abstract class SbtProjectCompilationTestBase(separateProdAndTestSources: Boolean
50
52
51
53
override def getTestsTempDir : String = this .getClass.getSimpleName
52
54
55
+ protected def reuseCompileServerProcessBetweenTests : Boolean = true
56
+
53
57
override def setUp (): Unit = {
54
58
super .setUp()
55
59
@@ -63,10 +67,26 @@ abstract class SbtProjectCompilationTestBase(separateProdAndTestSources: Boolean
63
67
}
64
68
65
69
SbtCachesSetupUtil .setupCoursierAndIvyCache(getProject)
70
+
71
+ if (reuseCompileServerProcessBetweenTests) {
72
+ // noinspection ApiStatus,UnstableApiUsage
73
+ ThreadLeakTracker .longRunningThreadCreated(
74
+ ApplicationManager .getApplication,
75
+ " BaseDataReader: output stream of scalaCompileServer" ,
76
+ " BaseDataReader: error stream of scalaCompileServer" ,
77
+ " scalaCompileServer"
78
+ )
79
+ } else {
80
+ // We don't want to reuse the compile server in this test class, but it may have already been started.
81
+ // We should shut it down first.
82
+ CompileServerLauncher .stopServerAndWait()
83
+ }
66
84
}
67
85
68
86
override def tearDown (): Unit = try {
69
- CompileServerLauncher .stopServerAndWait()
87
+ if (! reuseCompileServerProcessBetweenTests) {
88
+ CompileServerLauncher .stopServerAndWait()
89
+ }
70
90
compiler.tearDown()
71
91
val settings = ScalaCompileServerSettings .getInstance()
72
92
settings.USE_DEFAULT_SDK = true
0 commit comments