Skip to content

Commit f3fae1a

Browse files
emrzvintellij-monorepo-bot
authored andcommitted
[starter] Move FailureDetailsExtended Starter/FailureDetailsForTeamcity to make getFailureDetailsForCI() work externally
(cherry picked from commit 83afb3e14a9bd9a1cfc5f564fe2c6ef1e8bdee24) IJ-CR-146304 GitOrigin-RevId: 58dba8fd4bee0b059c42276f93a141cc52bd9bc6
1 parent e5f158b commit f3fae1a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.intellij.ide.starter.report
2+
3+
import com.intellij.ide.starter.ci.CIServer
4+
import com.intellij.ide.starter.ci.teamcity.asTeamCity
5+
import com.intellij.ide.starter.report.FailureDetailsOnCI.Companion.getTestMethodName
6+
import com.intellij.ide.starter.runner.IDERunContext
7+
import com.intellij.ide.starter.utils.replaceSpecialCharactersWithHyphens
8+
import com.intellij.openapi.vfs.CharsetToolkit
9+
import java.net.URI
10+
import java.net.URLEncoder
11+
12+
object FailureDetailsForTeamcity : FailureDetailsOnCI {
13+
override fun getFailureDetails(runContext: IDERunContext): String {
14+
15+
return if (CIServer.instance.isBuildRunningOnCI)
16+
getFailureDetailsForCI(runContext)
17+
else getFailureDetailsForLocalRun(runContext)
18+
}
19+
20+
private fun getFailureDetailsForCI(runContext: IDERunContext): String {
21+
val testMethodName = getTestMethodName().ifEmpty { runContext.contextName }
22+
val uri = getLinkToCIArtifacts(runContext)
23+
return "Test: $testMethodName" + System.lineSeparator() +
24+
"You can find logs and other info in CI artifacts under the path ${runContext.contextName}" + System.lineSeparator() +
25+
"Link on TC artifacts $uri"
26+
}
27+
28+
override fun getLinkToCIArtifacts(runContext: IDERunContext): String {
29+
val teamCityCI = CIServer.instance.asTeamCity()
30+
val urlString = "${teamCityCI.serverUri}/buildConfiguration/${teamCityCI.buildTypeId}/${teamCityCI.buildId}" +
31+
"?buildTab=artifacts#${URLEncoder.encode("/" + runContext.contextName.replaceSpecialCharactersWithHyphens(), CharsetToolkit.UTF8)}"
32+
return URI(urlString).normalize().toString()
33+
}
34+
35+
private fun getFailureDetailsForLocalRun(runContext: IDERunContext): String {
36+
val testMethodName = getTestMethodName().ifEmpty { runContext.contextName }
37+
38+
return "Test: $testMethodName" + System.lineSeparator() +
39+
"You can find logs and other info under the path ${runContext.logsDir.toRealPath()}"
40+
}
41+
}

intellij.tools.plugin.checker.tests/testSrc/com/intellij/tools/plugin/checker/di/diContainer.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import com.intellij.ide.starter.ide.IdeProductProvider
99
import com.intellij.ide.starter.models.IdeProduct
1010
import com.intellij.ide.starter.models.IdeProductImp
1111
import com.intellij.ide.starter.report.ErrorReporter
12+
import com.intellij.ide.starter.report.FailureDetailsForTeamcity
13+
import com.intellij.ide.starter.report.FailureDetailsOnCI
1214
import com.intellij.ide.starter.runner.IDERunContext
1315
import com.intellij.tools.ide.util.common.logOutput
1416
import org.kodein.di.DI
@@ -38,6 +40,7 @@ fun initPluginCheckerDI(systemPropertiesFilePath: Path = Path(System.getenv("TEA
3840
}
3941
bindSingleton<IdeProduct>(overrides = true) { IdeProductImp }
4042
bindSingleton<IdeDownloader>(overrides = true) { IdeByLinkDownloader }
43+
bindSingleton<FailureDetailsOnCI>(overrides = true) { FailureDetailsForTeamcity }
4144
bindSingleton<IdeProductProvider> { IdeProductProvider }
4245
bindSingleton<URI>(tag = "teamcity.uri", overrides = true) { serverUri }
4346
}

0 commit comments

Comments
 (0)