Skip to content

Commit cbf9a48

Browse files
committed
Add a test case that verifies that \R is correctly detected now
1 parent 91b0aaa commit cbf9a48

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

plugin/src/main/java/io/jenkins/plugins/analysis/warnings/groovy/GroovyParser.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package io.jenkins.plugins.analysis.warnings.groovy;
22

3-
import java.io.Serializable;
4-
import java.util.Arrays;
5-
import java.util.Optional;
6-
import java.util.regex.Matcher;
7-
import java.util.regex.Pattern;
8-
import java.util.regex.PatternSyntaxException;
9-
103
import org.apache.commons.lang3.ObjectUtils;
114
import org.apache.commons.lang3.StringUtils;
125
import org.codehaus.groovy.control.CompilationFailedException;
@@ -20,6 +13,12 @@
2013
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2114

2215
import groovy.lang.Script;
16+
import java.io.Serializable;
17+
import java.util.Arrays;
18+
import java.util.Optional;
19+
import java.util.regex.Matcher;
20+
import java.util.regex.Pattern;
21+
import java.util.regex.PatternSyntaxException;
2322

2423
import org.kohsuke.stapler.AncestorInPath;
2524
import org.kohsuke.stapler.DataBoundConstructor;
@@ -38,7 +37,7 @@
3837
import io.jenkins.plugins.util.ValidationUtilities;
3938

4039
/**
41-
* Defines the properties of a warnings parser that uses a Groovy script to parse the warnings log.
40+
* Defines the properties of a warning parser that uses a Groovy script to parse the console log.
4241
*
4342
* @author Ullrich Hafner
4443
*/

plugin/src/test/java/io/jenkins/plugins/analysis/warnings/groovy/GroovyParserTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package io.jenkins.plugins.analysis.warnings.groovy;
22

3-
import java.io.IOException;
4-
import java.io.StringReader;
5-
63
import org.apache.commons.lang3.StringUtils;
74
import org.junit.jupiter.api.Test;
5+
import org.junit.jupiter.params.ParameterizedTest;
6+
import org.junit.jupiter.params.provider.ValueSource;
87
import org.junitpioneer.jupiter.Issue;
98

109
import edu.hm.hafner.analysis.IssueParser;
1110
import edu.hm.hafner.analysis.Report;
1211
import edu.hm.hafner.util.SerializableTest;
1312

13+
import java.io.IOException;
14+
import java.io.StringReader;
15+
1416
import hudson.model.Run;
1517

1618
import io.jenkins.plugins.analysis.core.util.ConsoleLogReaderFactory;
@@ -57,13 +59,11 @@ void shouldShortenExample() {
5759
*
5860
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-35262">Issue 35262</a>
5961
*/
60-
@Test
61-
void issue35262() throws IOException {
62-
matchMultiLine("(make(?:(?!make)[\\s\\S])*?make-error:.*(?:\\n|\\r\\n?))");
63-
matchMultiLine("(make(?:(?!make)[\\s\\S])*?make-error:.*(?:\\r?))");
64-
}
65-
66-
private void matchMultiLine(final String multiLineRegexp) throws IOException {
62+
@Issue("JENKINS-35262")
63+
@ParameterizedTest(name = "{index}: Regular expression should be multiline \"{0}\"")
64+
@ValueSource(strings = {"\\n|\\r\\n", "\\r", "\\R"})
65+
void issue35262(final String regexp) throws IOException {
66+
var multiLineRegexp = String.format("(make(?:(?!make)[\\s\\S])*?make-error:.*(?:%s?))", regexp);
6767
String textToMatch = toString("issue35262.log");
6868
String script = toString("issue35262.groovy");
6969

0 commit comments

Comments
 (0)