1 /* |
1 /* |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
55 ModulePathTest t = new ModulePathTest(); |
56 ModulePathTest t = new ModulePathTest(); |
56 t.runTests(); |
57 t.runTests(); |
57 } |
58 } |
58 |
59 |
59 @Test |
60 @Test |
60 public void testNotExistsOnPath(Path base) throws Exception { |
61 public void testNotExistsOnPath_noWarn(Path base) throws Exception { |
61 Path src = base.resolve("src"); |
62 Path src = base.resolve("src"); |
62 tb.writeJavaFiles(src, "class C { }"); |
63 tb.writeJavaFiles(src, "class C { }"); |
63 |
64 |
64 String log = new JavacTask(tb, Task.Mode.CMDLINE) |
65 String log = new JavacTask(tb, Task.Mode.CMDLINE) |
65 .options("-XDrawDiagnostics", |
66 .options("-XDrawDiagnostics", |
66 "--module-path", "doesNotExist") |
67 "--module-path", "doesNotExist") |
67 .files(findJavaFiles(src)) |
68 .files(findJavaFiles(src)) |
68 .run(Task.Expect.FAIL) |
69 .run(Task.Expect.SUCCESS) |
69 .writeAll() |
70 .writeAll() |
70 .getOutput(Task.OutputKind.DIRECT); |
71 .getOutput(Task.OutputKind.DIRECT); |
71 |
72 |
72 if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist")) |
73 if (!log.isEmpty()) |
|
74 throw new Exception("unexpected output"); |
|
75 } |
|
76 |
|
77 @Test |
|
78 public void testNotExistsOnPath_warn(Path base) throws Exception { |
|
79 Path src = base.resolve("src"); |
|
80 tb.writeJavaFiles(src, "class C { }"); |
|
81 |
|
82 String log = new JavacTask(tb, Task.Mode.CMDLINE) |
|
83 .options("-XDrawDiagnostics", |
|
84 "-Xlint:path", |
|
85 "--module-path", "doesNotExist") |
|
86 .files(findJavaFiles(src)) |
|
87 .run(Task.Expect.SUCCESS) |
|
88 .writeAll() |
|
89 .getOutput(Task.OutputKind.DIRECT); |
|
90 |
|
91 if (!log.contains("- compiler.warn.path.element.not.found: doesNotExist")) |
73 throw new Exception("expected output not found"); |
92 throw new Exception("expected output not found"); |
74 } |
93 } |
75 |
94 |
76 @Test |
95 @Test |
77 public void testNotADirOnPath_1(Path base) throws Exception { |
96 public void testNotADirOnPath_1(Path base) throws Exception { |