langtools/test/tools/javac/modules/ModulePathTest.java
changeset 43771 25ddac537bb5
parent 42822 a84956e7ee4d
equal deleted inserted replaced
43770:a321bed02000 43771:25ddac537bb5
     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.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
       
    26  * @bug 8142968 8174104
    26  * @summary tests for --module-path
    27  * @summary tests for --module-path
    27  * @library /tools/lib
    28  * @library /tools/lib
    28  * @modules
    29  * @modules
    29  *      jdk.compiler/com.sun.tools.javac.api
    30  *      jdk.compiler/com.sun.tools.javac.api
    30  *      jdk.compiler/com.sun.tools.javac.main
    31  *      jdk.compiler/com.sun.tools.javac.main
    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 {