Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ class LoggerazziPlugin @Inject constructor(
val recordedFolderFile = reportsFolder.dir("recorded").asFile.apply {
mkdirs()
deviceFileManager.pullRecordedLogs(absolutePath)
processAndFilterResults()
}
val failuresFolderFile = reportsFolder.dir("failures").asFile.apply {
mkdirs()
deviceFileManager.pullFailuresLogs(absolutePath)
processAndFilterResults()
}
filterRecordedAndFailureResults(recordedFolderFile, failuresFolderFile)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move all fixes applied to snaptesting on a PR in that repo.

val goldenForFailuresReportFolderFile = reportsFolder.dir("golden").asFile.apply {
mkdirs()
}
Expand Down Expand Up @@ -133,21 +132,28 @@ class LoggerazziPlugin @Inject constructor(
return replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
}

private fun File.processAndFilterResults() {
listFiles()
private fun filterRecordedAndFailureResults(recordedDir: File, failuresDir: File) {
recordedDir.listFiles()
?.groupBy {
it.name.substringBeforeLast(".")
}
?.forEach { (key, filesGroup) ->
val lastFile = filesGroup.maxByOrNull {
val lastRecordedFile = filesGroup.maxByOrNull {
it.name.substringAfterLast(".").toLong()
}
filesGroup.forEach { file ->
if (file != lastFile) {
if (file != lastRecordedFile) {
file.delete()
File(failuresDir, file.name).takeIf { it.exists() }?.delete()
}
}
lastFile?.renameTo(File(this, "$key.txt"))
if (lastRecordedFile != null) {
lastRecordedFile
.renameTo(File(recordedDir, "$key.txt"))
File(failuresDir, lastRecordedFile.name)
.takeIf { it.exists() }
?.renameTo(File(failuresDir, "$key.txt"))
}
}
}
}