@Test
public void parseGradleBuildFileOutput() throws IOException {

  createTempFile(".gradle");
  writeToFile("buildscript {",
              "    repositories {",
              "        mavenCentral()",
              "    }",
              "    dependencies {",
              "        classpath 'com.android.tools.build:gradle:0.4'",
              "    }",
              "}",
              "ERROR plugin: 'android'");
  StringBuilder err = new StringBuilder();
  err.append("FAILURE: Build failed with an exception.").append(NEWLINE).append(NEWLINE);
  err.append("* Where:").append(NEWLINE);
  err.append("Build file '").append(sourceFilePath).append("' line: 9").append(NEWLINE).append(NEWLINE);
  err.append("* What went wrong:").append(NEWLINE);
  err.append("A problem occurred evaluating project ':project'.").append(NEWLINE);
  err.append("> Could not find method ERROR() for arguments [{plugin=android}] on project ':project'.").append(NEWLINE).append(NEWLINE);
  err.append("* Try:").append(NEWLINE);
  err.append("Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.").append(
    NEWLINE).append(NEWLINE);
  err.append("BUILD FAILED").append(NEWLINE).append(NEWLINE);
  err.append("Total time: 18.303 secs\n");
  List<Message> messages = parser.parseGradleOutput(err.toString());
  assertEquals("0: Error:A problem occurred evaluating project ':project'.\n" +
               "> Could not find method ERROR() for arguments [{plugin=android}] on project ':project'.\n" +
               "\t" + sourceFilePath + ":9:1\n" +
               "1: Info:BUILD FAILED\n" +
               "2: Info:Total time: 18.303 secs\n",
               toString(messages));
}