test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java
changeset 52323 c306abfeae0d
parent 51182 b0fcf59be391
equal deleted inserted replaced
52322:3d33e20a5794 52323:c306abfeae0d
    30  *          jdk.compiler/com.sun.tools.javac.code
    30  *          jdk.compiler/com.sun.tools.javac.code
    31  *          jdk.compiler/com.sun.tools.javac.main
    31  *          jdk.compiler/com.sun.tools.javac.main
    32  *          jdk.compiler/com.sun.tools.javac.util
    32  *          jdk.compiler/com.sun.tools.javac.util
    33  *          jdk.jdeps/com.sun.tools.javap
    33  *          jdk.jdeps/com.sun.tools.javap
    34  * @build toolbox.ToolBox toolbox.JavacTask toolbox.TestRunner
    34  * @build toolbox.ToolBox toolbox.JavacTask toolbox.TestRunner
    35  * @run main OptionSmokeTest
    35  * @run main/othervm OptionSmokeTest
    36  */
    36  */
       
    37 
       
    38 import java.util.Locale;
    37 
    39 
    38 import java.nio.file.Path;
    40 import java.nio.file.Path;
    39 import java.nio.file.Paths;
    41 import java.nio.file.Paths;
    40 
    42 
    41 import com.sun.tools.javac.util.Assert;
    43 import com.sun.tools.javac.util.Assert;
    49 public class OptionSmokeTest extends TestRunner {
    51 public class OptionSmokeTest extends TestRunner {
    50     ToolBox tb = new ToolBox();
    52     ToolBox tb = new ToolBox();
    51 
    53 
    52     public OptionSmokeTest() {
    54     public OptionSmokeTest() {
    53         super(System.err);
    55         super(System.err);
       
    56         Locale.setDefault(Locale.US);
    54     }
    57     }
    55 
    58 
    56     protected void runTests() throws Exception {
    59     protected void runTests() throws Exception {
    57         runTests(m -> new Object[] { Paths.get(m.getName()) });
    60         runTests(m -> new Object[] { Paths.get(m.getName()) });
    58     }
    61     }
   115         doTestNoSource(base, "error: no source files", String.format("-target %s", Source.DEFAULT.name));
   118         doTestNoSource(base, "error: no source files", String.format("-target %s", Source.DEFAULT.name));
   116     }
   119     }
   117 
   120 
   118     @Test
   121     @Test
   119     public void requiresArg(Path base) throws Exception {
   122     public void requiresArg(Path base) throws Exception {
   120         doTestNoSource(base, "error: -target requires an argument", "-target");
   123         doTestNoSource(base, "error: --target requires an argument", "-target");
   121     }
   124     }
   122 
   125 
   123     @Test
   126     @Test
   124     public void invalidSource(Path base) throws Exception {
   127     public void invalidSource(Path base) throws Exception {
   125         doTestNoSource(base, "error: invalid source release: 999999", "-source 999999");
   128         doTestNoSource(base, "error: invalid source release: 999999", "-source 999999");
   207         Assert.check(log.startsWith("error: unmatched quote in environment variable JDK_JAVAC_OPTIONS"));
   210         Assert.check(log.startsWith("error: unmatched quote in environment variable JDK_JAVAC_OPTIONS"));
   208     }
   211     }
   209 
   212 
   210     @Test
   213     @Test
   211     public void optionCantBeUsedWithRelease(Path base) throws Exception {
   214     public void optionCantBeUsedWithRelease(Path base) throws Exception {
   212         doTestNoSource(base, "error: option -source cannot be used together with --release",
   215         doTestNoSource(base, "error: option --source cannot be used together with --release",
   213                 String.format("--release %s -source %s", Source.DEFAULT.name, Source.DEFAULT.name));
   216                 String.format("--release %s -source %s", Source.DEFAULT.name, Source.DEFAULT.name));
   214     }
   217     }
   215 
   218 
   216     @Test
   219     @Test
   217     public void releaseVersionNotSupported(Path base) throws Exception {
   220     public void releaseVersionNotSupported(Path base) throws Exception {
   230                 String.format("--release %s -Xbootclasspath/p:any", Source.DEFAULT.name));
   233                 String.format("--release %s -Xbootclasspath/p:any", Source.DEFAULT.name));
   231         doTestNoSource(base, "error: option -endorseddirs cannot be used together with --release",
   234         doTestNoSource(base, "error: option -endorseddirs cannot be used together with --release",
   232                 String.format("--release %s -endorseddirs any", Source.DEFAULT.name));
   235                 String.format("--release %s -endorseddirs any", Source.DEFAULT.name));
   233         doTestNoSource(base, "error: option -extdirs cannot be used together with --release",
   236         doTestNoSource(base, "error: option -extdirs cannot be used together with --release",
   234                 String.format("--release %s -extdirs any", Source.DEFAULT.name));
   237                 String.format("--release %s -extdirs any", Source.DEFAULT.name));
   235         doTestNoSource(base, "error: option -source cannot be used together with --release",
   238         doTestNoSource(base, "error: option --source cannot be used together with --release",
   236                 String.format("--release %s -source %s", Source.MIN.name, Source.DEFAULT.name));
   239                 String.format("--release %s -source %s", Source.MIN.name, Source.DEFAULT.name));
   237         doTestNoSource(base, "error: option -target cannot be used together with --release",
   240         doTestNoSource(base, "error: option --target cannot be used together with --release",
   238                 String.format("--release %s -target %s", Source.MIN.name, Source.DEFAULT.name));
   241                 String.format("--release %s -target %s", Source.MIN.name, Source.DEFAULT.name));
   239         doTestNoSource(base, "error: option --system cannot be used together with --release",
   242         doTestNoSource(base, "error: option --system cannot be used together with --release",
   240                 String.format("--release %s --system none", Source.DEFAULT.name));
   243                 String.format("--release %s --system none", Source.DEFAULT.name));
   241         doTestNoSource(base, "error: option --upgrade-module-path cannot be used together with --release",
   244         doTestNoSource(base, "error: option --upgrade-module-path cannot be used together with --release",
   242                 String.format("--release %s --upgrade-module-path any", Source.DEFAULT.name));
   245                 String.format("--release %s --upgrade-module-path any", Source.DEFAULT.name));