Skip to content

Commit 390458a

Browse files
committed
[tests] Fix the RevertableChange test implementations which modify the Scala compile server settings
- In the previous implementation, the revertable change was fully reverting _all_ compile server settings as they were before the test was run. - On a brand-new machine, with no history of running any tests which use the compile server, this result in always reverting the compile server settings to their default state. - We reuse the compile server much more prominently in tests now, to significantly improve test execution time. - This resulted in the reused compile server process reading default data from the disk, ending in test failures due to misconfiguration.
1 parent ac8b1f0 commit 390458a

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

scala/scala-impl/test/org/jetbrains/plugins/scala/util/CompilerTestUtil.scala

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,24 @@ object CompilerTestUtil {
3232
}
3333
}
3434

35-
def withEnabledCompileServer(enable: Boolean): RevertableChange = withModifiedCompileServerSettings { settings =>
36-
settings.COMPILE_SERVER_ENABLED = enable
37-
settings.COMPILE_SERVER_SHUTDOWN_IDLE = true
38-
settings.COMPILE_SERVER_SHUTDOWN_DELAY = 30
35+
def withEnabledCompileServer(enable: Boolean): RevertableChange = {
36+
val settings = compileServerSettings
37+
val r1 = RevertableChange.withModifiedSetting[Boolean](
38+
settings.COMPILE_SERVER_ENABLED,
39+
settings.COMPILE_SERVER_ENABLED = _,
40+
enable
41+
)
42+
val r2 = RevertableChange.withModifiedSetting[Boolean](
43+
settings.COMPILE_SERVER_SHUTDOWN_IDLE,
44+
settings.COMPILE_SERVER_SHUTDOWN_IDLE = _,
45+
true
46+
)
47+
val r3 = RevertableChange.withModifiedSetting[Int](
48+
settings.COMPILE_SERVER_SHUTDOWN_DELAY,
49+
settings.COMPILE_SERVER_SHUTDOWN_DELAY = _,
50+
30
51+
)
52+
r1 |+| r2 |+| r3
3953
}
4054

4155
def withForcedJdkForBuildProcess(jdk: Sdk): RevertableChange = new RevertableChange {
@@ -60,11 +74,20 @@ object CompilerTestUtil {
6074
}
6175
}
6276

63-
def withCompileServerJdk(sdk: Sdk): RevertableChange =
64-
withModifiedCompileServerSettings { settings =>
65-
settings.USE_DEFAULT_SDK = false
66-
settings.COMPILE_SERVER_SDK = sdk.getName
67-
}
77+
def withCompileServerJdk(sdk: Sdk): RevertableChange = {
78+
val settings = compileServerSettings
79+
val r1 = RevertableChange.withModifiedSetting[Boolean](
80+
settings.USE_DEFAULT_SDK,
81+
settings.USE_DEFAULT_SDK = _,
82+
false
83+
)
84+
val r2 = RevertableChange.withModifiedSetting[String](
85+
settings.COMPILE_SERVER_SDK,
86+
settings.COMPILE_SERVER_SDK = _,
87+
sdk.getName
88+
)
89+
r1 |+| r2
90+
}
6891

6992
private def withErrorsFromCompiler(project: Project, enabled: Boolean): RevertableChange = {
7093
val revertible1 = RevertableChange.withModifiedSetting(

0 commit comments

Comments
 (0)