6989457: javadoc test file test/tools/javadoc/T4994049/FileWithTabs.java probably does not

Reviewed-by: mcimadamore
This commit is contained in:
Jonathan Gibbons 2010-10-12 12:55:38 -07:00
parent 0b7ceb0204
commit 2baca00eeb
2 changed files with 42 additions and 7 deletions

View File

@ -22,5 +22,5 @@
*/
public class FileWithTabs {
public void tabbedMethod() {}
\tpublic void tabbedMethod() {}
}

View File

@ -30,7 +30,7 @@
*/
import com.sun.javadoc.*;
import java.io.File;
import java.io.*;
import static com.sun.tools.javadoc.Main.execute;
public class T4994049 extends Doclet {
@ -52,12 +52,47 @@ public class T4994049 extends Doclet {
return false;
}
public static void main(String... args) {
public static void main(String... args) throws Exception {
File testSrc = new File(System.getProperty("test.src"));
File tmpSrc = new File("tmpSrc");
initTabs(testSrc, tmpSrc);
for (String file : args) {
File source = new File(System.getProperty("test.src", "."), file);
if (execute("javadoc", "T4994049", T4994049.class.getClassLoader(),
new String[]{source.getPath()} ) != 0)
throw new Error();
File source = new File(tmpSrc, file);
int rc = execute("javadoc", "T4994049", T4994049.class.getClassLoader(),
new String[]{ source.getPath() } );
if (rc != 0)
throw new Error("Unexpected return code from javadoc: " + rc);
}
}
static void initTabs(File from, File to) throws IOException {
for (File f: from.listFiles()) {
File t = new File(to, f.getName());
if (f.isDirectory()) {
initTabs(f, t);
} else if (f.getName().endsWith(".java")) {
write(t, read(f).replace("\\t", "\t"));
}
}
}
static String read(File f) throws IOException {
StringBuilder sb = new StringBuilder();
try (BufferedReader in = new BufferedReader(new FileReader(f))) {
String line;
while ((line = in.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
}
return sb.toString();
}
static void write(File f, String s) throws IOException {
f.getParentFile().mkdirs();
try (Writer out = new FileWriter(f)) {
out.write(s);
}
}