From 6495c28ac9ff94980a635042c0600b38d3ede849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kohlschu=CC=88tter?= Date: Fri, 6 Oct 2023 19:16:15 +0200 Subject: [PATCH] test: Fix tests that spawn new processes Some tests try to spawn a new Java process for the JSweetCommandLineLauncher. These tests fail with new Java versions >= 16. Specify --add-opens=jdk.compiler/... statements to allow our code to access the Java Compiler packages under com.sun.tools.javac... --- .../test/transpiler/TranspilerTests.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/transpiler/src/test/java/org/jsweet/test/transpiler/TranspilerTests.java b/transpiler/src/test/java/org/jsweet/test/transpiler/TranspilerTests.java index 6f446f5ad..388b946e2 100644 --- a/transpiler/src/test/java/org/jsweet/test/transpiler/TranspilerTests.java +++ b/transpiler/src/test/java/org/jsweet/test/transpiler/TranspilerTests.java @@ -93,6 +93,10 @@ public void testCommandLine() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--targetVersion", "ES6", // @@ -118,6 +122,10 @@ public void testCommandLine() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), // @@ -143,6 +151,10 @@ public void testCommandLine() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), // @@ -161,6 +173,10 @@ public void testCommandLine() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), // @@ -178,6 +194,10 @@ public void testCommandLine() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), // @@ -204,6 +224,10 @@ public void testCommandLineSuccess() { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), // @@ -228,6 +252,10 @@ public void testErroneousCommandLineArgument() throws Throwable { process = ProcessUtil.runCommand("java", line -> { System.out.println(line); }, null, "-cp", TranspilerTestRunner.getTestClassPath(), // + "--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", JSweetCommandLineLauncher.class.getName(), // "--tsout", outDir.getPath(), // "--jsout", outDir.getPath(), //