@Test
public void duplicateResources() throws Exception {

  // To reproduce, create a source file with two duplicate string item definitions
  createTempXmlFile();
  String output =
    "Failed to parse " + sourceFilePath + "\n" +
    "java.io.IOException: Found item String/drawer_open more than one time\n" +
    "\tat com.android.ide.common.res2.ValueResourceParser2.checkDuplicate(ValueResourceParser2.java:249)\n" +
    "\tat com.android.ide.common.res2.ValueResourceParser2.parseFile(ValueResourceParser2.java:103)\n" +
    "\tat com.android.ide.common.res2.ResourceSet.createResourceFile(ResourceSet.java:273)\n" +
    "\tat com.android.ide.common.res2.ResourceSet.parseFolder(ResourceSet.java:248)\n" +
    // ...
    "\tat org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)\n" +
    "\tat org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)\n" +
    "\tat java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)\n" +
    "\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)\n" +
    "\tat java.lang.Thread.run(Thread.java:680)\n" +
    "\n" +
    "FAILURE: Build failed with an exception.\n" +
    "\n" +
    "* What went wrong:\n" +
    "Execution failed for task ':MyApp:mergeDebugResources'.\n" +
    "> Found item String/drawer_open more than one time\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";
  assertEquals("0: Error:Found item String/drawer_open more than one time: Failed to parse " + sourceFilePath + "\n" +
               "\t" + sourceFilePath + ":-1:-1\n" +
               "1: Error:Execution failed for task ':MyApp:mergeDebugResources'.\n" +
               "> Found item String/drawer_open more than one time\n",
               toString(parser.parseGradleOutput(output)));
  // Also test CRLF handling:
  output = output.replace("\n", "\r\n");
  assertEquals("0: Error:Found item String/drawer_open more than one time: Failed to parse " + sourceFilePath + "\n" +
               "\t" + sourceFilePath + ":-1:-1\n" +
               "1: Error:Execution failed for task ':MyApp:mergeDebugResources'.\n" +
               "> Found item String/drawer_open more than one time\n",
               toString(parser.parseGradleOutput(output)));
}