aboutsummaryrefslogtreecommitdiff
path: root/src/main/groovy/frege/gradle/QuickCheckTask.groovy
diff options
context:
space:
mode:
authorMark Perry <maperry78@yahoo.com.au>2015-09-16 01:08:45 +1000
committerMark Perry <maperry78@yahoo.com.au>2015-09-16 01:08:45 +1000
commit492ec7d5a1856672800b51c898099678bb95ac62 (patch)
treed9faa96d33f93d01c4857416048fb8ebbfdc74dd /src/main/groovy/frege/gradle/QuickCheckTask.groovy
parent8204c2f65d11f1d4b862286d59f7081178a10d97 (diff)
downloadfrege-gradle-plugin-492ec7d5a1856672800b51c898099678bb95ac62.tar.gz
frege-gradle-plugin-492ec7d5a1856672800b51c898099678bb95ac62.tar.bz2
frege-gradle-plugin-492ec7d5a1856672800b51c898099678bb95ac62.zip
Added help and Frege package dir for compile task
Diffstat (limited to 'src/main/groovy/frege/gradle/QuickCheckTask.groovy')
-rw-r--r--src/main/groovy/frege/gradle/QuickCheckTask.groovy94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/main/groovy/frege/gradle/QuickCheckTask.groovy b/src/main/groovy/frege/gradle/QuickCheckTask.groovy
new file mode 100644
index 0000000..7da7924
--- /dev/null
+++ b/src/main/groovy/frege/gradle/QuickCheckTask.groovy
@@ -0,0 +1,94 @@
+package frege.gradle
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.internal.file.FileResolver
+import org.gradle.api.tasks.InputDirectory
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.TaskAction
+import org.gradle.process.internal.DefaultJavaExecAction
+import org.gradle.process.internal.JavaExecAction
+
+class QuickCheckTask 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
+ Integer num = 100
+ List<String> includePredicates
+ List<String> excludePredicates
+ String moduleName
+ String moduleDirectory
+ String moduleJar
+ List<String> classpathDirectories =
+ ["$project.buildDir/classes/main/"]
+// ["$project.buildDir/classes/main/", "$project.buildDir/classes/test/"]
+
+
+ @TaskAction
+ void runQuickCheck() {
+
+ FileResolver fileResolver = getServices().get(FileResolver.class)
+ JavaExecAction action = new DefaultJavaExecAction(fileResolver)
+ action.setMain("frege.tools.Quick")
+
+ action.standardInput = System.in
+ action.standardOutput = System.out
+ action.errorOutput = System.err
+
+ action.setClasspath(project.files(project.configurations.testRuntime))
+
+ project.configurations.testRuntime.each { println it }
+
+ def args = []
+ if (help) {
+
+ } else {
+ if (verbose) args << "-v"
+
+ args = args + classpathDirectories
+// args.action.args(classpathDirectories) // test all in build dir and below build/classes/test/
+
+
+ }
+
+ action.args args
+ action.execute()
+ }
+
+} \ No newline at end of file