/**
   * 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 testFullPath() throws Exception {
    ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
    ResourceHelper.createEfsFile(
        fProject, "Folder/testFullPath.c", "null:/EfsFolder/efsTestFullPath.c");

    parseOutput("EfsFolder/efsTestFullPath.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals(
        "L/FindMatchingFilesEfsTest/Folder/testFullPath.c", problemMarkerInfo.file.toString());
    assertEquals("error", problemMarkerInfo.description);
  }
  @Override
  protected void tearDown() throws Exception {
    ResourceHelper.cleanUp();
    fProject = null;

    ErrorParserManager.setUserDefinedErrorParsers(null);
  }
  /**
   * 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);
  }
  /**
   * 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 testBuildDir() throws Exception {
    ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
    ResourceHelper.createEfsFile(fProject, "Folder/testBuildDir.c", "null:/Folder/testBuildDir.c");
    ResourceHelper.createEfsFolder(fProject, "BuildDir", "null:/BuildDir");
    ResourceHelper.createEfsFile(
        fProject, "BuildDir/testBuildDir.c", "null:/BuildDir/testBuildDir.c");

    String buildDir = fProject.getLocation().append("BuildDir").toOSString();
    parseOutput(fProject, buildDir, "testBuildDir.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals(
        "L/FindMatchingFilesEfsTest/BuildDir/testBuildDir.c", 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 testDuplicateInRoot() throws Exception {
    ResourceHelper.createEfsFile(fProject, "testDuplicateInRoot.c", "null:/testDuplicateInRoot.c");

    ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
    ResourceHelper.createEfsFile(
        fProject, "Folder/testDuplicateInRoot.c", "null:/Folder/testDuplicateInRoot.c");

    // Resolved to the file in root folder
    parseOutput("testDuplicateInRoot.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals(1, problemMarkerInfo.lineNumber);
    assertEquals(
        "L/FindMatchingFilesEfsTest/testDuplicateInRoot.c", problemMarkerInfo.file.toString());
    assertEquals("error", problemMarkerInfo.description);
  }
 @Override
 protected void setUp() throws Exception {
   if (fProject == null) {
     fProject = ResourceHelper.createCDTProject(testName);
     Assert.assertNotNull(fProject);
     mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
   }
   errorList = new ArrayList<ProblemMarkerInfo>();
 }
  /**
   * Checks if a file from error output can be found.
   *
   * @throws Exception...
   */
  public void testRelativePathDotFromSubfolder() throws Exception {
    ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder");
    ResourceHelper.createEfsFolder(fProject, "Subfolder/Folder", "null:/Subfolder/Folder");
    ResourceHelper.createEfsFile(
        fProject,
        "Subfolder/Folder/testRelativePathDotFromSubfolder.c",
        "null:/Subfolder/Folder/testRelativePathDotFromSubfolder.c");

    parseOutput("./Folder/testRelativePathDotFromSubfolder.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    assertEquals(
        "L/FindMatchingFilesEfsTest/Subfolder/Folder/testRelativePathDotFromSubfolder.c",
        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 testRelativePathNotMatchingFolder() throws Exception {
    ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
    ResourceHelper.createEfsFile(
        fProject,
        "Folder/testRelativePathNotMatchingFolder.c",
        "null:/Folder/testRelativePathNotMatchingFolder.c");

    parseOutput("NotMatchingFolder/testRelativePathNotMatchingFolder.c:1:error");
    assertEquals(1, errorList.size());

    ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
    // No match
    assertEquals("P/FindMatchingFilesEfsTest", problemMarkerInfo.file.toString());
    assertEquals(1, problemMarkerInfo.lineNumber);
    assertEquals("error", problemMarkerInfo.description);
    assertEquals(
        new Path("NotMatchingFolder/testRelativePathNotMatchingFolder.c"),
        problemMarkerInfo.externalPath);
  }
  /**
   * 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);
  }
Example #12
0
 /**
  * Creates new temporary folder with generated name from workspace root.
  *
  * @return absolute location of the folder on the file system.
  * @throws IOException if something goes wrong.
  */
 public static IPath createTemporaryFolder() throws CoreException, IOException {
   return ResourceHelper.createWorkspaceFolder(
       "tmp/" + System.currentTimeMillis() + '.' + UUID.randomUUID());
 }
Example #13
0
 @Override
 protected void setUp() throws Exception {
   fProject = ResourceHelper.createCDTProject(TEST_PROJECT_NAME);
   assertNotNull(fProject);
   errorList = new ArrayList<ProblemMarkerInfo>();
 }
Example #14
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]);
    }
  }
 @Override
 protected void tearDown() throws Exception {
   ResourceHelper.cleanUp();
   fProject = null;
 }