Skip to content

Commit 4014156

Browse files
committed
Revert^2 "Add wasm target to compose runtime"
Reason for revert: fixed issue in parent 1dd7d85 Change-Id: I9a9c91b9ad17b9dd5dd4dadbe7dd0c2878d8611f
1 parent 6402c33 commit 4014156

30 files changed

Lines changed: 542 additions & 34 deletions

‎compose/runtime/runtime-annotation/build.gradle‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ androidXMultiplatform {
3939
ios()
4040
watchos()
4141
tvos()
42+
wasmJs()
4243

4344
defaultPlatform(PlatformIdentifier.JVM)
4445

@@ -48,6 +49,15 @@ androidXMultiplatform {
4849
api(libs.kotlinStdlib)
4950
}
5051
}
52+
53+
wasmJsMain {
54+
dependsOn(commonMain)
55+
dependencies {
56+
// For KotlinWasm/Js, versions of toolchain and stdlib need to be the same (2.1):
57+
// https://youtrack.jetbrains.com/issue/KT-71032
58+
api(libs.kotlinStdlibWasm)
59+
}
60+
}
5161
}
5262
}
5363

‎compose/runtime/runtime-test-utils/build.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ androidXMultiplatform {
2727
}
2828
jvmStubs()
2929
linuxX64Stubs()
30+
wasmJs()
3031

3132
defaultPlatform(PlatformIdentifier.ANDROID)
3233

@@ -62,6 +63,12 @@ androidXMultiplatform {
6263
linuxx64StubsMain {
6364
dependsOn(commonStubsMain)
6465
}
66+
wasmJsMain {
67+
dependsOn(commonStubsMain)
68+
dependencies {
69+
implementation(libs.kotlinStdlibWasm)
70+
}
71+
}
6572
}
6673
}
6774

‎compose/runtime/runtime/build.gradle‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ androidXMultiplatform {
3535
androidTarget()
3636
jvmStubs(/* runTests */ true)
3737
linuxX64Stubs()
38+
wasmJs()
3839

3940
defaultPlatform(PlatformIdentifier.ANDROID)
4041

@@ -50,7 +51,9 @@ androidXMultiplatform {
5051

5152
commonTest {
5253
dependencies {
53-
implementation kotlin("test")
54+
// For KotlinWasm/Js, versions of toolchain and stdlib need to be the same (2.1):
55+
// https://youtrack.jetbrains.com/issue/KT-71032
56+
implementation(libs.kotlinTestForWasmTests)
5457
implementation(libs.kotlinCoroutinesTest)
5558
implementation(libs.kotlinReflect)
5659
implementation(project(":compose:runtime:runtime-test-utils"))
@@ -121,9 +124,32 @@ androidXMultiplatform {
121124
dependsOn(nonEmulatorJvmTest)
122125
}
123126

124-
linuxx64StubsMain {
127+
nonJvmMain {
125128
dependsOn(nonAndroidMain)
126129
}
130+
131+
linuxx64StubsMain {
132+
dependsOn(nonJvmMain)
133+
}
134+
135+
webMain {
136+
dependsOn(nonJvmMain)
137+
}
138+
139+
wasmJsMain {
140+
dependsOn(webMain)
141+
dependencies {
142+
implementation("org.jetbrains.kotlinx:kotlinx-browser:0.1")
143+
}
144+
}
145+
146+
webTest {
147+
dependsOn(nonEmulatorCommonTest)
148+
}
149+
150+
wasmJsTest {
151+
dependsOn(webTest)
152+
}
127153
}
128154
}
129155

‎compose/runtime/runtime/src/commonTest/kotlin/kotlinx/test/IgnoreJsTarget.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
*/
1616
package kotlinx.test
1717

18+
// TODO(b/409723535): Differentiate between WASM and JS targets.
1819
expect annotation class IgnoreJsTarget()

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/CompositionObserverTests.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ import androidx.compose.runtime.tooling.observe
2727
import kotlin.test.Test
2828
import kotlin.test.assertEquals
2929
import kotlin.test.assertTrue
30+
import kotlinx.test.IgnoreJsTarget
3031

3132
@Stable
3233
@OptIn(ExperimentalComposeRuntimeApi::class)
3334
@Suppress("unused")
3435
class CompositionObserverTests {
3536
@Test
37+
@IgnoreJsTarget // b/409727436
3638
fun observeScope() {
3739
var startCount = 0
3840
var endCount = 0
@@ -76,6 +78,7 @@ class CompositionObserverTests {
7678
}
7779

7880
@Test
81+
@IgnoreJsTarget // b/409727436
7982
fun observeScope_dispose() {
8083
var startCount = 0
8184
var endCount = 0
@@ -127,6 +130,7 @@ class CompositionObserverTests {
127130
}
128131

129132
@Test
133+
@IgnoreJsTarget // b/409727436
130134
fun observeScope_scopeRemoved() {
131135
var startCount = 0
132136
var endCount = 0

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/CompositionTests.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import kotlinx.coroutines.test.TestCoroutineScheduler
7272
import kotlinx.coroutines.test.TestScope
7373
import kotlinx.coroutines.test.runTest
7474
import kotlinx.coroutines.withContext
75+
import kotlinx.test.IgnoreJsTarget
7576

7677
@Composable fun Container(content: @Composable () -> Unit) = content()
7778

@@ -2565,6 +2566,7 @@ class CompositionTests {
25652566
}
25662567

25672568
@Test
2569+
@IgnoreJsTarget // b/409728274
25682570
fun testRememberObserver_Abandon_Recompose() {
25692571
val abandonedObjects = mutableListOf<RememberObserver>()
25702572
val observed =

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/MovableContentTests.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,6 @@ class MovableContentTests {
15461546

15471547
condition = true
15481548
expectChanges()
1549-
println("Done")
15501549
revalidate()
15511550
verifyConsistent()
15521551
}

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/PausableCompositionTests.kt‎

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import kotlin.coroutines.resume
2929
import kotlin.test.Ignore
3030
import kotlin.test.Test
3131
import kotlin.test.assertEquals
32+
import kotlin.test.assertFailsWith
3233
import kotlin.test.assertFalse
3334
import kotlin.test.assertTrue
3435
import kotlinx.coroutines.CancellableContinuation
@@ -424,36 +425,40 @@ class PausableCompositionTests {
424425
awaiter.await()
425426
}
426427

427-
@Test(expected = IllegalStateException::class)
428+
@Test
428429
fun pausableComposition_throwInResume() = runTest {
429-
val recomposer = Recomposer(coroutineContext)
430-
val pausableComposition = PausableComposition(EmptyApplier(), recomposer)
431-
432-
try {
433-
val handle = pausableComposition.setPausableContent { error("Test error") }
434-
handle.resume { false }
435-
handle.apply()
436-
} finally {
437-
recomposer.cancel()
438-
recomposer.close()
430+
assertFailsWith<IllegalStateException> {
431+
val recomposer = Recomposer(coroutineContext)
432+
val pausableComposition = PausableComposition(EmptyApplier(), recomposer)
433+
434+
try {
435+
val handle = pausableComposition.setPausableContent { error("Test error") }
436+
handle.resume { false }
437+
handle.apply()
438+
} finally {
439+
recomposer.cancel()
440+
recomposer.close()
441+
}
439442
}
440443
}
441444

442-
@Test(expected = IllegalStateException::class)
445+
@Test
443446
fun pausableComposition_throwInApply() = runTest {
444-
val recomposer = Recomposer(coroutineContext)
445-
val pausableComposition = PausableComposition(EmptyApplier(), recomposer)
446-
447-
try {
448-
val handle =
449-
pausableComposition.setPausableContent {
450-
DisposableEffect(Unit) { throw IllegalStateException("test") }
451-
}
452-
handle.resume { false }
453-
handle.apply()
454-
} finally {
455-
recomposer.cancel()
456-
recomposer.close()
447+
assertFailsWith<IllegalStateException> {
448+
val recomposer = Recomposer(coroutineContext)
449+
val pausableComposition = PausableComposition(EmptyApplier(), recomposer)
450+
451+
try {
452+
val handle =
453+
pausableComposition.setPausableContent {
454+
DisposableEffect(Unit) { throw IllegalStateException("test") }
455+
}
456+
handle.resume { false }
457+
handle.apply()
458+
} finally {
459+
recomposer.cancel()
460+
recomposer.close()
461+
}
457462
}
458463
}
459464
}

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/RecomposerTests.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher
4242
import kotlinx.coroutines.test.runTest
4343
import kotlinx.coroutines.withContext
4444
import kotlinx.coroutines.withTimeoutOrNull
45+
import kotlinx.test.IgnoreJsTarget
4546

4647
@OptIn(ExperimentalCoroutinesApi::class)
4748
class RecomposerTests {
@@ -359,6 +360,7 @@ class RecomposerTests {
359360
}
360361

361362
@Test
363+
@IgnoreJsTarget // b/409727145
362364
fun stateChangesDuringApplyChangesAreNotifiedBeforeFrameFinished() = compositionTest {
363365
val count = mutableStateOf(0)
364366
val countFromEffect = mutableStateOf(0)

‎compose/runtime/runtime/src/nonEmulatorCommonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotContextElementTests.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import kotlinx.coroutines.launch
2424
import kotlinx.coroutines.test.UnconfinedTestDispatcher
2525
import kotlinx.coroutines.test.runTest
2626
import kotlinx.coroutines.withContext
27+
import kotlinx.test.IgnoreJsTarget
2728

2829
@OptIn(ExperimentalCoroutinesApi::class)
2930
class SnapshotContextElementTests {
3031
@Test
32+
@IgnoreJsTarget // b/409725929
3133
fun coroutineEntersExpectedSnapshot() =
3234
runTest(UnconfinedTestDispatcher()) {
3335
val snapshot = Snapshot.takeSnapshot()

0 commit comments

Comments
 (0)