Skip to content
Snippets Groups Projects
Commit 9b8e2e95 authored by Florian Angerer's avatar Florian Angerer
Browse files

Fix: RError detector pattern was not accurate.

parent 0bdd0f1b
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ public class RErrorDetector extends LineDetector {
public static final RErrorDetector INSTANCE = new RErrorDetector();
private static final Pattern PATTERN = Pattern.compile("(.*\\s)?Error( in (?<CALLSTR>\\S*) )?: (?<MSG>.*)");
private static final Pattern PATTERN = Pattern.compile("(.*\\s)?Error( in (?<CALLSTR>[^:]*(\\(.*\\))?) )?: (?<MSG>.*)");
protected RErrorDetector() {
}
......
......@@ -163,6 +163,32 @@ public class RErrorDetectorTest {
Assert.assertEquals("invalid value for 'label'", findFirst.orElse(null).getDetails().trim());
}
@Test
public void testCallstringWithNamesAndValues0() {
List<String> lines = Arrays.asList(new String[]{"Error in grep(pattern, all.names, value = TRUE) : ",
" invalid regular expression '*': Dangling meta character '*' near index 0"});
Collection<Problem> detect = RErrorDetector.INSTANCE.detect(pkgTestRun, loc(), lines);
Assert.assertEquals(1, detect.size());
Optional<Problem> findFirst = detect.stream().findFirst();
Assert.assertEquals("Error in grep(pattern, all.names, value = TRUE)", findFirst.orElse(null).getSummary().trim());
Assert.assertEquals("invalid regular expression '*': Dangling meta character '*' near index 0", findFirst.orElse(null).getDetails().trim());
}
@Test
public void testCallstringWithNamesAndValues1() {
List<String> lines = Arrays.asList(new String[]{"Error in grep(pattern, all.names, value = \":\") : ",
" invalid regular expression '*': Dangling meta character '*' near index 0"});
Collection<Problem> detect = RErrorDetector.INSTANCE.detect(pkgTestRun, loc(), lines);
Assert.assertEquals(1, detect.size());
Optional<Problem> findFirst = detect.stream().findFirst();
Assert.assertEquals("Error in grep(pattern, all.names, value = \":\")", findFirst.orElse(null).getSummary().trim());
Assert.assertEquals("invalid regular expression '*': Dangling meta character '*' near index 0", findFirst.orElse(null).getDetails().trim());
}
private static Location loc() {
return new Location(pkg.getLocation(), 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment