aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy6
-rw-r--r--src/main/groovy/frege/gradle/DefaultFregeSourceSet.java8
-rw-r--r--src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy26
-rw-r--r--src/main/groovy/frege/gradle/FregeSourceSet.java1
-rw-r--r--src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy30
-rw-r--r--src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy7
-rw-r--r--src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java5
-rw-r--r--src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy88
8 files changed, 124 insertions, 47 deletions
diff --git a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy
index 4142790..2acfa9d 100644
--- a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy
+++ b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy
@@ -29,9 +29,11 @@ class FregePluginIntegTest extends AbstractFregeIntegrationSpec {
"""
when:
- def result = run("classes")
+ def result = run(gradleVersion, "classes")
then:
result.task(":compileFrege").outcome == UP_TO_DATE
+ where:
+ gradleVersion << ["2.8", "2.11", "2.12"]
}
@Unroll
@@ -55,6 +57,8 @@ class FregePluginIntegTest extends AbstractFregeIntegrationSpec {
where:
fregeVersion | gradleVersion
+ DEFAULT_FREGE_VERSION | "2.12"
+ "3.22.367-g2737683" | "2.12"
DEFAULT_FREGE_VERSION | "2.9"
DEFAULT_FREGE_VERSION | "2.8"
"3.22.367-g2737683" | "2.9"
diff --git a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java b/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java
index 3a9bcfc..a1650a1 100644
--- a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java
+++ b/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java
@@ -2,18 +2,16 @@ package frege.gradle;
import groovy.lang.Closure;
import org.gradle.api.file.SourceDirectorySet;
-import org.gradle.api.internal.file.DefaultSourceDirectorySet;
-import org.gradle.api.internal.file.FileResolver;
import org.gradle.util.ConfigureUtil;
public class DefaultFregeSourceSet implements FregeSourceSet {
private final SourceDirectorySet frege;
private final SourceDirectorySet allFrege;
- public DefaultFregeSourceSet(String displayName, FileResolver fileResolver) {
- this.frege = new DefaultSourceDirectorySet(String.format("%s Frege source", new Object[]{displayName}), fileResolver);
+ public DefaultFregeSourceSet(String displayName, FregeSourceSetDirectoryFactory sourceSetFactory) {
+ this.frege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName}));
this.frege.getFilter().include(new String[]{"**/*.fr"});
- this.allFrege = new DefaultSourceDirectorySet(String.format("%s Frege source", new Object[]{displayName}), fileResolver);
+ this.allFrege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName}));
this.allFrege.source(this.frege);
this.allFrege.getFilter().include(new String[]{"**/*.fr"});
}
diff --git a/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy b/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy
new file mode 100644
index 0000000..35110f5
--- /dev/null
+++ b/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy
@@ -0,0 +1,26 @@
+package frege.gradle
+
+import org.gradle.api.file.FileTree
+import org.gradle.api.tasks.util.PatternFilterable
+
+interface FregeSourceDirectorySet extends PatternFilterable {
+ def String getName()
+
+ def FregeSourceDirectorySet srcDir(Object srcPath)
+
+ def FregeSourceDirectorySet srcDirs(Object... srcPaths)
+
+ def Set<File> getSrcDirs()
+
+ def FregeSourceDirectorySet setSrcDirs(Iterable<?> srcPaths)
+
+ def FileTree getFiles()
+
+ def PatternFilterable getFilter()
+
+ def FregeSourceSetOutputs getOutput()
+
+ def String getGeneratorTaskName()
+
+ boolean contains(File file)
+} \ No newline at end of file
diff --git a/src/main/groovy/frege/gradle/FregeSourceSet.java b/src/main/groovy/frege/gradle/FregeSourceSet.java
index 7540930..27654f1 100644
--- a/src/main/groovy/frege/gradle/FregeSourceSet.java
+++ b/src/main/groovy/frege/gradle/FregeSourceSet.java
@@ -4,4 +4,5 @@ import org.gradle.api.file.SourceDirectorySet;
public interface FregeSourceSet {
SourceDirectorySet getFrege();
+ SourceDirectorySet getAllFrege();
}
diff --git a/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy b/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy
new file mode 100644
index 0000000..96abc8f
--- /dev/null
+++ b/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy
@@ -0,0 +1,30 @@
+package frege.gradle
+
+import org.gradle.api.file.SourceDirectorySet
+import org.gradle.api.internal.file.DefaultSourceDirectorySet
+import org.gradle.api.internal.file.FileResolver
+import org.gradle.api.internal.file.SourceDirectorySetFactory
+import org.gradle.api.internal.project.ProjectInternal
+import org.gradle.util.GradleVersion
+
+public class FregeSourceSetDirectoryFactory {
+ private final boolean useFactory;
+ private final FileResolver fileResolver
+ private final ProjectInternal project
+
+ public FregeSourceSetDirectoryFactory(ProjectInternal project, FileResolver fileResolver) {
+ this.fileResolver = fileResolver
+ this.project = project
+ this.useFactory = GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0;
+
+ }
+
+ public SourceDirectorySet newSourceSetDirectory(String displayName) {
+ if (useFactory) {
+ SourceDirectorySetFactory factory = project.getServices().get(SourceDirectorySetFactory.class);
+ return factory.create(displayName);
+ } else {
+ return new DefaultSourceDirectorySet(displayName, fileResolver);
+ }
+ }
+}
diff --git a/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy b/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy
new file mode 100644
index 0000000..07e90a3
--- /dev/null
+++ b/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy
@@ -0,0 +1,7 @@
+package frege.gradle
+
+import org.gradle.api.file.FileCollection
+
+interface FregeSourceSetOutputs {
+ FileCollection getDirs()
+} \ No newline at end of file
diff --git a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
index 6d7a639..f45dae4 100644
--- a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
+++ b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
@@ -1,6 +1,7 @@
package frege.gradle.plugins;
import frege.gradle.DefaultFregeSourceSet;
+import frege.gradle.FregeSourceSetDirectoryFactory;
import frege.gradle.tasks.FregeCompile;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
@@ -8,6 +9,7 @@ import org.gradle.api.Project;
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.internal.file.FileResolver;
import org.gradle.api.internal.plugins.DslObject;
+import org.gradle.api.internal.project.ProjectInternal;
import org.gradle.api.internal.tasks.DefaultSourceSet;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPluginConvention;
@@ -44,7 +46,8 @@ public class FregeBasePlugin implements Plugin<Project> {
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(final SourceSet sourceSet) {
- final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver);
+ FregeSourceSetDirectoryFactory factory = new FregeSourceSetDirectoryFactory((ProjectInternal) project, fileResolver);
+ final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), factory);
new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet);
final String defaultSourcePath = String.format("src/%s/frege", sourceSet.getName());
diff --git a/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy b/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy
index cb7d5ef..e06236f 100644
--- a/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy
+++ b/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy
@@ -7,6 +7,42 @@ import org.gradle.process.internal.JavaExecAction
class FregeQuickCheck extends DefaultTask {
+ // more options to consider:
+/*
+ Looks up quick check predicates in the given modules and tests them.
+
+ [Usage:] java -cp fregec.jar frege.tools.Quick [ option ... ] modulespec ...
+
+ Options:
+
+ - -v print a line for each pedicate that passed
+ - -n num run _num_ tests per predicate, default is 100
+ - -p pred1,pred2,... only test the given predicates
+ - -x pred1,pred2,... do not test the given predicates
+ - -l just print the names of the predicates available.
+
+ Ways to specify modules:
+
+ - module the module name (e.g. my.great.Module), will be lookup up in
+ the current class path.
+ - dir/ A directory path. The directory is searched for class files,
+ and for each class files an attempt is made to load it as if
+ the given directory was in the class path. The directory must
+ be the root of the classes contained therein, otherwise the
+ classes won't get loaded.
+ - path-to.jar A jar or zip file is searched for class files, and for each
+ class file found an attempt is made to load it as if the
+ jar was in the class path.
+
+ The number of passed/failed tests is reported. If any test failed or other
+ errors occured, the exit code will be non zero.
+
+ The code will try to heat up your CPU by running tests on all available cores.
+ This should be faster on multi-core computers than running the tests
+ sequentially. It makes it feasable to run more tests per predicate.
+
+ */
+
Boolean verbose = true
Boolean listAvailable = false
Boolean help = false
@@ -14,9 +50,10 @@ class FregeQuickCheck extends DefaultTask {
List<String> includePredicates
List<String> excludePredicates
String moduleName
+ String moduleDirectory
String moduleJar
- String moduleDir = "$project.buildDir/classes/test"
List<String> classpathDirectories = ["$project.buildDir/classes/main", "$project.buildDir/classes/test"]
+ String moduleDir = "$project.buildDir/classes/test"
List<String> allJvmArgs = []
@TaskAction
@@ -33,50 +70,21 @@ class FregeQuickCheck extends DefaultTask {
def f = project.files(classpathDirectories.collect { s -> new File(s) })
action.setClasspath(project.files(project.configurations.compile).plus(project.files(project.configurations.testRuntime)).plus(f))
- def moduleSpec = moduleName ?: moduleJar ?: moduleDir
+
+ project.configurations.testRuntime.each { println it }
def args = []
if (help) {
- println """
-FregeQuickCheck Help
---------------------
-All attributes are optional,
-currently used moduleDir is '$moduleDir',
-currently used moduleSpec is '$moduleSpec'.
-
-Example attribute values:
-fregeQuickCheck {
- help = true // default: false
- listAvailable = true // default: false, will only list and not execute
- verbose = false // default: true, needed to see the results
- num = 500 // default: 100
- includePredicates = ['myFirstPred', 'mySecondPred']
- excludePredicates = ['myFirstPred', 'mySecondPred']
- moduleName = 'my.cool.Module' // prio 1
- moduleJar = 'path/to/my/module.jar' // prio 2
- moduleDir = "\$project.buildDir/classes/test" // prio 3, default
- classpathDirectories = ["\$project.buildDir/classes/main", "\$project.buildDir/classes/test"]
- allJvmArgs = ['-Xss4M']
-}
-"""
- println "Current Test Runtime is: "
- project.configurations.testRuntime.each { println it }
- }
-
- if (verbose) args << "-v"
- if (listAvailable) args << "-l"
- if (num) args << "-n" << num
- if (includePredicates) args << "-p" << includePredicates.join(',')
- if (excludePredicates) args << "-x" << excludePredicates.join(',')
- if (!allJvmArgs.isEmpty()) {
- action.setJvmArgs(allJvmArgs)
- }
- args << moduleSpec
- if (help) {
- println "Calling Frege QuickCheck with args: '${args.join(' ')}'"
- println "and JVM args: '${allJvmArgs.join(' ')}'"
+ } else {
+ if (verbose) args << "-v"
+ if (listAvailable) args << "-l"
+ if (!allJvmArgs.isEmpty()) {
+ action.setJvmArgs(allJvmArgs)
+ }
+ args = args + [moduleDir]
}
+ logger.info("Calling Frege QuickCheck with args: '$args'")
action.args args
action.execute()
}