From 0dc38e5d871a54cc6a9ef47dc4d680664071831b Mon Sep 17 00:00:00 2001 From: Alan Leung Date: Tue, 23 Apr 2024 13:40:46 -0700 Subject: LE: Add test for fixing recoverable errors Fixes: 336605368 Test: This adds more testing Change-Id: I10af362b65624994e841e6698b721e07b428b246 --- .../run/deployment/liveedit/BasicCompileTest.kt | 23 +++++++++++++++++++--- 1 file 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 -- cgit v1.2.3