summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Leung <acleung@google.com>2024-04-23 13:40:46 -0700
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-29 22:40:34 +0000
commit0dc38e5d871a54cc6a9ef47dc4d680664071831b (patch)
treeb414ac13b30d1b1330a7e731e1933fff7c891c6f
parentd3cfdaaf851be023fb4406d6a8754a3ecd2241f7 (diff)
downloadidea-0dc38e5d871a54cc6a9ef47dc4d680664071831b.tar.gz
LE: Add test for fixing recoverable errors
Fixes: 336605368 Test: This adds more testing Change-Id: I10af362b65624994e841e6698b721e07b428b246
-rw-r--r--android/run/testSrc/com/android/tools/idea/run/deployment/liveedit/BasicCompileTest.kt23
1 files changed, 20 insertions, 3 deletions
diff --git a/android/run/testSrc/com/android/tools/idea/run/deployment/liveedit/BasicCompileTest.kt b/android/run/testSrc/com/android/tools/idea/run/deployment/liveedit/BasicCompileTest.kt
index 197af85db68..32e28d2029b 100644
--- a/android/run/testSrc/com/android/tools/idea/run/deployment/liveedit/BasicCompileTest.kt
+++ b/android/run/testSrc/com/android/tools/idea/run/deployment/liveedit/BasicCompileTest.kt
@@ -92,15 +92,32 @@ class BasicCompileTest {
@Test
fun recoverableErrors() {
- try {
- val file = projectRule.createKtFile("RecoverableError.kt", """
+ // Step 1: Error Free
+ val file = projectRule.createKtFile("RecoverableError.kt", """
+ fun recoverableError() { "a".toString() }
+ """)
+
+ val cache = projectRule.initialCache(listOf(file))
+
+ // Step 2: Introduce recoverable syntax errors
+ projectRule.modifyKtFile(file, """
fun recoverableError() { "a".toString() } }
""")
- compile(file)
+
+ try {
+ compile(file, cache)
Assert.fail("RecoverableError.kt contains a lexical error and should not be updated by Live Edit")
} catch (e: LiveEditUpdateException) {
Assert.assertEquals("Expecting a top level declaration", e.message)
}
+
+ // Step 3: Fix syntax error
+ projectRule.modifyKtFile(file, """
+ fun recoverableError() { "a".toString() }
+ """)
+
+ // Should not have compiler errors.
+ compile(file, cache)
}
@Test