|
22 | 22 | */ |
23 | 23 |
|
24 | 24 |
|
| 25 | +import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK; |
| 26 | + |
25 | 27 | import java.io.IOException; |
26 | 28 | import java.nio.file.Files; |
27 | 29 | import java.nio.file.Path; |
28 | | -import java.util.List; |
29 | 30 | import java.util.ArrayList; |
30 | 31 | import java.util.Collection; |
31 | 32 | import java.util.Collections; |
| 33 | +import java.util.List; |
32 | 34 | import java.util.Optional; |
33 | 35 | import java.util.function.Function; |
34 | 36 | import java.util.function.Predicate; |
35 | 37 | import java.util.regex.Pattern; |
36 | 38 | import java.util.stream.Stream; |
37 | | -import jdk.jpackage.test.TKit; |
| 39 | +import jdk.jpackage.internal.util.function.ThrowingConsumer; |
| 40 | +import jdk.jpackage.test.Annotations.Parameter; |
| 41 | +import jdk.jpackage.test.Annotations.ParameterSupplier; |
| 42 | +import jdk.jpackage.test.Annotations.Test; |
| 43 | +import jdk.jpackage.test.CannedFormattedString; |
| 44 | +import jdk.jpackage.test.Executor; |
| 45 | +import jdk.jpackage.test.HelloApp; |
38 | 46 | import jdk.jpackage.test.JPackageCommand; |
39 | 47 | import jdk.jpackage.test.JPackageStringBundle; |
40 | 48 | import jdk.jpackage.test.JavaAppDesc; |
41 | | -import jdk.jpackage.test.PackageTest; |
42 | | -import jdk.jpackage.test.HelloApp; |
43 | | -import jdk.jpackage.test.Executor; |
44 | 49 | import jdk.jpackage.test.JavaTool; |
45 | | -import jdk.jpackage.test.Annotations.Test; |
46 | | -import jdk.jpackage.test.Annotations.Parameter; |
47 | | -import jdk.jpackage.test.Annotations.ParameterSupplier; |
48 | | -import jdk.jpackage.internal.util.function.ThrowingConsumer; |
| 50 | +import jdk.jpackage.test.PackageTest; |
| 51 | +import jdk.jpackage.test.TKit; |
49 | 52 | import jdk.tools.jlink.internal.LinkableRuntimeImage; |
50 | | -import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK; |
51 | 53 |
|
52 | 54 | /* |
53 | 55 | * @test |
@@ -228,6 +230,29 @@ public void testVerbose() { |
228 | 230 | }); |
229 | 231 | } |
230 | 232 |
|
| 233 | + @Test |
| 234 | + @Parameter("false") |
| 235 | + @Parameter("true") |
| 236 | + public void testErrorsAlwaysPrinted(boolean verbose) { |
| 237 | + final var cmd = JPackageCommand.helloAppImage() |
| 238 | + .ignoreDefaultVerbose(true) |
| 239 | + .useToolProvider(false) |
| 240 | + .removeArgumentWithValue("--main-class"); |
| 241 | + |
| 242 | + if (verbose) { |
| 243 | + cmd.addArgument("--verbose"); |
| 244 | + } |
| 245 | + |
| 246 | + final var textVerifier = Stream.of( |
| 247 | + List.of("error.no-main-class-with-main-jar", "hello.jar"), |
| 248 | + List.of("error.no-main-class-with-main-jar.advice", "hello.jar") |
| 249 | + ).map(args -> { |
| 250 | + return JPackageStringBundle.MAIN.cannedFormattedString(args.getFirst(), args.subList(1, args.size()).toArray()); |
| 251 | + }).map(CannedFormattedString::getValue).map(TKit::assertTextStream).reduce(TKit.TextStreamVerifier::andThen).orElseThrow(); |
| 252 | + |
| 253 | + textVerifier.apply(cmd.saveConsoleOutput(true).execute(1).getOutput().stream().filter(Predicate.not(JPackageCommand::withTimestamp))); |
| 254 | + } |
| 255 | + |
231 | 256 | @Test |
232 | 257 | public void testNoName() { |
233 | 258 | final String mainClassName = "Greetings"; |
|
0 commit comments