changeset 762:68cf07910d74

6989457: javadoc test file test/tools/javadoc/T4994049/FileWithTabs.java probably does not Reviewed-by: mcimadamore
author jjg
date Tue, 12 Oct 2010 12:55:38 -0700
parents 5b5d965900b8
children 14a707f8ce84
files test/tools/javadoc/T4994049/FileWithTabs.java test/tools/javadoc/T4994049/T4994049.java
diffstat 2 files changed, 42 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javadoc/T4994049/FileWithTabs.java	Mon Oct 11 10:19:57 2010 -0700
+++ b/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/test/tools/javadoc/T4994049/T4994049.java	Mon Oct 11 10:19:57 2010 -0700
+++ b/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);
         }
     }