author | bobv |
Tue, 07 Nov 2017 10:30:53 -0500 | |
changeset 47801 | c7b50c23ea71 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
31936 | 1 |
/* |
44287
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
41451
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
31936 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36526
diff
changeset
|
24 |
import java.io.File; |
31936 | 25 |
import java.io.PrintWriter; |
26 |
import java.io.StringWriter; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Arrays; |
|
29 |
import java.util.List; |
|
30 |
import java.util.function.Predicate; |
|
41451 | 31 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
32 |
import jdk.javadoc.internal.tool.Main; |
41451 | 33 |
import jdk.javadoc.internal.tool.Main.Result; |
34 |
||
35 |
import static jdk.javadoc.internal.tool.Main.Result.*; |
|
31936 | 36 |
|
37 |
/** |
|
38 |
* @test |
|
39 |
* @bug 8086737 |
|
40763
209113892b0d
8165109: langtools/test switches to use new CLI options
mchung
parents:
40308
diff
changeset
|
40 |
* @summary Test --release option in javadoc |
31936 | 41 |
* @run main ReleaseOption |
36526 | 42 |
* @modules jdk.javadoc/jdk.javadoc.internal.tool |
31936 | 43 |
*/ |
44 |
public class ReleaseOption { |
|
45 |
public static void main(String... args) { |
|
46 |
new ReleaseOption().run(); |
|
47 |
} |
|
48 |
||
49 |
void run() { |
|
44287
829205b133d4
8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents:
41451
diff
changeset
|
50 |
doRunTest(ERROR, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7"); |
41451 | 51 |
doRunTest(OK, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8"); |
52 |
doRunTest(CMDERR, out -> true, "--release", "7", "-source", "7"); |
|
53 |
doRunTest(CMDERR, out -> true, "--release", "7", "-bootclasspath", "any"); |
|
31936 | 54 |
} |
55 |
||
41451 | 56 |
void doRunTest(Result expectedResult, Predicate<String> validate, String... args) { |
31936 | 57 |
System.err.println("running with args: " + Arrays.asList(args)); |
58 |
List<String> options = new ArrayList<>(); |
|
59 |
options.addAll(Arrays.asList(args)); |
|
60 |
options.add("-XDrawDiagnostics"); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36526
diff
changeset
|
61 |
options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath()); |
31936 | 62 |
StringWriter out = new StringWriter(); |
63 |
PrintWriter pw = new PrintWriter(out); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
64 |
int actualResult = Main.execute(options.toArray(new String[0]), pw); |
31936 | 65 |
System.err.println("actual result=" + actualResult); |
66 |
System.err.println("actual output=" + out.toString()); |
|
41451 | 67 |
if (actualResult != expectedResult.exitCode) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36526
diff
changeset
|
68 |
throw new Error("Exit code not as expected"); |
31936 | 69 |
if (!validate.test(out.toString())) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36526
diff
changeset
|
70 |
throw new Error("Output not as expected"); |
31936 | 71 |
} |
72 |
} |
|
73 |
} |