Skip to content

Commit 3d73144

Browse files
authored
Fix test to allow Git origin URLs starting with git@ (#4152)
This occurred when using the SSH option to clone the repository.
1 parent c96feb2 commit 3d73144

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

platform-tests/src/test/java/org/junit/platform/reporting/open/xml/OpenTestReportGeneratingListenerTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.net.URISyntaxException;
2525
import java.nio.file.Files;
2626
import java.nio.file.Path;
27+
import java.util.regex.Pattern;
2728

2829
import org.junit.jupiter.api.Test;
2930
import org.junit.jupiter.api.io.TempDir;
@@ -75,9 +76,9 @@ void writesValidXmlReport() throws Exception {
7576
<java:javaVersion>${xmlunit.ignore}</java:javaVersion>
7677
<java:fileEncoding>${xmlunit.ignore}</java:fileEncoding>
7778
<java:heapSize max="${xmlunit.isNumber}"/>
78-
<git:repository originUrl="${xmlunit.matchesRegex(https://.+)}"/>
79+
<git:repository originUrl="${xmlunit.matchesRegex#(git@|https://).+#}"/>
7980
<git:branch>${xmlunit.ignore}</git:branch>
80-
<git:commit>${xmlunit.matchesRegex([0-9a-f]{40})}</git:commit>
81+
<git:commit>${xmlunit.matchesRegex#[0-9a-f]{40}#}</git:commit>
8182
<git:status clean="${xmlunit.ignore}">${xmlunit.ignore}</git:status>
8283
</infrastructure>
8384
<e:started id="1" name="dummy" time="${xmlunit.isDateTime}">
@@ -104,7 +105,7 @@ void writesValidXmlReport() throws Exception {
104105
<e:finished id="2" time="${xmlunit.isDateTime}">
105106
<result status="FAILED">
106107
<java:throwable assertionError="true" type="org.opentest4j.AssertionFailedError">
107-
${xmlunit.matchesRegex(org\\.opentest4j\\.AssertionFailedError: failure message)}
108+
${xmlunit.matchesRegex#org\\.opentest4j\\.AssertionFailedError: failure message#}
108109
</java:throwable>
109110
</result>
110111
</e:finished>
@@ -115,7 +116,8 @@ void writesValidXmlReport() throws Exception {
115116
""";
116117

117118
XmlAssert.assertThat(xmlFile).and(expected) //
118-
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator()) //
119+
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator(Pattern.quote("${"), Pattern.quote("}"),
120+
Pattern.quote("#"), Pattern.quote("#"), ",")) //
119121
.ignoreWhitespace() //
120122
.areIdentical();
121123
}

platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/XmlAssertions.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.UncheckedIOException;
1515
import java.nio.file.Files;
1616
import java.nio.file.Path;
17+
import java.util.regex.Pattern;
1718

1819
import org.xmlunit.assertj3.XmlAssert;
1920
import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator;
@@ -46,9 +47,9 @@ private static void verifyContent(Path xmlFile) {
4647
<java:javaVersion>${xmlunit.ignore}</java:javaVersion>
4748
<java:fileEncoding>${xmlunit.ignore}</java:fileEncoding>
4849
<java:heapSize max="${xmlunit.isNumber}"/>
49-
<git:repository originUrl="${xmlunit.matchesRegex(https://.+)}"/>
50+
<git:repository originUrl="${xmlunit.matchesRegex#(git@|https://).+#}"/>
5051
<git:branch>${xmlunit.ignore}</git:branch>
51-
<git:commit>${xmlunit.matchesRegex([0-9a-f]{40})}</git:commit>
52+
<git:commit>${xmlunit.matchesRegex#[0-9a-f]{40}#}</git:commit>
5253
<git:status clean="${xmlunit.ignore}">${xmlunit.ignore}</git:status>
5354
</infrastructure>
5455
<e:started id="1" name="JUnit Jupiter" time="${xmlunit.isDateTime}">
@@ -156,7 +157,8 @@ private static void verifyContent(Path xmlFile) {
156157
""";
157158

158159
XmlAssert.assertThat(xmlFile).and(expected) //
159-
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator()) //
160+
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator(Pattern.quote("${"), Pattern.quote("}"),
161+
Pattern.quote("#"), Pattern.quote("#"), ",")) //
160162
.ignoreWhitespace() //
161163
.areIdentical();
162164
}

0 commit comments

Comments
 (0)