aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-17 15:21:51 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-17 15:22:01 +0100
commit1792451e5e318a0cfb2e0085115d4c68f8025828 (patch)
treed85533f58e819e827a51aab6f52c9a190dcbed37
parentbf27baa7ef13bef1a1296c1c09b845580e65be44 (diff)
downloadsonarqube-1792451e5e318a0cfb2e0085115d4c68f8025828.tar.gz
sonarqube-1792451e5e318a0cfb2e0085115d4c68f8025828.zip
Fix parsing of maven logs in performance tests5.5-M2
-rw-r--r--tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java4
-rw-r--r--tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java4
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java
index 90960996b8c..69f0289f440 100644
--- a/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java
+++ b/tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java
@@ -32,7 +32,7 @@ public class MavenLogs {
* Total time: 3:14.025s
*/
public static Long extractTotalTime(String logs) {
- Pattern pattern = Pattern.compile(".*Total time: (\\d*:)?(\\d+).(\\d+)s.*");
+ Pattern pattern = Pattern.compile("^.*Total time: (\\d*:)?(\\d+).(\\d+)s.*$", Pattern.DOTALL);
Matcher matcher = pattern.matcher(logs);
if (matcher.matches()) {
String minutes = StringUtils.defaultIfBlank(StringUtils.removeEnd(matcher.group(1), ":"), "0");
@@ -41,7 +41,7 @@ public class MavenLogs {
return (Long.parseLong(minutes) * 60000) + (Long.parseLong(seconds) * 1000) + Long.parseLong(millis);
}
- return null;
+ throw new IllegalStateException("Maven logs do not contain \"Total time\"");
}
/**
diff --git a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java
index 22f945b98f6..434c02510bf 100644
--- a/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java
+++ b/tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java
@@ -28,8 +28,8 @@ import static org.fest.assertions.Assertions.assertThat;
public class MavenLogsTest {
@Test
public void testExtractTotalTime() throws Exception {
- assertThat(MavenLogs.extractTotalTime(" Total time: 6.015s ")).isEqualTo(6015);
- assertThat(MavenLogs.extractTotalTime(" Total time: 3:14.025s ")).isEqualTo(194025);
+ assertThat(MavenLogs.extractTotalTime(" \n Total time: 6.015s \n ")).isEqualTo(6015);
+ assertThat(MavenLogs.extractTotalTime(" \n Total time: 3:14.025s\n ")).isEqualTo(194025);
}
@Test