Fix commitish detection in LanguageSnippetTest to also cover release versions (#537)

This commit is contained in:
Philip K.F. Hölzenspies
2024-06-17 18:21:22 +01:00
committed by GitHub
parent 600939457a
commit d55866a04b

View File

@@ -91,8 +91,16 @@ abstract class AbstractLanguageSnippetTestsEngine : InputOutputTestEngine() {
protected fun String.stripVersionCheckErrorMessage() =
replace("Pkl version is ${Release.current().version()}", "Pkl version is xxx")
protected fun String.stripStdlibLocationSha(): String =
replace("https://github.com/apple/pkl/blob/${Release.current().commitId()}/stdlib/", "https://github.com/apple/pkl/blob/\$commitId/stdlib/")
protected fun String.stripStdlibLocationSha(): String {
// Logic must be kept in-sync with `doc-package-info.pkl`.
val commitIsh =
if (Release.current().version().isNormal) Release.current().version()
else Release.current().commitId()
return replace(
"https://github.com/apple/pkl/blob/${commitIsh}/stdlib/",
"https://github.com/apple/pkl/blob/\$commitId/stdlib/"
)
}
protected fun String.withUnixLineEndings(): String {
return if (System.lineSeparator() == "\r\n") replace("\r\n", "\n")