306 error(tr, "Expected output not found");
307 show(tr);
308 }
309
310 // java --source N -m jdk.compiler
311 @Test
312 void testSourceModuleConflict() throws IOException {
313 starting("testSourceModuleConflict");
314 TestResult tr = doExec(javaCmd, "--source", thisVersion, "-m", "jdk.compiler");
315 if (tr.isOK())
316 error(tr, "Command succeeded unexpectedly");
317 if (!tr.contains("Option -m is not allowed with --source"))
318 error(tr, "Expected output not found");
319 show(tr);
320 }
321
322 // #!.../java --source N -version
323 @Test
324 void testTerminalOptionInShebang() throws IOException {
325 starting("testTerminalOptionInShebang");
326 if (skipShebangTest || isAIX || isMacOSX || isSolaris) {
327 // On MacOSX, we cannot distinguish between terminal options on the
328 // shebang line and those on the command line.
329 // On Solaris, all options after the first on the shebang line are
330 // ignored. Similar on AIX.
331 log.println("SKIPPED");
332 return;
333 }
334 Path base = Files.createDirectories(
335 Paths.get("testTerminalOptionInShebang"));
336 Path bad = base.resolve("bad");
337 createFile(bad, List.of(
338 "#!" + shebangJavaCmd + " --source " + thisVersion + " -version"));
339 setExecutable(bad);
340 TestResult tr = doExec(bad.toString());
341 if (!tr.contains("Option -version is not allowed in this context"))
342 error(tr, "Expected output not found");
343 show(tr);
344 }
345
346 // #!.../java --source N @bad.at (contains -version)
347 @Test
348 void testTerminalOptionInShebangAtFile() throws IOException {
349 starting("testTerminalOptionInShebangAtFile");
350 if (skipShebangTest || isAIX || isMacOSX || isSolaris) {
351 // On MacOSX, we cannot distinguish between terminal options in a
352 // shebang @-file and those on the command line.
353 // On Solaris, all options after the first on the shebang line are
354 // ignored. Similar on AIX.
355 log.println("SKIPPED");
356 return;
357 }
358 // Use a short directory name, to avoid line length limitations
359 Path base = Files.createDirectories(Paths.get("testBadAtFile"));
360 Path bad_at = base.resolve("bad.at");
361 createFile(bad_at, List.of("-version"));
362 Path bad = base.resolve("bad");
363 createFile(bad, List.of(
364 "#!" + shebangJavaCmd + " --source " + thisVersion + " @" + bad_at));
365 setExecutable(bad);
366 TestResult tr = doExec(bad.toString());
367 if (!tr.contains("Option -version in @testBadAtFile/bad.at is "
368 + "not allowed in this context"))
369 error(tr, "Expected output not found");
370 show(tr);
371 }
372
373 // #!.../java --source N HelloWorld
374 @Test
375 void testMainClassInShebang() throws IOException {
376 starting("testMainClassInShebang");
377 if (skipShebangTest || isAIX || isMacOSX || isSolaris) {
378 // On MacOSX, we cannot distinguish between a main class on the
379 // shebang line and one on the command line.
380 // On Solaris, all options after the first on the shebang line are
381 // ignored. Similar on AIX.
382 log.println("SKIPPED");
383 return;
384 }
385 Path base = Files.createDirectories(Paths.get("testMainClassInShebang"));
386 Path bad = base.resolve("bad");
387 createFile(bad, List.of(
388 "#!" + shebangJavaCmd + " --source " + thisVersion + " HelloWorld"));
389 setExecutable(bad);
390 TestResult tr = doExec(bad.toString());
391 if (!tr.contains("Cannot specify main class in this context"))
392 error(tr, "Expected output not found");
393 show(tr);
394 }
395
396 //--------------------------------------------------------------------------
397
|
306 error(tr, "Expected output not found");
307 show(tr);
308 }
309
310 // java --source N -m jdk.compiler
311 @Test
312 void testSourceModuleConflict() throws IOException {
313 starting("testSourceModuleConflict");
314 TestResult tr = doExec(javaCmd, "--source", thisVersion, "-m", "jdk.compiler");
315 if (tr.isOK())
316 error(tr, "Command succeeded unexpectedly");
317 if (!tr.contains("Option -m is not allowed with --source"))
318 error(tr, "Expected output not found");
319 show(tr);
320 }
321
322 // #!.../java --source N -version
323 @Test
324 void testTerminalOptionInShebang() throws IOException {
325 starting("testTerminalOptionInShebang");
326 if (skipShebangTest || isAIX || isMacOSX) {
327 // On MacOSX, we cannot distinguish between terminal options on the
328 // shebang line and those on the command line.
329 // On Solaris, all options after the first on the shebang line are
330 // ignored. Similar on AIX.
331 log.println("SKIPPED");
332 return;
333 }
334 Path base = Files.createDirectories(
335 Paths.get("testTerminalOptionInShebang"));
336 Path bad = base.resolve("bad");
337 createFile(bad, List.of(
338 "#!" + shebangJavaCmd + " --source " + thisVersion + " -version"));
339 setExecutable(bad);
340 TestResult tr = doExec(bad.toString());
341 if (!tr.contains("Option -version is not allowed in this context"))
342 error(tr, "Expected output not found");
343 show(tr);
344 }
345
346 // #!.../java --source N @bad.at (contains -version)
347 @Test
348 void testTerminalOptionInShebangAtFile() throws IOException {
349 starting("testTerminalOptionInShebangAtFile");
350 if (skipShebangTest || isAIX || isMacOSX) {
351 // On MacOSX, we cannot distinguish between terminal options in a
352 // shebang @-file and those on the command line.
353 // On Solaris, all options after the first on the shebang line are
354 // ignored. Similar on AIX.
355 log.println("SKIPPED");
356 return;
357 }
358 // Use a short directory name, to avoid line length limitations
359 Path base = Files.createDirectories(Paths.get("testBadAtFile"));
360 Path bad_at = base.resolve("bad.at");
361 createFile(bad_at, List.of("-version"));
362 Path bad = base.resolve("bad");
363 createFile(bad, List.of(
364 "#!" + shebangJavaCmd + " --source " + thisVersion + " @" + bad_at));
365 setExecutable(bad);
366 TestResult tr = doExec(bad.toString());
367 if (!tr.contains("Option -version in @testBadAtFile/bad.at is "
368 + "not allowed in this context"))
369 error(tr, "Expected output not found");
370 show(tr);
371 }
372
373 // #!.../java --source N HelloWorld
374 @Test
375 void testMainClassInShebang() throws IOException {
376 starting("testMainClassInShebang");
377 if (skipShebangTest || isAIX || isMacOSX) {
378 // On MacOSX, we cannot distinguish between a main class on the
379 // shebang line and one on the command line.
380 // On Solaris, all options after the first on the shebang line are
381 // ignored. Similar on AIX.
382 log.println("SKIPPED");
383 return;
384 }
385 Path base = Files.createDirectories(Paths.get("testMainClassInShebang"));
386 Path bad = base.resolve("bad");
387 createFile(bad, List.of(
388 "#!" + shebangJavaCmd + " --source " + thisVersion + " HelloWorld"));
389 setExecutable(bad);
390 TestResult tr = doExec(bad.toString());
391 if (!tr.contains("Cannot specify main class in this context"))
392 error(tr, "Expected output not found");
393 show(tr);
394 }
395
396 //--------------------------------------------------------------------------
397
|