Skip to content
Permalink
Browse files

Merge pull request #6 from kbriggs/bugfix-JENKINS-18154

[JENKINS-18154] Use correct HTML output with folderWhereYouRunDoxygen
  • Loading branch information...
gboissinot committed Jun 23, 2013
2 parents e39037f + 7943ee7 commit 171a66a82dacd93a1038fea4be34295067408cbc
@@ -108,51 +108,22 @@ private FilePath getDoxygenGeneratedDir(FilePath base) throws IOException, Inter
if (doxyfileInfos == null)
return null;

FilePath result = base;
if ((this.folderWhereYouRunDoxygen != null) && (!this.folderWhereYouRunDoxygen.trim().isEmpty())) {
result = result.child(this.folderWhereYouRunDoxygen);
}
final String outputDirectory = doxyfileInfos.get(DOXYGEN_KEY_OUTPUT_DIRECTORY);

String doxyGenDir = null;
if (outputDirectory != null && outputDirectory.trim().length() != 0) {
Boolean absolute = false;
absolute = base.act(new FilePath.FileCallable<Boolean>() {
public Boolean invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
return new File(outputDirectory).exists();
}
});

if (absolute) {
doxyGenDir = outputDirectory;
} else {
// Check if need to append the path from where doxygen is run
if ((this.folderWhereYouRunDoxygen != null) && (!this.folderWhereYouRunDoxygen.isEmpty())) {
doxyGenDir = this.folderWhereYouRunDoxygen + File.separator + outputDirectory;
} else {
doxyGenDir = outputDirectory;
}
}
if ((outputDirectory != null) && (!outputDirectory.trim().isEmpty())) {
result = result.child(outputDirectory);
}

//Concat html directory
String outputHTML = doxyfileInfos.get(DOXYGEN_KEY_HTML_OUTPUT);
if (outputHTML == null || outputHTML.trim().length() == 0) {
outputHTML = "html";
if (outputHTML == null || outputHTML.trim().isEmpty()) {
outputHTML = DOXYGEN_DEFAULT_HTML_OUTPUT;
LOGGER.log(Level.INFO, "The " + DOXYGEN_KEY_HTML_OUTPUT + " tag is not present or is left blank." + DOXYGEN_DEFAULT_HTML_OUTPUT + " will be used as the default path.");
}
doxyGenDir = (doxyGenDir != null) ? (doxyGenDir + File.separator + outputHTML) :
(this.folderWhereYouRunDoxygen != null) && (!this.folderWhereYouRunDoxygen.isEmpty()) ?
(this.folderWhereYouRunDoxygen + File.separator + outputHTML) : outputHTML;

final String finalComputedDoxygenDir = doxyGenDir.replace('\\', '/');
Boolean absolute = isDirectoryAbsolute(base, finalComputedDoxygenDir);
LOGGER.info("Directory is absolute:"+absolute);

FilePath result;
if (absolute) {
LOGGER.info("Creating FilePath using base.getChannel()");
result = new FilePath(base.getChannel(), finalComputedDoxygenDir);
} else {
LOGGER.info("Creating FilePath using base");
result = new FilePath(base, doxyGenDir);
}
result = result.child(outputHTML);

LOGGER.info("Created filepath with the following path:"+result.getRemote());
if (!result.exists()) {
@@ -163,35 +134,6 @@ public Boolean invoke(File f, VirtualChannel channel) throws IOException, Interr
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
*/
@@ -227,18 +227,44 @@ public void retrieveDoxygenFromLoadFileWithWhereRun() throws Exception {

classContext.assertIsSatisfied();
context.assertIsSatisfied();
}

}


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

String whereRun = "testWhereRun";

//Create the doxyfile with content in the temporary workspace
FilePath doxyfileDir = new FilePath(workspace,whereRun);
FilePath doxyfilePath = doxyfileDir.child("Doxyfile-dot");
doxyfileDir.mkdirs();
FileOutputStream fos = new FileOutputStream(new File(doxyfilePath.toURI()));
fos.write(readAsString("Doxyfile-dot").getBytes());
fos.close();

//Create the generated doxygen directory
String commandDoxygenGeneratedDirectoryName="html";
FilePath doxygenDir=new FilePath(doxyfileDir,commandDoxygenGeneratedDirectoryName);
doxygenDir.mkdirs();

// 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);
DoxygenDirectoryParser doxygenDirectoryParser =
new DoxygenDirectoryParser(DoxygenArchiverDescriptor.DOXYGEN_DOXYFILE_PUBLISHTYPE ,doxyfilePath.toString(),"",whereRun);

classContext.checking(new Expectations() {
{
ignoring(taskListener).getLogger();
will(returnValue(new PrintStream(new ByteArrayOutputStream())));
}
});

FilePath resultDoxygenDirectory = doxygenDirectoryParser.invoke(parentFile, virtualChannel);
assertEquals("The computed doxygen directory is not correct", doxygenDir.toURI(),resultDoxygenDirectory.toURI());


classContext.assertIsSatisfied();
context.assertIsSatisfied();
}

}
@@ -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,0 +1,125 @@
# Doxyfile 1.5.7.1

#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = test
PROJECT_NUMBER = test
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = "C:/Documents and Settings/s0011918/"
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = YES
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
SYMBOL_CACHE_SIZE = 0
INPUT = src/main/java
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.f90 \
*.f \
*.vhd \
*.vhdl
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
HTML_DYNAMIC_SECTIONS = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHG_LOCATION =
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NONE
TREEVIEW_WIDTH = 250
FORMULA_FONTSIZE = 10

0 comments on commit 171a66a

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