author | bobv |
Tue, 07 Nov 2017 10:30:53 -0500 | |
changeset 47801 | c7b50c23ea71 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
44287
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
1 |
/* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
4 |
* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
8 |
* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
14 |
* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
18 |
* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
21 |
* questions. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
22 |
*/ |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
23 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
24 |
/* |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
25 |
* @test |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
26 |
* @bug 8175219 |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
27 |
* @summary test --ignore-errors works correctly |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
28 |
* @modules |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
29 |
* jdk.javadoc/jdk.javadoc.internal.api |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
30 |
* jdk.javadoc/jdk.javadoc.internal.tool |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.api |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.main |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
33 |
* @library /tools/lib |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
34 |
* @build toolbox.ToolBox toolbox.TestRunner |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
35 |
* @run main IgnoreSourceErrors |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
36 |
*/ |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
37 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
38 |
import java.io.IOException; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
39 |
import java.nio.file.Files; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
42 |
import java.nio.file.StandardOpenOption; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
43 |
import java.util.Arrays; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
44 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
45 |
import toolbox.*; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
46 |
import toolbox.Task.*; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
47 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
48 |
/** |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
49 |
* Dummy javadoc comment. |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
50 |
*/ |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
51 |
public class IgnoreSourceErrors extends TestRunner { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
52 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
53 |
final ToolBox tb; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
54 |
final Path testSrc; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
55 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
56 |
public IgnoreSourceErrors() throws IOException { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
57 |
super(System.err); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
58 |
tb = new ToolBox(); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
59 |
testSrc = Paths.get("Foo.java"); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
60 |
emitSample(testSrc); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
61 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
62 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
63 |
public static void main(String... args) throws Exception { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
64 |
new IgnoreSourceErrors().runTests(); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
65 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
66 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
67 |
@Test |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
68 |
public void runIgnoreErrorsOffByDefault() throws Exception { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
69 |
JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
70 |
task.options(testSrc.toString()); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
71 |
Task.Result result = task.run(Expect.FAIL); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
72 |
String out = result.getOutput(OutputKind.DIRECT); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
73 |
if (!out.contains("modifier static not allowed here")) { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
74 |
throw new Exception("expected string not found \'modifier static not allowed here\'"); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
75 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
76 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
77 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
78 |
@Test |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
79 |
public void runIgnoreErrorsOn() throws Exception { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
80 |
JavadocTask task = new JavadocTask(tb, Task.Mode.CMDLINE); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
81 |
task.options("--ignore-source-errors", testSrc.toString()); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
82 |
Task.Result result = task.run(Expect.SUCCESS); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
83 |
String out = result.getOutput(OutputKind.DIRECT); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
84 |
if (!out.contains("modifier static not allowed here")) { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
85 |
throw new Exception("expected string not found \'modifier static not allowed here\'"); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
86 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
87 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
88 |
|
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
89 |
void emitSample(Path file) throws IOException { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
90 |
String[] contents = { |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
91 |
"/** A java file with errors */", |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
92 |
"public static class Foo {}" |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
93 |
}; |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
94 |
Files.write(file, Arrays.asList(contents), StandardOpenOption.CREATE); |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
95 |
} |
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
diff
changeset
|
96 |
} |