[Patch] 8041793: javap misses newline after printing AnnotationDefault
Jonathan Gibbons
jonathan.gibbons at oracle.com
Sat Jan 14 02:50:24 UTC 2017
On 01/13/2017 01:38 PM, Denis Istomin wrote:
> Hi,
> Made patch for bug 8041793.
>
Hi Denis,
The test will probably fail on Windows, because you are checking for the
exact newline character "\n".
There are two typical solutions to this general problem.
1. Take the string returned by the tool and normalize the newlines with
code similar to
out.replace(System.getProperty("line.separator"), "\n")
The system property is also available as a constant within the
ToolBox class.
2. Split the output into lines, perhaps by using the getOutputLines
method instead of getOutput,
and then compare the resulting list against an equivalent list for
the expected output.
Note there are occasions when it is important to verify that the exact
platform line separator sequence
is being used, and that will require different solutions.
Your test is also somewhat terse, in that in the case of a problem, it
just says "Error". We run thousands
of tests every day on JDK builds, and when a test fails, it is helpful
to have a test report something more.
In this case, saying "Expected output not found" would be slightly
better, and probably good enough.
In cases where the expected output is bigger, it becomes more helpful to
give more details about where
the mismatch occurs. You don't need to provide a full diff (!), but at
least an indication of the line number
of the first mismatch would help focus the attention of the person who
ends up having to examine why
the test failed.
-- Jon
More information about the compiler-dev
mailing list