mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8024096: some javadoc tests may contain false positive results
Reviewed-by: jjg
This commit is contained in:
parent
484e378a9d
commit
2be05076f8
6 changed files with 104 additions and 54 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -57,6 +57,7 @@ public abstract class JavadocTester {
|
|||
protected static final String SRC_DIR = System.getProperty("test.src", ".");
|
||||
protected static final String JAVA_VERSION = System.getProperty("java.version");
|
||||
protected static final String[][] NO_TEST = new String[][] {};
|
||||
protected static final String[] NO_FILE_TEST = new String[] {};
|
||||
|
||||
/**
|
||||
* Use this as the file name in the test array when you want to search
|
||||
|
@ -165,6 +166,26 @@ public abstract class JavadocTester {
|
|||
return returnCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the tests.
|
||||
*
|
||||
* @param tester the tester to execute
|
||||
* @param args the arguments to pass to Javadoc
|
||||
* @param testArray the array of tests
|
||||
* @param negatedTestArray the array of negated tests
|
||||
* @param fileTestArray the array of file tests
|
||||
* @param negatedFileTestArray the array of negated file tests
|
||||
* @return the return code for the execution of Javadoc
|
||||
*/
|
||||
public static int run(JavadocTester tester, String[] args,
|
||||
String[][] testArray, String[][] negatedTestArray, String[] fileTestArray,
|
||||
String[] negatedFileTestArray) {
|
||||
int returnCode = tester.runJavadoc(args);
|
||||
tester.runTestsOnHTML(testArray, negatedTestArray);
|
||||
tester.runTestsOnFile(fileTestArray, negatedFileTestArray);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute Javadoc using the default doclet.
|
||||
*
|
||||
|
@ -243,6 +264,19 @@ public abstract class JavadocTester {
|
|||
runTestsOnHTML(negatedTestArray, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run array of tests on the generated files.
|
||||
* This method accepts a fileTestArray for testing if a file is generated
|
||||
* and a negatedFileTestArray for testing if a file is not found.
|
||||
*
|
||||
* @param testArray the array of file tests
|
||||
* @param negatedTestArray the array of negated file tests
|
||||
*/
|
||||
public void runTestsOnFile(String[] fileTestArray, String[] negatedFileTestArray) {
|
||||
runTestsOnFile(fileTestArray, false);
|
||||
runTestsOnFile(negatedFileTestArray, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the array of tests on the resulting HTML.
|
||||
*
|
||||
|
@ -265,9 +299,11 @@ public abstract class JavadocTester {
|
|||
fileString = readFileToString(testArray[i][0]);
|
||||
} catch (Error e) {
|
||||
if (isNegated) {
|
||||
numTestsPassed += 1;
|
||||
System.out.println("Passed\n not found:\n"
|
||||
+ stringToFind + " in non-existent " + testArray[i][0] + "\n");
|
||||
System.out.println( "FAILED" + "\n"
|
||||
+ "for bug " + getBugId()
|
||||
+ " (" + getBugName() + ") "
|
||||
+ "due to "
|
||||
+ e + "\n");
|
||||
continue;
|
||||
}
|
||||
throw e;
|
||||
|
@ -290,6 +326,39 @@ public abstract class JavadocTester {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the array of file tests on the generated files.
|
||||
*
|
||||
* @param testArray the array of file tests
|
||||
* @param isNegated true if test is negated; false otherwise
|
||||
*/
|
||||
private void runTestsOnFile(String[] testArray, boolean isNegated) {
|
||||
String fileName;
|
||||
String failedString;
|
||||
String passedString;
|
||||
for (int i = 0; i < testArray.length; i++) {
|
||||
numTestsRun++;
|
||||
fileName = testArray[i];
|
||||
failedString = "FAILED" + "\n"
|
||||
+ "for bug " + getBugId() + " (" + getBugName() + ") "
|
||||
+ "file (" + fileName + ") found" + "\n";
|
||||
passedString = "Passed" + "\n" +
|
||||
"file (" + fileName + ") not found" + "\n";
|
||||
System.out.print("Running subtest #" + numTestsRun + "... ");
|
||||
try {
|
||||
File file = new File(fileName);
|
||||
if ((file.exists() && !isNegated) || (!file.exists() && isNegated)) {
|
||||
numTestsPassed += 1;
|
||||
System.out.println(passedString);
|
||||
} else {
|
||||
System.out.println(failedString);
|
||||
}
|
||||
} catch (Error e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through the list of given file pairs and diff each file.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,7 @@ import java.io.File;
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4258405 4973606
|
||||
* @bug 4258405 4973606 8024096
|
||||
* @summary This test verifies that the doc-file directory does not
|
||||
* get overwritten when the sourcepath is equal to the destination
|
||||
* directory.
|
||||
|
@ -47,25 +47,17 @@ public class TestDocFileDir extends JavadocTester {
|
|||
};
|
||||
private static final String[][] NEGATED_TEST1 = NO_TEST;
|
||||
|
||||
private static final String[][] TEST2 = {
|
||||
{BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" +
|
||||
private static final String[] FILE_TEST2 = {
|
||||
BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" +
|
||||
FS + "testfile.txt",
|
||||
"passed"
|
||||
},
|
||||
{BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" +
|
||||
FS + "testfile.txt",
|
||||
"passed"
|
||||
},
|
||||
BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" +
|
||||
FS + "testfile.txt"
|
||||
};
|
||||
private static final String[][] NEGATED_TEST2 = {
|
||||
{BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" +
|
||||
private static final String[] FILE_NEGATED_TEST2 = {
|
||||
BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" +
|
||||
FS + "testfile.txt",
|
||||
"passed"
|
||||
},
|
||||
{BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" +
|
||||
FS + "testfile.txt",
|
||||
"passed"
|
||||
},
|
||||
BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" +
|
||||
FS + "testfile.txt"
|
||||
};
|
||||
|
||||
private static final String[][] TEST0 = {
|
||||
|
@ -106,7 +98,7 @@ public class TestDocFileDir extends JavadocTester {
|
|||
run(tester, ARGS0, TEST0, NEGATED_TEST0);
|
||||
copyDir(SRC_DIR + FS + "pkg", BUG_ID + "-1");
|
||||
run(tester, ARGS1, TEST1, NEGATED_TEST1);
|
||||
run(tester, ARGS2, TEST2, NEGATED_TEST2);
|
||||
run(tester, ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2);
|
||||
tester.printSummary();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,7 +23,9 @@
|
|||
|
||||
|
||||
/**
|
||||
* ±ñÉ¿í ¹©¢!
|
||||
* Testing en\u00e7\u00f4ded string.
|
||||
* In the encoded comment string, Unicode U+00E7 is "Latin small letter C with cedilla"
|
||||
* and Unicode U+00F4 is "Latin small letter O with circumflex"
|
||||
*/
|
||||
public class EncodeTest {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4661481
|
||||
* @bug 4661481 8024096
|
||||
* @summary This test determines if the value of the -encoding option is
|
||||
* properly passed from Javadoc to the source file parser.
|
||||
* @author jamieh
|
||||
|
@ -40,12 +40,12 @@ public class TestEncoding extends JavadocTester {
|
|||
|
||||
//If ??? is found in the output, the source file was not read with the correct encoding setting.
|
||||
private static final String[][] NEGATED_TEST = {
|
||||
{BUG_ID + FS + "EncodeTest.html", "???"}
|
||||
{BUG_ID + FS + "EncodeTest.html", "??"}
|
||||
};
|
||||
private static final String[] ARGS =
|
||||
new String[] {
|
||||
"-d", BUG_ID, "-sourcepath", SRC_DIR,
|
||||
"-encoding", "SJIS", SRC_DIR + FS + "EncodeTest.java"
|
||||
"-encoding", "iso-8859-1", SRC_DIR + FS + "EncodeTest.java"
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8002304
|
||||
* @bug 8002304 8024096
|
||||
* @summary Test for various method types in the method summary table
|
||||
* @author Bhavesh Patel
|
||||
* @library ../lib/
|
||||
|
@ -107,7 +107,7 @@ public class TestMethodTypes extends JavadocTester {
|
|||
"</caption>"
|
||||
},
|
||||
|
||||
{BUG_ID + FS + "pkg" + FS + "D.html",
|
||||
{BUG_ID + FS + "pkg1" + FS + "D.html",
|
||||
"<caption><span>Methods</span><span class=\"tabEnd\"> </span>" +
|
||||
"</caption>"
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8006124 8009684 8016921 8023700
|
||||
* @bug 8006124 8009684 8016921 8023700 8024096
|
||||
* @summary Test javadoc support for profiles.
|
||||
* @author Bhavesh Patel, Evgeniya Stepanova
|
||||
* @library ../lib/
|
||||
|
@ -187,26 +187,6 @@ public class TestProfiles extends JavadocTester {
|
|||
}
|
||||
};
|
||||
private static final String[][] PACKAGES_NEGATED_TEST = {
|
||||
{PACKAGE_BUG_ID + FS + "profile-overview-frame.html",
|
||||
"<span><a href=\"overview-frame.html\" "
|
||||
+ "target=\"packageListFrame\">All Packages</a></span>"
|
||||
},
|
||||
{PACKAGE_BUG_ID + FS + "compact2-frame.html",
|
||||
"<span><a href=\"overview-frame.html\" target=\"packageListFrame\">"
|
||||
+ "All Packages</a></span><span><a href=\"profile-overview-frame.html\" "
|
||||
+ "target=\"packageListFrame\">All Profiles</a></span>"
|
||||
},
|
||||
{PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html",
|
||||
"<a href=\"../compact2-summary.html\" target=\"classFrame\">"
|
||||
+ "compact2</a> - <a href=\"../pkg2/compact2-package-summary.html\" "
|
||||
+ "target=\"classFrame\">pkg2</a>"
|
||||
},
|
||||
{PACKAGE_BUG_ID + FS + "compact2-summary.html",
|
||||
"<h1 title=\"Profile\" class=\"title\">Profile compact2</h1>"
|
||||
},
|
||||
{PACKAGE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html",
|
||||
"<div class=\"subTitle\">compact3</div>"
|
||||
},
|
||||
{PACKAGE_BUG_ID + FS + "overview-frame.html",
|
||||
"<span><a href=\"profile-overview-frame.html\" "
|
||||
+ "target=\"packageListFrame\">All Profiles</a></span>"
|
||||
|
@ -222,6 +202,13 @@ public class TestProfiles extends JavadocTester {
|
|||
"</ul>"
|
||||
}
|
||||
};
|
||||
private static final String[] PACKAGES_NEGATED_FILE_TEST = {
|
||||
PACKAGE_BUG_ID + FS + "profile-overview-frame.html",
|
||||
PACKAGE_BUG_ID + FS + "compact2-frame.html",
|
||||
PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html",
|
||||
PACKAGE_BUG_ID + FS + "compact2-summary.html",
|
||||
PACKAGE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html"
|
||||
};
|
||||
|
||||
/**
|
||||
* The entry point of the test.
|
||||
|
@ -231,7 +218,7 @@ public class TestProfiles extends JavadocTester {
|
|||
public static void main(String[] args) {
|
||||
TestProfiles tester = new TestProfiles();
|
||||
run(tester, ARGS1, PROFILES_TEST, PROFILES_NEGATED_TEST);
|
||||
run(tester, ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST);
|
||||
run(tester, ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST, NO_FILE_TEST, PACKAGES_NEGATED_FILE_TEST);
|
||||
tester.printSummary();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue