Skip to content
Permalink
Browse files

[JENKINS-18154] remove isDirectoryAbsolute()

The refactor of getDoxygenGeneratedDir() has made isDirectoryAbsolute()
redundant; remove it.
  • Loading branch information...
kbriggs committed Jun 23, 2013
1 parent 730f198 commit f9b10f47eac5609d3419240831f80bd6083bb3c3
@@ -134,35 +134,6 @@ private FilePath getDoxygenGeneratedDir(FilePath base) throws IOException, Inter
return result;
}

// See https://issues.jenkins-ci.org/browse/JENKINS-13599
protected boolean isDirectoryAbsolute(String path) {
File file = new File(path);
String absolutePath = file.getAbsolutePath();
LOGGER.info(String.format("passed in path:%s, absolutePath:%s",
path, absolutePath));
if(path.equals(file.getAbsolutePath())) {
return true;
}
else {
return false;
}
}

protected Boolean isDirectoryAbsolute(FilePath base,
final String finalComputedDoxygenDir) throws IOException,
InterruptedException {
Boolean absolute = false;
absolute = base.act(new FilePath.FileCallable<Boolean>() {
public Boolean invoke(File f, VirtualChannel channel)
throws IOException, InterruptedException {

// See https://issues.jenkins-ci.org/browse/JENKINS-13599
return isDirectoryAbsolute(finalComputedDoxygenDir);
}
});
return absolute;
}

/**
* Load the Doxyfile Doxygen file in memory
*/
@@ -229,16 +229,4 @@ public void retrieveDoxygenFromLoadFileWithWhereRun() throws Exception {
context.assertIsSatisfied();
}

@Test
public void pathIsRelativeWhenNoParent() throws Exception {
// Arrange
DoxygenDirectoryParser parser = new DoxygenDirectoryParser(DoxygenArchiverDescriptor.DOXYGEN_DOXYFILE_PUBLISHTYPE, "Doxyfile", "");

// Act
// A final computed directory like "html" has no parent.
Boolean absolute = parser.isDirectoryAbsolute(workspace, "html");

// Assert
Assert.assertFalse("When no parent is in the path, it is not absolute.", absolute);
}
}
@@ -6,26 +6,7 @@

public class DoxygenDirectoryParserTest {

@Test
public void testIsAbsolute() throws Exception {
DoxygenDirectoryParser parser = new DoxygenDirectoryParser("", "", "");
// testData array contains arrays of test data where index 0 is the path
// and index 1 is the expectedResult of isAbsolute
// This test data will currently on work in a Unix environment
System.out.println(System.getProperty("user.dir"));
Object[][] testData = new Object[][] {
{ "doc", false },
{ "/usr", true },
{ "abcd123", false }, // nonexistent relative dir
{ "/foo/bar", true }, // nonexistent absolute dir
{ "/etc/passwd", true },
{ "pom.xml", false }, // since tests are run from the trunk dir
{ "src", false }, // a dir in the trunk dir
};

for(Object[] testPair : testData ) {
Boolean actual = parser.isDirectoryAbsolute((String)testPair[0]);
Assert.assertEquals("For path:" + testPair[0], (Boolean)testPair[1], actual);
}
}
// No tests remain here, but the class is kept for future tests.
// TODO: move parsing-related tests from DoxygenArchiverTest to here.

}

0 comments on commit f9b10f4

Please sign in to comment.
You can’t perform that action at this time.