[Test] JS backend recompilation tests: Dispose the test root disposable of the subordinate incremental configuration

- The incremental configuration for JS recompilation tests creates its
  own test root disposable. It needs to be properly handled to avoid
  disposable leaks.
- The incremental configuration's disposable is registered with the
  parent configuration's disposable because it lives in its scope and
  should thus not be a root disposable. It's also disposed at the end of
  `transform` because the incremental configuration's lifetime ends
  there.

^KT-64099 fixed
This commit is contained in:
Marco Pennekamp
2023-12-05 21:03:40 +01:00
committed by Space Team
parent a4fc658fb3
commit 76a4b32c1f
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.js.test.converters.incremental
import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestInfrastructureInternals
import org.jetbrains.kotlin.test.TestRunner
@@ -50,6 +51,9 @@ abstract class CommonRecompileModuleJsBackendFacade<R : ResultingArtifact.Fronte
configure(module)
}
// The incremental configuration creates its own test root disposable. It needs to be properly handled to avoid disposable leaks.
Disposer.register(testServices.testConfiguration.rootDisposable, incrementalConfiguration.rootDisposable)
val moduleStructure = testServices.moduleStructure
val incrementalModule = module.copy(files = filesToRecompile)
val incrementalModuleStructure = TestModuleStructureImpl(
@@ -71,9 +75,14 @@ abstract class CommonRecompileModuleJsBackendFacade<R : ResultingArtifact.Fronte
incrementalServices.register(module)
incrementalRunner.processModule(incrementalModule, incrementalDependencyProvider)
incrementalRunner.reportFailures(incrementalServices)
val incrementalArtifact = incrementalDependencyProvider.getArtifact(incrementalModule, ArtifactKinds.Js)
val incrementalArtifact = try {
incrementalRunner.processModule(incrementalModule, incrementalDependencyProvider)
incrementalRunner.reportFailures(incrementalServices)
incrementalDependencyProvider.getArtifact(incrementalModule, ArtifactKinds.Js)
} finally {
Disposer.dispose(incrementalConfiguration.rootDisposable)
}
return BinaryArtifacts.Js.IncrementalJsArtifact(inputArtifact, incrementalArtifact)
}