]> source.dussan.org Git - sonarqube.git/commitdiff
Fix parsing of maven logs in performance tests 5.5-M2
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 17 Feb 2016 14:21:51 +0000 (15:21 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 17 Feb 2016 14:22:01 +0000 (15:22 +0100)
tests/perf/src/main/java/org/sonarsource/sonarqube/perf/MavenLogs.java
tests/perf/src/test/java/org/sonarsource/sonarqube/perf/scanner/MavenLogsTest.java

index 90960996b8cbd3438e31b60890f8016769645e49..69f0289f44050345d73d4ce170f043c75931ed42 100644 (file)
@@ -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\"");
   }
 
   /**
index 22f945b98f69f008610a847127f6df0483cf49dc..434c02510bfb806a567f3bd84daaa36a715be979 100644 (file)
@@ -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