/**
   * Checks if a file from error output can be found.
   *
   * @throws Exception...
   */
  public void testEfsProjectPushPopDirectory() throws Exception {
    String fileName = "testEfsProjectPushPopDirectory.c";

    IProject efsProject =
        ResourceHelper.createCDTProject("EfsProject", new URI("mem:/ProjectPushPopDirectory"));
    ResourceHelper.createFolder(efsProject, "Folder");
    ResourceHelper.createFolder(efsProject, "Folder/SubFolder");
    ResourceHelper.createFile(efsProject, fileName);
    ResourceHelper.createFile(efsProject, "Folder/" + fileName);
    ResourceHelper.createFile(efsProject, "Folder/SubFolder/" + fileName);

    String lines =
        "make[1]: Entering directory `Folder'\n"
            + "make[2]: Entering directory `SubFolder'\n"
            + "make[2]: Leaving directory `SubFolder'\n"
            + fileName
            + ":1:error\n";

    String[] errorParsers = {MAKE_ERRORPARSER_ID, mockErrorParserId};
    parseOutput(efsProject, efsProject.getLocation(), errorParsers, lines);
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals("L/EfsProject/Folder/" + fileName, problemMarkerInfo.file.toString());
    assertEquals(1, problemMarkerInfo.lineNumber);
    assertEquals("error", problemMarkerInfo.description);
  }
  /**
   * Checks if a file from error output can be found.
   *
   * @throws Exception...
   */
  public void testEfsProjectBuildDirURI() throws Exception {
    String fileName = "testEfsProjectBuildDirURI.c";

    IProject efsProject = ResourceHelper.createCDTProject("EfsProject", new URI("mem:/EfsProject"));
    ResourceHelper.createFolder(efsProject, "Folder");
    ResourceHelper.createFile(efsProject, "Folder/" + fileName);
    ResourceHelper.createFolder(efsProject, "BuildDir");
    ResourceHelper.createFile(efsProject, "BuildDir/" + fileName);

    URI buildDirURI = new URI("mem:/EfsProject/BuildDir/");
    parseOutput(efsProject, buildDirURI, new String[] {mockErrorParserId}, fileName + ":1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals("L/EfsProject/BuildDir/" + fileName, problemMarkerInfo.file.toString());
    assertEquals("error", problemMarkerInfo.description);
  }
  /**
   * Checks if a file from error output can be found.
   *
   * @throws Exception...
   */
  public void testEfsVsRegular() throws Exception {
    ResourceHelper.createFile(fProject, "testEfsVsRegular.c");
    ResourceHelper.createEfsFile(fProject, "efsTestEfsVsRegular.c", "null:/testEfsVsRegular.c");

    parseOutput("testEfsVsRegular.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals(
        "L/FindMatchingFilesEfsTest/testEfsVsRegular.c", problemMarkerInfo.file.toString());
    assertEquals("error", problemMarkerInfo.description);
  }
  /**
   * Checks if a file from error output can be found.
   *
   * @throws Exception...
   */
  public void testEfsProject() throws Exception {
    IFile efsSmokeTest =
        ResourceHelper.createEfsFile(fProject, "efsSmokeTest.c", "mem:/efsSmokeTest.c");
    Assert.assertTrue(efsSmokeTest.exists());

    IProject efsProject = ResourceHelper.createCDTProject("EfsProject", new URI("mem:/EfsProject"));
    ResourceHelper.createFolder(efsProject, "Folder");
    ResourceHelper.createFile(efsProject, "Folder/testEfsProject.c");

    parseOutput(efsProject, "testEfsProject.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals("L/EfsProject/Folder/testEfsProject.c", problemMarkerInfo.file.toString());
    assertEquals("error", problemMarkerInfo.description);
  }
Esempio n. 5
0
  /**
   * Check how RegexErrorParser parses output.
   *
   * @throws Exception...
   */
  public void testRegexErrorParserParseOutput() throws Exception {
    RegexErrorParser regexErrorParser = new RegexErrorParser();
    regexErrorParser.addPattern(
        new RegexErrorPattern(
            "(.*)#(.*)#(.*)#(.*)",
            "$1",
            "$2",
            "$3 $4",
            "var=$4",
            IMarkerGenerator.SEVERITY_ERROR_RESOURCE,
            true));
    regexErrorParser.addPattern(
        new RegexErrorPattern(
            "(.*)!(skip me)!(.*)!(.*)",
            null,
            null,
            null,
            null,
            RegexErrorPattern.SEVERITY_SKIP,
            true));
    regexErrorParser.addPattern(
        new RegexErrorPattern(
            "(.*)!(Description)!(.*)!(.*)",
            "$4",
            "$3",
            "$2",
            "$1",
            IMarkerGenerator.SEVERITY_WARNING, /*eat-line*/
            false));
    // broken pattern
    regexErrorParser.addPattern(
        new RegexErrorPattern(
            "(.*)!(.*)", "$6", "$7", "$8", "$9", IMarkerGenerator.SEVERITY_WARNING, true));
    regexErrorParser.addPattern(
        new RegexErrorPattern(
            "(.*)!(.*)!(.*)!(.*)", null, null, null, null, IMarkerGenerator.SEVERITY_INFO, true));

    String fileName = "RegexErrorParser.c";
    ResourceHelper.createFile(fProject, fileName);

    errorList.clear();
    ErrorParserManager epManager = new ErrorParserManager(fProject, markerGenerator, new String[0]);

    ProblemMarkerInfo problemMarkerInfo;

    // Regular pattern
    regexErrorParser.processLine(fileName + "#10#Description#Variable", epManager);
    // This should get ignored
    regexErrorParser.processLine("Variable!skip me!10!" + fileName, epManager);
    // Eat-line=false + qualifying next pattern (nulls), i.e. generates 2 problems
    regexErrorParser.processLine("Variable!Description!10!" + fileName, epManager);

    assertEquals(3, errorList.size());

    // Regular
    problemMarkerInfo = errorList.get(0);
    assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, problemMarkerInfo.severity);
    assertEquals("L/" + TEST_PROJECT_NAME + "/" + fileName, problemMarkerInfo.file.toString());
    assertEquals(fileName, problemMarkerInfo.file.getName());
    assertEquals(10, problemMarkerInfo.lineNumber);
    assertEquals("Description Variable", problemMarkerInfo.description);
    assertEquals("var=Variable", problemMarkerInfo.variableName);

    // Eat-line
    problemMarkerInfo = errorList.get(1);
    assertEquals(IMarkerGenerator.SEVERITY_WARNING, problemMarkerInfo.severity);
    assertEquals("L/" + TEST_PROJECT_NAME + "/" + fileName, problemMarkerInfo.file.toString());
    assertEquals(fileName, problemMarkerInfo.file.getName());
    assertEquals(10, problemMarkerInfo.lineNumber);
    assertEquals("Description", problemMarkerInfo.description);
    assertEquals("Variable", problemMarkerInfo.variableName);

    // Nulls
    problemMarkerInfo = errorList.get(2);
    assertEquals(IMarkerGenerator.SEVERITY_INFO, problemMarkerInfo.severity);
    assertEquals("P/" + TEST_PROJECT_NAME, problemMarkerInfo.file.toString());
    assertEquals(0, problemMarkerInfo.lineNumber);
    assertEquals("", problemMarkerInfo.description);
    assertEquals("", problemMarkerInfo.variableName);

    // clone & equals
    RegexErrorParser cloned = (RegexErrorParser) regexErrorParser.clone();
    assertTrue(cloned != regexErrorParser);
    assertEquals(regexErrorParser, cloned);
    assertTrue(cloned.getPatterns() != regexErrorParser.getPatterns());
    assertEquals(cloned.getPatterns().length, regexErrorParser.getPatterns().length);
    for (int i = 0; i < regexErrorParser.getPatterns().length; i++) {
      // Checking deep copy
      assertTrue(cloned.getPatterns()[i] != regexErrorParser.getPatterns()[i]);
      assertEquals(cloned.getPatterns()[i], regexErrorParser.getPatterns()[i]);
    }
  }