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