Skip to content

Commit be3cea0

Browse files
committed
[tests, compilation] Reuse the Scala Compile Server when running sbt project compilation tests
1 parent 2fb837e commit be3cea0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/DisplayModuleNameTestBase.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import org.junit.Assert.fail
66

77
abstract class DisplayModuleNameTestBase(separateProdAndTestSources: Boolean = false) extends SbtProjectCompilationTestBase(separateProdAndTestSources) {
88

9+
override protected def reuseCompileServerProcessBetweenTests: Boolean = false
10+
911
protected def runTest(expectedValue: Boolean): Unit = {
1012
importProject(false)
1113
val modules = ModuleManager.getInstance(myProject).getModules

scala/compiler-integration/test/org/jetbrains/plugins/scala/compiler/SbtProjectCompilationTestBase.scala

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.jetbrains.plugins.scala.compiler
22

3+
import com.intellij.openapi.application.ApplicationManager
34
import com.intellij.openapi.externalSystem.model.ProjectSystemId
45
import com.intellij.openapi.module.Module
56
import com.intellij.openapi.projectRoots.{ProjectJdkTable, Sdk}
67
import com.intellij.openapi.roots.{CompilerModuleExtension, ModuleRootManager}
78
import com.intellij.openapi.vfs.VfsUtil
89
import com.intellij.platform.externalSystem.testFramework.ExternalSystemImportingTestCase
910
import com.intellij.testFramework.CompilerTester
11+
import com.intellij.testFramework.common.ThreadLeakTracker
1012
import org.jetbrains.annotations.Nullable
1113
import org.jetbrains.plugins.scala.base.libraryLoaders.SmartJDKLoader
1214
import org.jetbrains.plugins.scala.extensions.inWriteAction
@@ -50,6 +52,8 @@ abstract class SbtProjectCompilationTestBase(separateProdAndTestSources: Boolean
5052

5153
override def getTestsTempDir: String = this.getClass.getSimpleName
5254

55+
protected def reuseCompileServerProcessBetweenTests: Boolean = true
56+
5357
override def setUp(): Unit = {
5458
super.setUp()
5559

@@ -63,10 +67,26 @@ abstract class SbtProjectCompilationTestBase(separateProdAndTestSources: Boolean
6367
}
6468

6569
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+
}
6684
}
6785

6886
override def tearDown(): Unit = try {
69-
CompileServerLauncher.stopServerAndWait()
87+
if (!reuseCompileServerProcessBetweenTests) {
88+
CompileServerLauncher.stopServerAndWait()
89+
}
7090
compiler.tearDown()
7191
val settings = ScalaCompileServerSettings.getInstance()
7292
settings.USE_DEFAULT_SDK = true

0 commit comments

Comments
 (0)