@Test
public void gradleAaptErrorParser() throws IOException {

  createTempXmlFile();
  writeToFile("<resources xmlns:android='http://schemas.android.com/apk/res/android'>",
              "    <TextView\n" +
              "            android:layout_width=\"fill_parent\"\n" +
              "            android:layout_height=\"wrap_content\"\n" +
              "            android:text=\"@string/does_not_exist\"\n" +
              "            android:id=\"@+id/text\"\n" +
              "            />\n");
  final String messageText = "No resource found that matches the given name (at 'text' with value '@string/does_not_exist').";
  String err = "FAILURE: Build failed with an exception.\n" +
               "\n" +
               "* What went wrong:\n" +
               "Execution failed for task ':five:processDebugResources'.\n" +
               "> Failed to run command:\n" +
               "  \t/Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt package -f --no-crunch -I ...\n" +
               "  Error Code:\n" +
               "  \t1\n" +
               "  Output:\n" +
               "  \t" + sourceFilePath + ":5: error: Error: " + messageText + "\n" +
               "\n" +
               "\n" +
               "* Try:\n" +
               "Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\n" +
               "\n" +
               "BUILD FAILED\n";
  assertEquals("0: Error:Error while executing aapt command\n" +
               "1: Error:No resource found that matches the given name (at 'text' with value '@string/does_not_exist').\n" +
               "\t" + sourceFilePath + ":5:27\n" +
               "2: Error:Execution failed for task ':five:processDebugResources'.\n" +
               "3: Info:BUILD FAILED\n",
               toString(parser.parseGradleOutput(err)));
}