# HG changeset patch # User jjg # Date 1284656257 25200 # Node ID 90c4a1a6421770c4890299a13fdc7592b7021c69 # Parent b3bb16faccc203a77f82242cb6f55741ec163579 6985115: tests create too much output Reviewed-by: mcimadamore diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javac/T6855236.java --- a/langtools/test/tools/javac/T6855236.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javac/T6855236.java Thu Sep 16 09:57:37 2010 -0700 @@ -71,12 +71,10 @@ @Override public Object visitMethodInvocation(MethodInvocationTree node, Trees p) { - System.out.print("current path: "); + System.out.println("current path: "); for (Tree t : getCurrentPath()) { - System.out.print('/'); - System.out.print(t); - } - System.out.println(); + System.out.println(" " + t.getKind() + ": " + trim(t, 64)); + } System.out.println("parent path: " + getCurrentPath().getParentPath()); System.out.println("method select: " + node.getMethodSelect().toString()); for (ExpressionTree arg : node.getArguments()) { @@ -88,12 +86,20 @@ @Override public Object visitExpressionStatement(ExpressionStatementTree node, Trees p) { ExpressionTree t = node.getExpression(); - System.out.println("expression statement: " + t.toString()); + System.out.println(); + System.out.println("expression statement: " + trim(t, 64)); return super.visitExpressionStatement(node, p); } } + private String trim(Tree t, int len) { + String s = t.toString().trim().replaceAll("\\s+", " "); + if (s.length() > len) + s = s.substring(0, len) + "..."; + return s; + } + } diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javac/failover/CheckAttributedTree.java --- a/langtools/test/tools/javac/failover/CheckAttributedTree.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java Thu Sep 16 09:57:37 2010 -0700 @@ -282,13 +282,13 @@ Iterable trees = task.parse(); task.analyze(); List> res = new ArrayList<>(); - System.out.println("Try to add pairs. Elems are " + analyzedElems); + //System.out.println("Try to add pairs. Elems are " + analyzedElems); for (CompilationUnitTree t : trees) { JCCompilationUnit cu = (JCCompilationUnit)t; for (JCTree def : cu.defs) { if (def.getTag() == JCTree.CLASSDEF && analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) { - System.out.println("Adding pair..."); + //System.out.println("Adding pair..."); res.add(new Pair<>(cu, def)); } } diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javac/tree/AbstractTreeScannerTest.java --- a/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Thu Sep 16 09:57:37 2010 -0700 @@ -182,6 +182,16 @@ } /** + * Report an error. When the program is complete, the program will either + * exit or throw an Error if any errors have been reported. + * @param msg the error message + */ + void error(JavaFileObject file, String msg) { + System.err.println(file.getName() + ": " + msg); + errors++; + } + + /** * Report an error for a specific tree node. * @param file the source file for the tree * @param t the tree node @@ -197,7 +207,7 @@ */ String trim(Tree tree, int len) { JCTree t = (JCTree) tree; - String s = t.toString().replaceAll("[\r\n]+", " ").replaceAll(" +", " "); + String s = t.toString().replaceAll("\\s+", " "); return (s.length() < len) ? s : s.substring(0, len); } diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javac/tree/JavacTreeScannerTest.java --- a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java Thu Sep 16 09:57:37 2010 -0700 @@ -89,12 +89,13 @@ scan(tree); expect = new HashSet(); reflectiveScan(tree); + if (found.equals(expect)) { - System.err.println(found.size() + " trees compared OK"); + //System.err.println(sourcefile.getName() + ": trees compared OK"); return found.size(); } - error("Differences found for " + tree.sourcefile.getName()); + error(sourcefile, "differences found"); if (found.size() != expect.size()) error("Size mismatch; found: " + found.size() + ", expected: " + expect.size()); @@ -103,13 +104,13 @@ missing.addAll(expect); missing.removeAll(found); for (JCTree t: missing) - error(tree.sourcefile, t, "missing"); + error(sourcefile, t, "missing"); Set excess = new HashSet(); excess.addAll(found); excess.removeAll(expect); for (JCTree t: excess) - error(tree.sourcefile, t, "unexpected"); + error(sourcefile, t, "unexpected"); return 0; } @@ -119,7 +120,7 @@ public void scan(JCTree tree) { if (tree == null) return; - System.err.println("FOUND: " + tree.getTag() + " " + trim(tree, 64)); + //System.err.println("FOUND: " + tree.getTag() + " " + trim(tree, 64)); found.add(tree); super.scan(tree); } @@ -130,7 +131,7 @@ return; if (o instanceof JCTree) { JCTree tree = (JCTree) o; - System.err.println("EXPECT: " + tree.getTag() + " " + trim(tree, 64)); + //System.err.println("EXPECT: " + tree.getTag() + " " + trim(tree, 64)); expect.add(tree); for (Field f: getFields(tree)) { try { diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javac/tree/SourceTreeScannerTest.java --- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java Thu Sep 16 09:57:37 2010 -0700 @@ -91,12 +91,13 @@ scan(tree, null); expect = new HashSet(); reflectiveScan(tree); + if (found.equals(expect)) { - System.err.println(found.size() + " trees compared OK"); + //System.err.println(sourcefile.getName() + ": trees compared OK"); return found.size(); } - error("Differences found for " + tree.sourcefile.getName()); + error(sourcefile.getName() + ": differences found"); if (found.size() != expect.size()) error("Size mismatch; found: " + found.size() + ", expected: " + expect.size()); @@ -105,13 +106,13 @@ missing.addAll(expect); missing.removeAll(found); for (Tree t: missing) - error(tree.sourcefile, t, "missing"); + error(sourcefile, t, "missing"); Set excess = new HashSet(); excess.addAll(found); excess.removeAll(expect); for (Tree t: excess) - error(tree.sourcefile, t, "unexpected"); + error(sourcefile, t, "unexpected"); return 0; } @@ -121,7 +122,7 @@ public Void scan(Tree tree, Void ignore) { if (tree == null) return null; - System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64)); + //System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64)); found.add(tree); return super.scan(tree, ignore); } @@ -132,7 +133,7 @@ return; if (o instanceof JCTree) { JCTree tree = (JCTree) o; - System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); + //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); expect.add(tree); for (Field f: getFields(tree)) { if (TypeBoundKind.class.isAssignableFrom(f.getType())) { diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javap/T6868539.java --- a/langtools/test/tools/javap/T6868539.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javap/T6868539.java Thu Sep 16 09:57:37 2010 -0700 @@ -39,25 +39,25 @@ } void run() { - verify("T6868539", "Utf8 +java/lang/String"); // 1: Utf8 + String output = javap("T6868539"); + verify(output, "Utf8 +java/lang/String"); // 1: Utf8 // 2: currently unused - verify("T6868539", "Integer +123456"); // 3: Integer - verify("T6868539", "Float +123456.0f"); // 4: Float - verify("T6868539", "Long +123456l"); // 5: Long - verify("T6868539", "Double +123456.0d"); // 6: Double - verify("T6868539", "Class +#[0-9]+ +// + T6868539"); // 7: Class - verify("T6868539", "String +#[0-9]+ +// + not found"); // 8: String - verify("T6868539", "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref - verify("T6868539", "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref - verify("T6868539", "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V"); + verify(output, "Integer +123456"); // 3: Integer + verify(output, "Float +123456.0f"); // 4: Float + verify(output, "Long +123456l"); // 5: Long + verify(output, "Double +123456.0d"); // 6: Double + verify(output, "Class +#[0-9]+ +// + T6868539"); // 7: Class + verify(output, "String +#[0-9]+ +// + not found"); // 8: String + verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref + verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref + verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V"); // 11: InterfaceMethodref - verify("T6868539", "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType + verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType if (errors > 0) throw new Error(errors + " found."); } - void verify(String className, String... expects) { - String output = javap(className); + void verify(String output, String... expects) { for (String expect: expects) { if (!output.matches("(?s).*" + expect + ".*")) error(expect + " not found"); diff -r b3bb16faccc2 -r 90c4a1a64217 langtools/test/tools/javap/T6980017.java --- a/langtools/test/tools/javap/T6980017.java Thu Sep 16 09:56:25 2010 -0700 +++ b/langtools/test/tools/javap/T6980017.java Thu Sep 16 09:57:37 2010 -0700 @@ -39,7 +39,7 @@ String[] args = { "-v", "-XDdetails:source", - "java.lang.String" + "java.lang.Object" }; StringWriter sw = new StringWriter();