29
29
* @test id=run-time-image-cap-yes
30
30
* @summary Test jlink --help for capability output (true)
31
31
* @requires (vm.compMode != "Xcomp" & jlink.runtime.linkable)
32
- * @run main/othervm JLinkHelpCapabilityTest true
32
+ * @run main/othervm -Duser.language=en JLinkHelpCapabilityTest true
33
33
*/
34
34
35
35
/*
36
36
* @test id=run-time-image-cap-no
37
37
* @summary Test jlink --help for capability output (false)
38
38
* @requires (vm.compMode != "Xcomp" & !jlink.runtime.linkable)
39
- * @run main/othervm JLinkHelpCapabilityTest false
39
+ * @run main/othervm -Duser.language=en JLinkHelpCapabilityTest false
40
40
*/
41
41
public class JLinkHelpCapabilityTest {
42
42
static final ToolProvider JLINK_TOOL = ToolProvider .findFirst ("jlink" )
@@ -46,18 +46,36 @@ public class JLinkHelpCapabilityTest {
46
46
47
47
public static void main (String [] args ) throws Exception {
48
48
boolean runtimeLinkCap = Boolean .parseBoolean (args [0 ]);
49
- String capabilities = String .format ("Capabilities: %srun -time- image" ,
50
- runtimeLinkCap ? "+ " : "- " );
49
+ String capabilities = String .format ("Linking from run -time image %s " ,
50
+ runtimeLinkCap ? "enabled " : "disabled " );
51
51
{
52
52
// Verify capability in --help output
53
53
StringWriter writer = new StringWriter ();
54
54
PrintWriter pw = new PrintWriter (writer );
55
55
JLINK_TOOL .run (pw , pw , "--help" );
56
56
String output = writer .toString ().trim ();
57
57
String lines [] = output .split ("\n " );
58
- if (!capabilities .equals (lines [lines .length - 1 ])) {
58
+ String capabilitiesMsg = null ;
59
+ boolean seenCap = false ;
60
+ for (int i = 0 ; i < lines .length ; i ++) {
61
+ if (lines [i ].startsWith ("Capabilities:" )) {
62
+ seenCap = true ;
63
+ continue ; // skip 'Capabilities:'
64
+ }
65
+ if (!seenCap ) {
66
+ continue ;
67
+ } else {
68
+ // Line after capabilities is the message we care about
69
+ capabilitiesMsg = lines [i ].trim ();
70
+ break ;
71
+ }
72
+ }
73
+ System .out .println ("DEBUG: Capabilities:" );
74
+ System .out .println ("DEBUG: " + capabilitiesMsg );
75
+ if (!capabilities .equals (capabilitiesMsg )) {
59
76
System .err .println (output );
60
- throw new AssertionError ("'--help': Capabilities mismatch. Expected: '" + capabilities +"'" );
77
+ throw new AssertionError ("'--help': Capabilities mismatch. Expected: '" +
78
+ capabilities +"' but got '" + capabilitiesMsg + "'" );
61
79
}
62
80
}
63
81
}
0 commit comments