6985115: tests create too much output
Reviewed-by: mcimadamore
This commit is contained in:
parent
1144807f1f
commit
e0caf9f660
@ -71,12 +71,10 @@ public class T6855236 extends AbstractProcessor {
|
||||
|
||||
@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 @@ public class T6855236 extends AbstractProcessor {
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,13 +282,13 @@ public class CheckAttributedTree {
|
||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||
task.analyze();
|
||||
List<Pair<JCCompilationUnit, JCTree>> 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));
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +181,16 @@ public abstract class AbstractTreeScannerTest {
|
||||
errors++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -197,7 +207,7 @@ public abstract class AbstractTreeScannerTest {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,13 @@ public class JavacTreeScannerTest extends AbstractTreeScannerTest {
|
||||
scan(tree);
|
||||
expect = new HashSet<JCTree>();
|
||||
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 @@ public class JavacTreeScannerTest extends AbstractTreeScannerTest {
|
||||
missing.addAll(expect);
|
||||
missing.removeAll(found);
|
||||
for (JCTree t: missing)
|
||||
error(tree.sourcefile, t, "missing");
|
||||
error(sourcefile, t, "missing");
|
||||
|
||||
Set<JCTree> excess = new HashSet<JCTree>();
|
||||
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 class JavacTreeScannerTest extends AbstractTreeScannerTest {
|
||||
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 @@ public class JavacTreeScannerTest extends AbstractTreeScannerTest {
|
||||
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 {
|
||||
|
@ -91,12 +91,13 @@ public class SourceTreeScannerTest extends AbstractTreeScannerTest {
|
||||
scan(tree, null);
|
||||
expect = new HashSet<Tree>();
|
||||
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 @@ public class SourceTreeScannerTest extends AbstractTreeScannerTest {
|
||||
missing.addAll(expect);
|
||||
missing.removeAll(found);
|
||||
for (Tree t: missing)
|
||||
error(tree.sourcefile, t, "missing");
|
||||
error(sourcefile, t, "missing");
|
||||
|
||||
Set<Tree> excess = new HashSet<Tree>();
|
||||
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 class SourceTreeScannerTest extends AbstractTreeScannerTest {
|
||||
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 @@ public class SourceTreeScannerTest extends AbstractTreeScannerTest {
|
||||
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())) {
|
||||
|
@ -39,25 +39,25 @@ public class T6868539
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -39,7 +39,7 @@ public class T6980017 {
|
||||
String[] args = {
|
||||
"-v",
|
||||
"-XDdetails:source",
|
||||
"java.lang.String"
|
||||
"java.lang.Object"
|
||||
};
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
|
Loading…
Reference in New Issue
Block a user