Search in sources :

Example 21 with Message

use of com.android.ide.common.blame.Message in project android by JetBrains.

the class BuildOutputParserTest method redirectFileLinksOutput.

@Test
public void redirectFileLinksOutput() throws Exception {
    // Do not run tests on Windows (see http://b.android.com/222904)
    assumeFalse(SystemInfo.isWindows);
    // Need file to be named (exactly) values.xml
    File tempDir = Files.createTempDir();
    File layoutDir = new File(tempDir, "layout-land");
    layoutDir.mkdirs();
    sourceFile = new File(layoutDir, "main.xml");
    sourceFilePath = sourceFile.getAbsolutePath();
    writeToFile("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    android:orientation=\"vertical\"\n" + "    android:layout_width=\"fill_parent\"\n" + "    android:layout_height=\"fill_parent\"\n" + "    >\n" + "<TextView\n" + "    android:layout_width=\"fill_parent\"\n" + "    android:layout_height=\"wrap_content\"\n" + "    android:text=\"Test App - Basic\"\n" + "    android:id=\"@+id/text\"\n" + "    />\n" + "</LinearLayout>\n" + "\n" + "<!-- From: file:src/test/resources/testData/resources/incMergeData/filesVsValues/main/layout/main.xml -->");
    String messageText = "Random error message here";
    String err = sourceFilePath + ":4: error: Error: " + messageText;
    Collection<Message> messages = parser.parseGradleOutput(err);
    assertEquals(1, messages.size());
    assertEquals("[message count]", 1, messages.size());
    Message message = ContainerUtil.getFirstItem(messages);
    assertNotNull(message);
    // NOT sourceFilePath; should be translated back from source comment
    String expected = "src/test/resources/testData/resources/incMergeData/filesVsValues/main/layout/main.xml";
    assertEquals("[file path]", expected, getSystemIndependentSourcePath(message));
    assertEquals("[message severity]", Message.Kind.ERROR, message.getKind());
    assertEquals("[message text]", messageText, message.getText());
    assertEquals("[position line]", 4, message.getLineNumber());
//assertEquals("[position column]", 35, message.getColumn());
// TODO: Test encoding issues (e.g. & in path where the XML source comment would be &amp; instead)
}
Also used : Message(com.android.ide.common.blame.Message) File(java.io.File) Test(org.junit.Test)

Example 22 with Message

use of com.android.ide.common.blame.Message in project android by JetBrains.

the class BuildOutputParserTest method parseDisplayingUnhandledMessages.

@Test
public void parseDisplayingUnhandledMessages() {
    String output = " **--- HELLO WORLD ---**";
    List<Message> Messages = parser.parseGradleOutput(output);
    assertEquals(1, Messages.size());
    Message message = Messages.get(0);
    assertEquals(output, message.getText());
    assertEquals(Message.Kind.SIMPLE, message.getKind());
}
Also used : Message(com.android.ide.common.blame.Message) Test(org.junit.Test)

Aggregations

Message (com.android.ide.common.blame.Message)22 SourceFilePosition (com.android.ide.common.blame.SourceFilePosition)11 SourcePosition (com.android.ide.common.blame.SourcePosition)9 File (java.io.File)8 Test (org.junit.Test)7 SourceFile (com.android.ide.common.blame.SourceFile)4 Matcher (java.util.regex.Matcher)4 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)3 SyncMessageSubject.syncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessageSubject.syncMessage)2 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)2 NotificationData (com.intellij.openapi.externalSystem.service.notification.NotificationData)2 Module (com.intellij.openapi.module.Module)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ParsingFailedException (com.android.ide.common.blame.parser.ParsingFailedException)1 PatternAwareOutputParser (com.android.ide.common.blame.parser.PatternAwareOutputParser)1 BuildOutputParser (com.android.tools.idea.gradle.output.parser.BuildOutputParser)1 SyncErrorHandler (com.android.tools.idea.gradle.project.sync.errors.SyncErrorHandler)1 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)1 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1