< prev index next >

test/tools/javac/modules/OutputDirTest.java

Print this page




  46         new OutputDirTest().run();
  47     }
  48 
  49     Path src;
  50 
  51     void run() throws Exception {
  52         tb = new ToolBox();
  53 
  54         src = Paths.get("src");
  55         tb.writeJavaFiles(src.resolve("m"),
  56                 "module m { }",
  57                 "package p; class C { }");
  58 
  59         runTests();
  60     }
  61 
  62     @Test
  63     public void testError(Path base) throws Exception {
  64         String log = new JavacTask(tb)
  65                 .options("-XDrawDiagnostics",
  66                         "-modulesourcepath", src.toString())
  67                 .files(findJavaFiles(src))
  68                 .run(Task.Expect.FAIL)
  69                 .writeAll()
  70                 .getOutput(Task.OutputKind.DIRECT);
  71 
  72         if (!log.contains("- compiler.err.no.output.dir"))
  73             throw new Exception("expected output not found");
  74     }
  75 
  76     @Test
  77     public void testProcOnly(Path base) throws IOException {
  78         new JavacTask(tb)
  79                 .options("-XDrawDiagnostics",
  80                         "-proc:only",
  81                         "-modulesourcepath", src.toString())
  82                 .files(findJavaFiles(src))
  83                 .run(Task.Expect.SUCCESS)
  84                 .writeAll();
  85     }
  86 
  87     @Test
  88     public void testClassOutDir(Path base) throws IOException {
  89         Path classes = base.resolve("classes");
  90         new JavacTask(tb)
  91                 .options("-XDrawDiagnostics",
  92                         "-d", classes.toString(),
  93                         "-modulesourcepath", src.toString())
  94                 .files(findJavaFiles(src))
  95                 .run(Task.Expect.SUCCESS)
  96                 .writeAll();
  97     }
  98 
  99     @Test
 100     public void testExplodedOutDir(Path base) throws Exception {
 101         Path modSrc = base.resolve("modSrc");
 102         tb.writeJavaFiles(modSrc,
 103                 "module m1 { exports p; }",
 104                 "package p; public class CC { }");
 105         Path modClasses = base.resolve("modClasses");
 106         Files.createDirectories(modClasses);
 107 
 108         new JavacTask(tb, Task.Mode.CMDLINE)
 109                 .outdir(modClasses)
 110                 .files(findJavaFiles(modSrc))
 111                 .run()
 112                 .writeAll();
 113 
 114         Path src = base.resolve("src");
 115         Path src_m = src.resolve("m");
 116         tb.writeJavaFiles(src_m,
 117                 "module m { requires m1 ; }",
 118                 "class C { }");
 119 
 120         String log = new JavacTask(tb, Task.Mode.CMDLINE)
 121                 .outdir(modClasses) // an exploded module
 122                 .options("-XDrawDiagnostics",
 123                         "-modulesourcepath", src.toString())
 124                 .files(findJavaFiles(src))
 125                 .run(Task.Expect.FAIL)
 126                 .writeAll()
 127                 .getOutput(Task.OutputKind.DIRECT);
 128 
 129         if (!log.contains("- compiler.err.multi-module.outdir.cannot.be.exploded.module: " + modClasses.toString()))
 130             throw new Exception("expected output not found");
 131     }
 132 
 133     @Test
 134     public void testInExplodedOutDir(Path base) throws Exception {
 135         Path modSrc = base.resolve("modSrc");
 136         tb.writeJavaFiles(modSrc,
 137                 "module m1 { exports p; }",
 138                 "package p; public class CC { }");
 139         Path modClasses = base.resolve("modClasses");
 140         Files.createDirectories(modClasses);
 141 
 142         new JavacTask(tb, Task.Mode.CMDLINE)
 143                 .outdir(modClasses)
 144                 .files(findJavaFiles(modSrc))
 145                 .run()
 146                 .writeAll();
 147 
 148         Path src = base.resolve("src");
 149         tb.writeJavaFiles(src,
 150                 "module m { requires m1 ; }",
 151                 "class C { }");
 152 
 153         Path classes = modClasses.resolve("m");
 154         Files.createDirectories(classes);
 155 
 156         String log = new JavacTask(tb, Task.Mode.CMDLINE)
 157                 .outdir(classes) // within an exploded module
 158                 .options("-XDrawDiagnostics",
 159                         "-Xlint", "-Werror",
 160                         "-modulepath", modClasses.toString())
 161                 .files(findJavaFiles(src))
 162                 .run(Task.Expect.FAIL)
 163                 .writeAll()
 164                 .getOutput(Task.OutputKind.DIRECT);
 165 
 166         if (!log.contains("- compiler.warn.outdir.is.in.exploded.module: " + classes.toString()))
 167             throw new Exception("expected output not found");
 168     }
 169 }


  46         new OutputDirTest().run();
  47     }
  48 
  49     Path src;
  50 
  51     void run() throws Exception {
  52         tb = new ToolBox();
  53 
  54         src = Paths.get("src");
  55         tb.writeJavaFiles(src.resolve("m"),
  56                 "module m { }",
  57                 "package p; class C { }");
  58 
  59         runTests();
  60     }
  61 
  62     @Test
  63     public void testError(Path base) throws Exception {
  64         String log = new JavacTask(tb)
  65                 .options("-XDrawDiagnostics",
  66                         "--module-source-path", src.toString())
  67                 .files(findJavaFiles(src))
  68                 .run(Task.Expect.FAIL)
  69                 .writeAll()
  70                 .getOutput(Task.OutputKind.DIRECT);
  71 
  72         if (!log.contains("- compiler.err.no.output.dir"))
  73             throw new Exception("expected output not found");
  74     }
  75 
  76     @Test
  77     public void testProcOnly(Path base) throws IOException {
  78         new JavacTask(tb)
  79                 .options("-XDrawDiagnostics",
  80                         "-proc:only",
  81                         "--module-source-path", src.toString())
  82                 .files(findJavaFiles(src))
  83                 .run(Task.Expect.SUCCESS)
  84                 .writeAll();
  85     }
  86 
  87     @Test
  88     public void testClassOutDir(Path base) throws IOException {
  89         Path classes = base.resolve("classes");
  90         new JavacTask(tb)
  91                 .options("-XDrawDiagnostics",
  92                         "-d", classes.toString(),
  93                         "--module-source-path", src.toString())
  94                 .files(findJavaFiles(src))
  95                 .run(Task.Expect.SUCCESS)
  96                 .writeAll();
  97     }
  98 
  99     @Test
 100     public void testExplodedOutDir(Path base) throws Exception {
 101         Path modSrc = base.resolve("modSrc");
 102         tb.writeJavaFiles(modSrc,
 103                 "module m1 { exports p; }",
 104                 "package p; public class CC { }");
 105         Path modClasses = base.resolve("modClasses");
 106         Files.createDirectories(modClasses);
 107 
 108         new JavacTask(tb, Task.Mode.CMDLINE)
 109                 .outdir(modClasses)
 110                 .files(findJavaFiles(modSrc))
 111                 .run()
 112                 .writeAll();
 113 
 114         Path src = base.resolve("src");
 115         Path src_m = src.resolve("m");
 116         tb.writeJavaFiles(src_m,
 117                 "module m { requires m1 ; }",
 118                 "class C { }");
 119 
 120         String log = new JavacTask(tb, Task.Mode.CMDLINE)
 121                 .outdir(modClasses) // an exploded module
 122                 .options("-XDrawDiagnostics",
 123                         "--module-source-path", src.toString())
 124                 .files(findJavaFiles(src))
 125                 .run(Task.Expect.FAIL)
 126                 .writeAll()
 127                 .getOutput(Task.OutputKind.DIRECT);
 128 
 129         if (!log.contains("- compiler.err.multi-module.outdir.cannot.be.exploded.module: " + modClasses.toString()))
 130             throw new Exception("expected output not found");
 131     }
 132 
 133     @Test
 134     public void testInExplodedOutDir(Path base) throws Exception {
 135         Path modSrc = base.resolve("modSrc");
 136         tb.writeJavaFiles(modSrc,
 137                 "module m1 { exports p; }",
 138                 "package p; public class CC { }");
 139         Path modClasses = base.resolve("modClasses");
 140         Files.createDirectories(modClasses);
 141 
 142         new JavacTask(tb, Task.Mode.CMDLINE)
 143                 .outdir(modClasses)
 144                 .files(findJavaFiles(modSrc))
 145                 .run()
 146                 .writeAll();
 147 
 148         Path src = base.resolve("src");
 149         tb.writeJavaFiles(src,
 150                 "module m { requires m1 ; }",
 151                 "class C { }");
 152 
 153         Path classes = modClasses.resolve("m");
 154         Files.createDirectories(classes);
 155 
 156         String log = new JavacTask(tb, Task.Mode.CMDLINE)
 157                 .outdir(classes) // within an exploded module
 158                 .options("-XDrawDiagnostics",
 159                         "-Xlint", "-Werror",
 160                         "--module-path", modClasses.toString())
 161                 .files(findJavaFiles(src))
 162                 .run(Task.Expect.FAIL)
 163                 .writeAll()
 164                 .getOutput(Task.OutputKind.DIRECT);
 165 
 166         if (!log.contains("- compiler.warn.outdir.is.in.exploded.module: " + classes.toString()))
 167             throw new Exception("expected output not found");
 168     }
 169 }
< prev index next >