Skip to content

Commit

Permalink
Add some Markdown escaping for flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Sep 6, 2024
1 parent 0dacd64 commit 52fb0ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,14 @@ public static String escapeHtml(String html) {

return html.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
}

/**
* Again very naive but should catch most issues.
*/
public static String escapeMarkdown(String markdown) {
return markdown.replace("#", "\\#")
.replace("*", "\\*")
.replace("`", "\\`");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<p>✖ <code>{flakyTest.fullName.escapeHtml}</code>{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={flakyTest.fullClassName}&tests.test={flakyTest.name}">History</a>{/if}</p>

{#for flake : flakyTest.flakes}
- `{flake.message}`{#if flake.type} - `{flake.type}`{/if}
- `{flake.message.escapeMarkdown}`{#if flake.type} - `{flake.type.escapeMarkdown}`{/if}

{#if flake.abbreviatedStackTrace.trim && includeStackTraces}
<details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ It should be safe to merge provided you have a look at the other checks in the s
<p>✖ <code>{flakyTest.fullName.escapeHtml}</code>{#if develocityEnabled && develocityUrl} - <a href="{develocityUrl}scans/tests?tests.container={flakyTest.fullClassName}&tests.test={flakyTest.name}">History</a>{/if}</p>

{#for flake : flakyTest.flakes}
- `{flake.message}`{#if flake.type} - `{flake.type}`{/if}
- `{flake.message.escapeMarkdown}`{#if flake.type} - `{flake.type.escapeMarkdown}`{/if}

{#if flake.abbreviatedStackTrace.trim && includeStackTraces}
<details>
Expand Down

0 comments on commit 52fb0ff

Please sign in to comment.