Skip to content

Commit f153e41

Browse files
committed
8361253: CommandLineOptionTest library should report observed values on failure
Reviewed-by: dholmes, shade
1 parent fba74f7 commit f153e41

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/lib/jdk/test/lib/cli/CommandLineOptionTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public static void verifyJVMStartup(String expectedMessages[],
122122
outputAnalyzer.shouldHaveExitValue(exitCode.value);
123123
} catch (RuntimeException e) {
124124
String errorMessage = String.format(
125-
"JVM process should have exit value '%d'.%n%s",
126-
exitCode.value, exitErrorMessage);
125+
"JVM process should have exit value '%d', but has '%d'.%n%s",
126+
exitCode.value, outputAnalyzer.getExitValue(), exitErrorMessage);
127127
throw new AssertionError(errorMessage, e);
128128
}
129129

@@ -302,9 +302,12 @@ public static void verifyOptionValue(String optionName,
302302
CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT,
303303
optionName, expectedValue));
304304
} catch (RuntimeException e) {
305+
String observedValue = outputAnalyzer.firstMatch(String.format(
306+
CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT,
307+
optionName, "\\S"));
305308
String errorMessage = String.format(
306-
"Option '%s' is expected to have '%s' value%n%s",
307-
optionName, expectedValue,
309+
"Option '%s' is expected to have '%s' value, but is '%s'.%n%s",
310+
optionName, expectedValue, observedValue,
308311
optionErrorString);
309312
throw new AssertionError(errorMessage, e);
310313
}

0 commit comments

Comments
 (0)