This is an automated email from the ASF dual-hosted git repository. emilles pushed a commit to branch GROOVY_4_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push: new feb6dd2dd5 GROOVY-11666: add test case feb6dd2dd5 is described below commit feb6dd2dd5252695c611273f4148672191132146 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Thu Jul 17 13:34:32 2025 -0500 GROOVY-11666: add test case --- .../main/java/org/codehaus/groovy/ant/Groovyc.java | 75 ++++++++------------- .../org/codehaus/groovy/ant/GroovycTest.xml | 76 +++++++++++++--------- .../org/codehaus/groovy/ant/GroovycTest3.groovy | 26 ++++++++ .../codehaus/groovy/ant/GroovycTest3Peer.groovy | 25 +++++++ .../org/codehaus/groovy/ant/GroovycTest.java | 65 ++++++++++++++---- 5 files changed, 177 insertions(+), 90 deletions(-) diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 9aeb747db9..120d45cbfc 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -176,8 +176,8 @@ import java.util.StringTokenizer; */ public class Groovyc extends MatchingTask { - private static final File[] EMPTY_FILE_ARRAY = new File[0]; - private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final File[] EMPTY_FILE_ARRAY = {}; + private static final String[] EMPTY_STRING_ARRAY = {}; private final LoggingHelper log = new LoggingHelper(this); @@ -306,12 +306,7 @@ public class Groovyc extends MatchingTask { * @param version the bytecode compatibility level */ public void setTargetBytecode(String version) { - for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) { - if (allowedJdk.equals(version)) { - this.targetBytecode = version; - break; - } - } + targetBytecode = Arrays.asList(CompilerConfiguration.ALLOWED_JDKS).contains(version) ? version : null; } /** @@ -320,7 +315,7 @@ public class Groovyc extends MatchingTask { * @return bytecode compatibility level. Can be one of the values in {@link CompilerConfiguration#ALLOWED_JDKS}. */ public String getTargetBytecode() { - return this.targetBytecode; + return targetBytecode; } /** @@ -885,9 +880,8 @@ public class Groovyc extends MatchingTask { } compile(); - if (updatedProperty != null - && taskSuccess - && compileList.length != 0) { + + if (taskSuccess && compileList.length > 0 && updatedProperty != null) { getProject().setNewProperty(updatedProperty, "true"); } } @@ -909,21 +903,17 @@ public class Groovyc extends MatchingTask { * @param files An array of filenames */ protected void scanDir(File srcDir, File destDir, String[] files) { - GlobPatternMapper m = new GlobPatternMapper(); + GlobPatternMapper gpm = new GlobPatternMapper(); SourceFileScanner sfs = new SourceFileScanner(this); - File[] newFiles; for (String extension : getScriptExtensions()) { - m.setFrom("*." + extension); - m.setTo("*.class"); - newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); - addToCompileList(newFiles); + gpm.setFrom("*." + extension); + gpm.setTo("*.class"); + addToCompileList(sfs.restrictAsFiles(files, srcDir, destDir, gpm)); } - if (jointCompilation) { - m.setFrom("*.java"); - m.setTo("*.class"); - newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); - addToCompileList(newFiles); + gpm.setFrom("*.java"); + gpm.setTo("*.class"); + addToCompileList(sfs.restrictAsFiles(files, srcDir, destDir, gpm)); } } @@ -942,26 +932,20 @@ public class Groovyc extends MatchingTask { * @return the list of files as an array */ public File[] getFileList() { - return Arrays.copyOf(compileList, compileList.length); + return compileList.clone(); } protected void checkParameters() throws BuildException { - if (src == null) { - throw new BuildException("srcdir attribute must be set!", getLocation()); - } - if (src.size() == 0) { + if (src == null || src.isEmpty()) { throw new BuildException("srcdir attribute must be set!", getLocation()); } if (destDir != null && !destDir.isDirectory()) { - throw new BuildException("destination directory \"" - + destDir - + "\" does not exist or is not a directory", - getLocation()); + throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", getLocation()); } if (encoding != null && !Charset.isSupported(encoding)) { - throw new BuildException("encoding \"" + encoding + "\" not supported."); + throw new BuildException("encoding \"" + encoding + "\" not supported.", getLocation()); } } @@ -1028,14 +1012,10 @@ public class Groovyc extends MatchingTask { || key.equals("release") || key.equals("source") || key.equals("target")) { - switch (key) { - case "nativeheaderdir": - key = "h"; - break; - case "release": - key = "-" + key; // to get "--" when passed to javac - break; - default: + if (key.equals("nativeheaderdir")) { + key = "h"; + } else if (key.equals("release")) { + key = "-" + key; // to get "--" when passed to javac } // map "depend", "encoding", etc. to "-Jkey=val" jointOptions.add("-J" + key + "=" + getProject().replaceProperties(e.getValue().toString())); @@ -1129,7 +1109,7 @@ public class Groovyc extends MatchingTask { if (targetBytecode != null) { commandLineList.add("-Dgroovy.target.bytecode=" + targetBytecode); } - if (!"*.groovy".equals(getScriptExtension())) { + if (!getScriptExtension().equals("*.groovy")) { String tmpExtension = getScriptExtension(); if (tmpExtension.startsWith("*.")) tmpExtension = tmpExtension.substring(1); @@ -1182,7 +1162,7 @@ public class Groovyc extends MatchingTask { * @param classpath */ private void doNormalCommandLineList(List<String> commandLineList, List<String> jointOptions, Path classpath) { - if (!fork) { + if (!fork && !classpath.isEmpty()) { commandLineList.add("--classpath"); commandLineList.add(classpath.toString()); } @@ -1291,8 +1271,7 @@ public class Groovyc extends MatchingTask { // hand crank it so we can add our own compiler configuration try { FileSystemCompiler.CompilationOptions options = new FileSystemCompiler.CompilationOptions(); - CommandLine parser = FileSystemCompiler.configureParser(options); - parser.parseArgs(commandLine); + FileSystemCompiler.configureParser(options).parseArgs(commandLine); configuration = options.toCompilerConfiguration(); configuration.setScriptExtensions(getScriptExtensions()); String tmpExtension = getScriptExtension(); @@ -1303,7 +1282,7 @@ public class Groovyc extends MatchingTask { configuration.setTargetBytecode(targetBytecode); } - // Load the file name list + // load the file name list String[] fileNames = options.generateFileNames(); boolean fileNameErrors = (fileNames == null || !FileSystemCompiler.validateFiles(fileNames)); if (!fileNameErrors) { @@ -1410,7 +1389,7 @@ public class Groovyc extends MatchingTask { ClassLoader loader = getClass().getClassLoader(); if (loader instanceof AntClassLoader) { - AntClassLoader antLoader = (AntClassLoader) loader; + @SuppressWarnings("resource") AntClassLoader antLoader = (AntClassLoader) loader; String[] pathElm = antLoader.getClasspath().split(File.pathSeparator, -1); List<String> classpath = configuration.getClasspath(); /* @@ -1441,7 +1420,7 @@ public class Groovyc extends MatchingTask { } } - @SuppressWarnings("removal") // TODO a future Groovy version should perform the operation not as a privileged action + @SuppressWarnings("removal") // TODO: a future Groovy version should perform the operation not as a privileged action GroovyClassLoader groovyLoader = java.security.AccessController.doPrivileged((PrivilegedAction<GroovyClassLoader>) () -> new GroovyClassLoader(loader, configuration)); diff --git a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml index b5fb7011f8..177ca5d106 100644 --- a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml +++ b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml @@ -22,7 +22,7 @@ <project name="Test Groovyc Task"> - <property name="srcPath" location="."/> + <property name="srcPath" location="../../../.."/><!-- aka test-resources --> <property name="destPath" location="${user.dir}/build/classes/groovy/test"/> <path id="groovyMaterials"> @@ -43,59 +43,59 @@ <target name="GroovycTest1_NoFork_NoClasspath"> - <compile-plain includes="GroovycTest1.groovy"/> + <compile-plain includes="**/GroovycTest1.groovy"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_NoFork_WithGroovyClasspath"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_NoFork_WithJavaClasspath"> - <compile-plain includes="GroovycTest1.groovy"/> + <compile-plain includes="**/GroovycTest1.groovy"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_NoFork_WithBothClasspath"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_ForkGroovy_NoClasspath"> - <compile-plain includes="GroovycTest1.groovy" fork="true"/> + <compile-plain includes="**/GroovycTest1.groovy" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_ForkGroovy_WithGroovyClasspath"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials" fork="true"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_ForkGroovy_WithJavaClasspath"> - <compile-plain includes="GroovycTest1.groovy" fork="true"/> + <compile-plain includes="**/GroovycTest1.groovy" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_ForkGroovy_WithBothClasspath"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials" fork="true"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_Joint_NoFork_NoClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovyTest2.java"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovyTest2.java"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> <java classname="org.codehaus.groovy.ant.GroovycTest2"/> </target> <target name="GroovycTest1_Joint_NoFork_WithGroovyClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" classpathref="groovyMaterials"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> <java classname="org.codehaus.groovy.ant.GroovycTest2"/> </target> <target name="Groovyc_Joint_NoFork_NestedCompilerArg_WithGroovyClasspath"> - <compile-joint includes="IncorrectGenericsUsage.java" classpathref="groovyMaterials"> + <compile-joint includes="**/IncorrectGenericsUsage.java" classpathref="groovyMaterials"> <javac> <compilerarg value="-Xlint"/> </javac> @@ -103,67 +103,67 @@ </target> <target name="GroovycTest1_Joint_NoFork_WithJavaClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_Joint_NoFork_WithBothClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" classpathref="groovyMaterials"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_Joint_ForkGroovy_NoClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> <java classname="org.codehaus.groovy.ant.GroovycTest2"/> </target> <target name="GroovycTest1_Joint_ForkGroovy_WithGroovyClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" fork="true" classpathref="groovyMaterials"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" fork="true" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> <java classname="org.codehaus.groovy.ant.GroovycTest2"/> </target> <target name="GroovycTest1_Joint_ForkGroovy_WithJavaClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" fork="true"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_Joint_ForkGroovy_WithBothClasspath"> - <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java" fork="true" classpathref="groovyMaterials"/> + <compile-joint includes="**/GroovycTest1.groovy,**/GroovycTest2.java" fork="true" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> <java classname="org.codehaus.groovy.ant.GroovycTest2" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_ForkGroovy_NoClasspath_WithJavaHome"> - <compile-plain includes="GroovycTest1.groovy" fork="true" javahome="${alt.java.home}"/> + <compile-plain includes="**/GroovycTest1.groovy" fork="true" javahome="${alt.java.home}"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_ForkGroovy_WithGroovyClasspath_WithJavaHome"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> <target name="GroovycTest1_ForkGroovy_WithJavaClasspath_WithJavaHome"> - <compile-plain includes="GroovycTest1.groovy" fork="true" javahome="${alt.java.home}"/> + <compile-plain includes="**/GroovycTest1.groovy" fork="true" javahome="${alt.java.home}"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_ForkGroovy_WithBothClasspath_WithJavaHome"> - <compile-plain includes="GroovycTest1.groovy" classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/> + <compile-plain includes="**/GroovycTest1.groovy" classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/> <java classname="org.codehaus.groovy.ant.GroovycTest1" classpathref="groovyMaterials"/> </target> <target name="GroovycTest1_ForkGroovy_NoClasspath_Fail"> - <compile-plain includes="GroovyTestBad1.groovy" fork="true"/> + <compile-plain includes="**/GroovyTestBad1.groovy" fork="true"/> </target> <target name="noForkNoAntRuntime"> - <compile-plain includes="GroovycTest1.groovy" fork="false" includeAntRuntime="false"/> + <compile-plain includes="**/GroovycTest1.groovy" fork="false" includeAntRuntime="false"/> </target> <!-- GROOVY-9197 --> @@ -173,7 +173,7 @@ <fileset file="commons-lang3-3.4.jar"/> </path> - <compile-joint fork="true" includeantruntime="false" includes="MakesExternalReference.java"> + <compile-joint fork="true" includeantruntime="false" includes="**/MakesExternalReference.java"> <classpath refid="the.classpath"/> </compile-joint> @@ -182,7 +182,7 @@ <!-- GROOVY-11573 --> <target name="jointForkedCompilation_ParameterMetadataCheck"> - <compile-joint fork="true" configscript="params.groovy" includes="ParameterMetadataCheck.java"/> + <compile-joint fork="true" configscript="params.groovy" includes="**/ParameterMetadataCheck.java"/> <java classname="org.codehaus.groovy.ant.ParameterMetadataCheck"/> </target> @@ -191,21 +191,39 @@ <groovyc destdir="${destPath}" fork="true"> <src> <fileset dir="${srcPath}"> - <include name="GroovycTest*.*"/> - <exclude name="GroovycTest.xml"/> - <exclude name="GroovycTest2.java"/> + <include name="**/GroovycTest*.*"/> + <exclude name="**/GroovycTest.xml"/> + <exclude name="**/GroovycTest2.java"/> </fileset> </src> </groovyc> <java classname="org.codehaus.groovy.ant.GroovycTest1"/> </target> + <!-- GROOVY-11666 --> + <target name="incrementalCompilation"> + <compile-plain includes="**/GroovycTest3*.groovy"/> + + <local name="boo"/> + <compile-plain includes="**/GroovycTest3.groovy" updatedProperty="boo"/> + <fail if="boo" message="GroovycTest3.groovy was re-compiled"/> + + <touch file="GroovycTest3.groovy"/> + + <local name="yay"/> + <compile-plain includes="**/GroovycTest3.groovy" updatedProperty="yay"/> + <fail unless="yay" message="GroovycTest3.groovy was not re-compiled"/> + + <java classname="org.codehaus.groovy.ant.GroovycTest3"/> + </target> + <target name="clean"> <delete quiet="true"> <fileset dir="${destPath}/org/codehaus/groovy/ant"> <include name="*_Result.txt"/> <include name="GroovycTest1*.class"/> <include name="GroovycTest2*.class"/> + <include name="GroovycTest3*.class"/> <include name="IncorrectGenericsUsage.class"/> <include name="MakesExternalReference.class"/> <include name="ParameterMetadataCheck.class"/> diff --git a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3.groovy b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3.groovy new file mode 100644 index 0000000000..486a47c8fd --- /dev/null +++ b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3.groovy @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.codehaus.groovy.ant + +class GroovycTest3 { + static main(args) { + def file = new File("build/classes/groovy/test/${getCanonicalName().replace('.','/')}_Result.txt") + file.write(new GroovycTest3Peer().OK) + } +} diff --git a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3Peer.groovy b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3Peer.groovy new file mode 100644 index 0000000000..66e30d0386 --- /dev/null +++ b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest3Peer.groovy @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.codehaus.groovy.ant + +import groovy.transform.PackageScope + +class GroovycTest3Peer { + @PackageScope String OK = 'OK.' +} diff --git a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java index 5714c711d9..8f9ab165f1 100644 --- a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java +++ b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java @@ -18,10 +18,11 @@ */ package org.codehaus.groovy.ant; -import groovy.test.GroovyTestCase; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; +import org.junit.Before; +import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,6 +37,10 @@ import java.nio.file.Paths; import java.util.regex.Pattern; import static groovy.test.GroovyAssert.isAtLeastJdk; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeFalse; /** * Unit tests for the {@link Groovyc} ant task. @@ -44,14 +49,14 @@ import static groovy.test.GroovyAssert.isAtLeastJdk; * since that would ruin the whole point of testing compilation by the Ant tasks. In fact it doesn't * matter as the tests remove all class files that should not pre-exist from this directory at each step. */ -public class GroovycTest extends GroovyTestCase { +public final class GroovycTest { private final File antFile = new File("src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml"); private Project project; private static boolean warned = false; - @Override - protected void setUp() { + @Before + public void setUp() { project = new Project(); project.init(); ProjectHelper.getProjectHelper().parse(project, antFile); @@ -187,52 +192,63 @@ public class GroovycTest extends GroovyTestCase { //-------------------------------------------------------------------------- + @Test public void testGroovycTest1_NoFork_NoClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_NoFork_NoClasspath"); } + @Test public void testGroovycTest1_NoFork_WithGroovyClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_NoFork_WithGroovyClasspath"); } + @Test public void testGroovycTest1_NoFork_WithJavaClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_NoFork_WithJavaClasspath"); } + @Test public void testGroovycTest1_NoFork_WithBothClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_NoFork_WithBothClasspath"); } + @Test public void testGroovycTest1_ForkGroovy_NoClasspath() { ensureExecutes("GroovycTest1_ForkGroovy_NoClasspath"); } + @Test public void testGroovycTest1_ForkGroovy_WithGroovyClasspath() { ensureExecutes("GroovycTest1_ForkGroovy_WithGroovyClasspath"); } + @Test public void testGroovycTest1_ForkGroovy_WithJavaClasspath() { ensureExecutes("GroovycTest1_ForkGroovy_WithJavaClasspath"); } + @Test public void testGroovycTest1_ForkGroovy_WithBothClasspath() { ensureExecutes("GroovycTest1_ForkGroovy_WithBothClasspath"); } + @Test public void testGroovycTest1_Joint_NoFork_NoClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_Joint_NoFork_NoClasspath"); } + @Test public void testGroovycTest1_Joint_NoFork_WithGroovyClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_Joint_NoFork_WithGroovyClasspath"); } + @Test public void testGroovyc_Joint_NoFork_NestedCompilerArg_WithGroovyClasspath() { // capture ant's output so we can verify the effect of passing compilerarg to javac ByteArrayOutputStream allOutput = new ByteArrayOutputStream(); @@ -255,57 +271,70 @@ public class GroovycTest extends GroovyTestCase { } } + @Test public void testGroovycTest1_Joint_NoFork_WithJavaClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_Joint_NoFork_WithJavaClasspath"); } + @Test public void testGroovycTest1_Joint_NoFork_WithBothClasspath() { - if (isAtLeastJdk("18.0")) return; // GROOVY-10479 + assumeFalse(isAtLeastJdk("18.0")); // GROOVY-10479 ensureExecutes("GroovycTest1_Joint_NoFork_WithBothClasspath"); } + @Test public void testGroovycTest1_Joint_ForkGroovy_NoClasspath() { ensureExecutes("GroovycTest1_Joint_ForkGroovy_NoClasspath"); } + @Test public void testGroovycTest1_Joint_ForkGroovy_WithGroovyClasspath() { ensureExecutes("GroovycTest1_Joint_ForkGroovy_WithGroovyClasspath"); } + @Test public void testGroovycTest1_Joint_ForkGroovy_WithJavaClasspath() { ensureExecutes("GroovycTest1_Joint_ForkGroovy_WithJavaClasspath"); } + @Test public void testGroovycTest1_Joint_ForkGroovy_WithBothClasspath() { ensureExecutes("GroovycTest1_Joint_ForkGroovy_WithBothClasspath"); } + @Test public void testGroovycTest1_ForkGroovy_NoClasspath_WithJavaHome() { ensureExecutesWithJavaHome("GroovycTest1_ForkGroovy_NoClasspath_WithJavaHome"); } + @Test public void testGroovycTest1_ForkGroovy_WithGroovyClasspath_WithJavaHome() { ensureExecutesWithJavaHome("GroovycTest1_ForkGroovy_WithGroovyClasspath_WithJavaHome"); } + @Test public void testGroovycTest1_ForkGroovy_WithJavaClasspath_WithJavaHome() { ensureExecutesWithJavaHome("GroovycTest1_ForkGroovy_WithJavaClasspath_WithJavaHome"); } + @Test public void testGroovycTest1_ForkGroovy_WithBothClasspath_WithJavaHome() { ensureExecutesWithJavaHome("GroovycTest1_ForkGroovy_WithBothClasspath_WithJavaHome"); } + @Test public void testGroovycTest1_ForkGroovy_NoClasspath_Fail() { ensureFails("GroovycTest1_ForkGroovy_NoClasspath_Fail"); } + @Test public void testNoForkWithNoIncludeAntRuntime() { ensureFails("noForkNoAntRuntime"); } // GROOVY-9197 + @Test public void testJointCompilationPropagatesClasspath() { ensureNotPresent("MakesExternalReference"); project.executeTarget("jointForkedCompilation_ExternalJarOnClasspath"); @@ -313,6 +342,7 @@ public class GroovycTest extends GroovyTestCase { } // GROOVY-11573 + @Test public void testJointCompilationPropagatesParameters() throws Exception { ensureNotPresent("ParameterMetadataCheck"); project.executeTarget("jointForkedCompilation_ParameterMetadataCheck"); @@ -324,8 +354,17 @@ public class GroovycTest extends GroovyTestCase { } // GROOVY-11607 - public void testPlainForkedCompilation_NestingSrcElementCheck() { + @Test + public void testPlainCompilationWithNestedSrcElement() { ensureExecutes("plainForkedCompilation_NestingSrcElementCheck"); ensureNotPresent("GroovycTest2"); // excluded from src > fileset } + + // GROOVY-11666 + @Test + public void testRestrictionForIncrementalCompilation() { + ensureNotPresent("GroovycTest3"); + project.executeTarget("incrementalCompilation"); + ensureResultOK("GroovycTest3"); + } }