From cf9a60c427d4a9afedea7a32d02ad2e9b84cd2d7 Mon Sep 17 00:00:00 2001 From: David Hontiveros Gordo Date: Tue, 25 Nov 2025 12:16:28 +0100 Subject: [PATCH 1/2] ANDROID-17148/fix-double-extension: Remove ".txt" extra extension when log file is creating --- .../java/com/telefonica/androidsnaptesting/logs/LogsRule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt index b3484f1..dfc8596 100644 --- a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt +++ b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt @@ -45,7 +45,7 @@ public open class GenericLogsRule( val isTestIgnored = description?.getAnnotation(IgnoreLogs::class.java) != null val testName = "${description?.className}_${description?.methodName}" - val fileName = "${testName}.txt.${System.nanoTime()}" + val fileName = "${testName}.${System.nanoTime()}" val recordedLogs: List From d04af03353ce008ee110de4b577cd3e3c1e05318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Wed, 26 Nov 2025 08:49:02 +0100 Subject: [PATCH 2/2] Fix issues after moving loggerazzi fixes --- .../com/telefonica/androidsnaptesting/logs/LogsRule.kt | 10 +++++----- .../androidsnaptesting/AndroidSnaptestingPlugin.kt | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt index dfc8596..62ed083 100644 --- a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt +++ b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/logs/LogsRule.kt @@ -45,25 +45,25 @@ public open class GenericLogsRule( val isTestIgnored = description?.getAnnotation(IgnoreLogs::class.java) != null val testName = "${description?.className}_${description?.methodName}" - val fileName = "${testName}.${System.nanoTime()}" - - val recordedLogs: List + val fileName = "${testName}.txt.${System.nanoTime()}" if (InstrumentationRegistry.getArguments().getString("record") != "true" && !isTestIgnored) { val goldenFile = directories.context.assets.open("${directories.goldenFilesDir}/${testName}.txt") val goldenStringLogs = String(goldenFile.readBytes()).takeIf { it.isNotEmpty() }?.split("\n") ?: emptyList() val comparison = compare(goldenStringLogs) + writeRecordedLogsToFile(fileName, comparison.recordedLogs) if (!comparison.success) { val compareFile = File(directories.failuresDir, fileName) compareFile.createNewFile() compareFile.writeText(comparison.failure!!) throw AssertionError("Logs do not match:\n${comparison.failure}") } - recordedLogs = comparison.recordedLogs } else { - recordedLogs = recorder.getRecordedLogs() + writeRecordedLogsToFile(fileName, recorder.getRecordedLogs()) } + } + private fun writeRecordedLogsToFile(fileName: String, recordedLogs: List) { val log = recordedLogs.joinToString("\n") { stringMapper.fromLog(it) } val testFile = File(directories.recordedDir, fileName) testFile.createNewFile() diff --git a/include-build/gradle-plugin/src/main/java/com/telefonica/androidsnaptesting/AndroidSnaptestingPlugin.kt b/include-build/gradle-plugin/src/main/java/com/telefonica/androidsnaptesting/AndroidSnaptestingPlugin.kt index 3daf1da..59a8dd9 100644 --- a/include-build/gradle-plugin/src/main/java/com/telefonica/androidsnaptesting/AndroidSnaptestingPlugin.kt +++ b/include-build/gradle-plugin/src/main/java/com/telefonica/androidsnaptesting/AndroidSnaptestingPlugin.kt @@ -149,10 +149,10 @@ class AndroidSnaptestingPlugin @Inject constructor( } if (lastRecordedFile != null) { lastRecordedFile - .renameTo(File(recordedDir, "$key.txt")) + .renameTo(File(recordedDir, key)) File(failuresDir, lastRecordedFile.name) .takeIf { it.exists() } - ?.renameTo(File(failuresDir, "$key.txt")) + ?.renameTo(File(failuresDir, key)) } } }