ant-build-system: Add default "check" target.

* guix/build-system/ant.scm (ant-build): Change default test target to
"check"; add "test-dir" argument.
* guix/build/ant-build-system.scm (default-build.xml): Add "test-dir"
argument; add ant targets "compile-tests" and "check".
(configure): Add "test-dir" argument; pass it to "default-build.xml".
This commit is contained in:
Ricardo Wurmus 2016-10-17 19:32:14 +02:00
parent 8df64f7384
commit 52a791f50f
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC
2 changed files with 40 additions and 4 deletions

View File

@ -93,12 +93,13 @@
(define* (ant-build store name inputs (define* (ant-build store name inputs
#:key #:key
(tests? #t) (tests? #t)
(test-target "tests") (test-target "check")
(configure-flags ''()) (configure-flags ''())
(make-flags ''()) (make-flags ''())
(build-target "jar") (build-target "jar")
(jar-name #f) (jar-name #f)
(source-dir "src") (source-dir "src")
(test-dir "src/test")
(phases '(@ (guix build ant-build-system) (phases '(@ (guix build ant-build-system)
%standard-phases)) %standard-phases))
(outputs '("out")) (outputs '("out"))
@ -128,6 +129,7 @@
#:build-target ,build-target #:build-target ,build-target
#:jar-name ,jar-name #:jar-name ,jar-name
#:source-dir ,source-dir #:source-dir ,source-dir
#:test-dir ,test-dir
#:phases ,phases #:phases ,phases
#:outputs %outputs #:outputs %outputs
#:search-paths ',(map search-path-specification->sexp #:search-paths ',(map search-path-specification->sexp

View File

@ -36,7 +36,7 @@
;; Code: ;; Code:
(define* (default-build.xml jar-name prefix #:optional (define* (default-build.xml jar-name prefix #:optional
(source-dir ".")) (source-dir ".") (test-dir "./test"))
"Create a simple build.xml with standard targets for Ant." "Create a simple build.xml with standard targets for Ant."
(call-with-output-file "build.xml" (call-with-output-file "build.xml"
(lambda (port) (lambda (port)
@ -48,6 +48,10 @@
(value "${basedir}/build/jar"))) (value "${basedir}/build/jar")))
(property (@ (name "dist.dir") (property (@ (name "dist.dir")
(value ,prefix))) (value ,prefix)))
(property (@ (name "test.home")
(value ,test-dir)))
(property (@ (name "test.classes.dir")
(value "${basedir}/build/test-classes")))
;; respect the CLASSPATH environment variable ;; respect the CLASSPATH environment variable
(property (@ (name "build.sysclasspath") (property (@ (name "build.sysclasspath")
@ -63,6 +67,35 @@
(destdir "${classes.dir}") (destdir "${classes.dir}")
(classpath (@ (refid "classpath")))))) (classpath (@ (refid "classpath"))))))
(target (@ (name "compile-tests"))
(mkdir (@ (dir "${test.classes.dir}")))
(javac (@ (includeantruntime "false")
(srcdir ,test-dir)
(destdir "${test.classes.dir}"))
(classpath
(pathelement (@ (path "${env.CLASSPATH}")))
(pathelement (@ (location "${classes.dir}")))
(pathelement (@ (location "${test.classes.dir}"))))))
(target (@ (name "check")
(depends "compile-tests"))
(mkdir (@ (dir "${test.home}/test-reports")))
(junit (@ (printsummary "true")
(showoutput "true")
(fork "yes")
(haltonfailure "yes"))
(classpath
(pathelement (@ (path "${env.CLASSPATH}")))
(pathelement (@ (location "${test.home}/resources")))
(pathelement (@ (location "${classes.dir}")))
(pathelement (@ (location "${test.classes.dir}"))))
(formatter (@ (type "plain")
(usefile "true")))
(batchtest (@ (fork "yes")
(todir "${test.home}/test-reports"))
(fileset (@ (dir "${test.home}/java"))
(include (@ (name "**/*Test.java" )))))))
(target (@ (name "jar") (target (@ (name "jar")
(depends "compile")) (depends "compile"))
(mkdir (@ (dir "${jar.dir}"))) (mkdir (@ (dir "${jar.dir}")))
@ -99,12 +132,13 @@ to the default GNU unpack strategy."
((assq-ref gnu:%standard-phases 'unpack) #:source source))) ((assq-ref gnu:%standard-phases 'unpack) #:source source)))
(define* (configure #:key inputs outputs (jar-name #f) (define* (configure #:key inputs outputs (jar-name #f)
(source-dir "src") #:allow-other-keys) (source-dir "src")
(test-dir "src/test") #:allow-other-keys)
(when jar-name (when jar-name
(default-build.xml jar-name (default-build.xml jar-name
(string-append (assoc-ref outputs "out") (string-append (assoc-ref outputs "out")
"/share/java") "/share/java")
source-dir)) source-dir test-dir))
(setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
(setenv "CLASSPATH" (generate-classpath inputs))) (setenv "CLASSPATH" (generate-classpath inputs)))