|
|
|
@ -36,7 +36,12 @@ class GradlePluginTest : GradlePluginTestBase() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun configurePreview() { |
|
|
|
|
fun configurePreviewWithoutConfigurationCache() = configurePreview(withConfigurationCache = false) |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun configurePreviewWithConfigurationCache() = configurePreview(withConfigurationCache = true) |
|
|
|
|
|
|
|
|
|
private fun configurePreview(withConfigurationCache: Boolean) { |
|
|
|
|
val isAlive = AtomicBoolean(true) |
|
|
|
|
val receivedConfigCount = AtomicInteger(0) |
|
|
|
|
val port = AtomicInteger(-1) |
|
|
|
@ -45,7 +50,7 @@ class GradlePluginTest : GradlePluginTestBase() {
|
|
|
|
|
soTimeout = 10_000 |
|
|
|
|
} |
|
|
|
|
port.set(serverSocket.localPort) |
|
|
|
|
try { |
|
|
|
|
serverSocket.use { |
|
|
|
|
while (isAlive.get()) { |
|
|
|
|
try { |
|
|
|
|
val socket = serverSocket.accept() |
|
|
|
@ -63,9 +68,6 @@ class GradlePluginTest : GradlePluginTestBase() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} finally { |
|
|
|
|
serverSocket.close() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -80,7 +82,7 @@ class GradlePluginTest : GradlePluginTestBase() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
testConfigureDesktopPreivewImpl(port.get()) |
|
|
|
|
testConfigureDesktopPreviewImpl(port.get(), withConfigurationCache) |
|
|
|
|
} finally { |
|
|
|
|
isAlive.set(false) |
|
|
|
|
connectionThread.interrupt() |
|
|
|
@ -94,20 +96,31 @@ class GradlePluginTest : GradlePluginTestBase() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun testConfigureDesktopPreivewImpl(port: Int) { |
|
|
|
|
private fun testConfigureDesktopPreviewImpl(port: Int, withConfigurationCache: Boolean) { |
|
|
|
|
check(port > 0) { "Invalid port: $port" } |
|
|
|
|
with(testProject(TestProjects.jvmPreview)) { |
|
|
|
|
val portProperty = "-Pcompose.desktop.preview.ide.port=$port" |
|
|
|
|
val previewTargetProperty = "-Pcompose.desktop.preview.target=PreviewKt.ExamplePreview" |
|
|
|
|
val jvmTask = ":jvm:configureDesktopPreview" |
|
|
|
|
gradle(jvmTask, portProperty, previewTargetProperty) |
|
|
|
|
val configurationCacheArg = "--configuration-cache" |
|
|
|
|
val jvmRunner = if (withConfigurationCache) { |
|
|
|
|
gradle(jvmTask, portProperty, previewTargetProperty, configurationCacheArg) |
|
|
|
|
} else { |
|
|
|
|
gradle(jvmTask, portProperty, previewTargetProperty) |
|
|
|
|
} |
|
|
|
|
jvmRunner |
|
|
|
|
.build() |
|
|
|
|
.checks { check -> |
|
|
|
|
check.taskOutcome(jvmTask, TaskOutcome.SUCCESS) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val mppTask = ":mpp:configureDesktopPreviewDesktop" |
|
|
|
|
gradle(mppTask, portProperty, previewTargetProperty) |
|
|
|
|
val mppRunner = if (withConfigurationCache) { |
|
|
|
|
gradle(mppTask, portProperty, previewTargetProperty, configurationCacheArg) |
|
|
|
|
} else { |
|
|
|
|
gradle(mppTask, portProperty, previewTargetProperty) |
|
|
|
|
} |
|
|
|
|
mppRunner |
|
|
|
|
.build() |
|
|
|
|
.checks { check -> |
|
|
|
|
check.taskOutcome(mppTask, TaskOutcome.SUCCESS) |
|
|
|
|