Store artifacts zip with the "<type>-testName-datetime" name

GitOrigin-RevId: cfb8b2db9a084c8961fa52c996aef44a4ca2b567
This commit is contained in:
Maxim.Kolmakov
2022-05-31 15:03:27 +00:00
committed by intellij-monorepo-bot
parent d6a53fa1fb
commit 13dff8d4e9
2 changed files with 9 additions and 2 deletions
@@ -275,10 +275,10 @@ data class IDERunContext(
ErrorReporter.reportErrorsAsFailedTests(logsDir / "script-errors", contextName)
val (artifactPath, artifactName) = if (successfulRun) contextName to "logs" else "run/$contextName" to "crash"
testContext.publishArtifact(logsDir, artifactPath, artifactName)
testContext.publishArtifact(logsDir, artifactPath, formatArtifactName(artifactName, testContext.testName))
val snapshotFiles = Files.list(testContext.paths.snapshotsDir).use { it.filter { it.isRegularFile() }.toList() }
if (snapshotFiles.isNotEmpty()) {
testContext.publishArtifact(testContext.paths.snapshotsDir, contextName, "snapshots")
testContext.publishArtifact(testContext.paths.snapshotsDir, contextName, formatArtifactName("snapshots", testContext.testName))
}
if (codeBuilder != null) {
host.tearDown(testContext)
@@ -13,9 +13,16 @@ import java.nio.charset.Charset
import java.nio.file.FileStore
import java.nio.file.Files
import java.nio.file.Path
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.io.path.*
import kotlin.time.Duration
fun formatArtifactName(artifactType: String, testName: String): String{
val testNameFormatted = testName.replace("/", "-").replace(" ", "")
val time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
return "$artifactType-$testNameFormatted-$time"
}
fun getThrowableText(t: Throwable): String {
val writer = StringWriter()