6989457: javadoc test file test/tools/javadoc/T4994049/FileWithTabs.java probably does not
authorjjg
Tue, 12 Oct 2010 12:55:38 -0700
changeset 6928 b261e884b833
parent 6927 5bc46d9ca5b9
child 6929 81a6a7c1bef1
6989457: javadoc test file test/tools/javadoc/T4994049/FileWithTabs.java probably does not Reviewed-by: mcimadamore
langtools/test/tools/javadoc/T4994049/FileWithTabs.java
langtools/test/tools/javadoc/T4994049/T4994049.java
--- a/langtools/test/tools/javadoc/T4994049/FileWithTabs.java	Mon Oct 11 10:19:57 2010 -0700
+++ b/langtools/test/tools/javadoc/T4994049/FileWithTabs.java	Tue Oct 12 12:55:38 2010 -0700
@@ -22,5 +22,5 @@
  */
 
 public class FileWithTabs {
-        public void tabbedMethod() {}
+\tpublic void tabbedMethod() {}
 }
--- a/langtools/test/tools/javadoc/T4994049/T4994049.java	Mon Oct 11 10:19:57 2010 -0700
+++ b/langtools/test/tools/javadoc/T4994049/T4994049.java	Tue Oct 12 12:55:38 2010 -0700
@@ -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 @@
         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);
         }
     }