Skip to content
Snippets Groups Projects
Unverified Commit f403d7ab authored by Julien Lepiller's avatar Julien Lepiller
Browse files

guix: ant-build-system: Add #:test-include and #:test-exclude arguments.

* guix/build-system/ant.scm: Add #:test-include and #:test-exclude
arguments.
* guix/build/ant-build-system.scm: Generate test list from arguments.
* doc/guix.texi (Build Systems): Document it.
parent 8df1faa0
No related branches found
No related tags found
No related merge requests found
...@@ -3481,7 +3481,11 @@ specify the source sub-directory, defaulting to ``src''. ...@@ -3481,7 +3481,11 @@ specify the source sub-directory, defaulting to ``src''.
   
The @code{#:main-class} parameter can be used with the minimal ant The @code{#:main-class} parameter can be used with the minimal ant
buildfile to specify the main class of the resulting jar. This makes the buildfile to specify the main class of the resulting jar. This makes the
jar file executable. jar file executable. The @code{#:test-include} parameter can be used to
specify the list of junit tests to run. It defaults to
@code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
disable some tests. It defaults to @code{(list "**/Abstract*.java")},
because abstract classes cannot be run as tests.
   
The parameter @code{#:build-target} can be used to specify the Ant task The parameter @code{#:build-target} can be used to specify the Ant task
that should be run during the @code{build} phase. By default the that should be run during the @code{build} phase. By default the
......
...@@ -100,6 +100,8 @@ (define* (ant-build store name inputs ...@@ -100,6 +100,8 @@ (define* (ant-build store name inputs
(build-target "jar") (build-target "jar")
(jar-name #f) (jar-name #f)
(main-class #f) (main-class #f)
(test-include (list "**/*Test.java"))
(test-exclude (list "**/Abstract*.java"))
(source-dir "src") (source-dir "src")
(test-dir "src/test") (test-dir "src/test")
(phases '(@ (guix build ant-build-system) (phases '(@ (guix build ant-build-system)
...@@ -132,6 +134,8 @@ (define builder ...@@ -132,6 +134,8 @@ (define builder
#:build-target ,build-target #:build-target ,build-target
#:jar-name ,jar-name #:jar-name ,jar-name
#:main-class ,main-class #:main-class ,main-class
#:test-include (list ,@test-include)
#:test-exclude (list ,@test-exclude)
#:source-dir ,source-dir #:source-dir ,source-dir
#:test-dir ,test-dir #:test-dir ,test-dir
#:phases ,phases #:phases ,phases
......
...@@ -36,7 +36,9 @@ (define-module (guix build ant-build-system) ...@@ -36,7 +36,9 @@ (define-module (guix build ant-build-system)
;; Code: ;; Code:
(define* (default-build.xml jar-name prefix #:optional (define* (default-build.xml jar-name prefix #:optional
(source-dir ".") (test-dir "./test") (main-class #f)) (source-dir ".") (test-dir "./test") (main-class #f)
(test-include '("**/*Test.java"))
(test-exclude '("**/Abstract*Test.java")))
"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)
...@@ -109,7 +111,12 @@ (define* (default-build.xml jar-name prefix #:optional ...@@ -109,7 +111,12 @@ (define* (default-build.xml jar-name prefix #:optional
(batchtest (@ (fork "yes") (batchtest (@ (fork "yes")
(todir "${test.home}/test-reports")) (todir "${test.home}/test-reports"))
(fileset (@ (dir "${test.home}/java")) (fileset (@ (dir "${test.home}/java"))
(include (@ (name "**/*Test.java" ))))))) ,@(map (lambda (file)
`(include (@ (name ,file))))
test-include)
,@(map (lambda (file)
`(exclude (@ (name ,file))))
test-exclude)))))
(target (@ (name "jar") (target (@ (name "jar")
(depends "compile, manifest")) (depends "compile, manifest"))
...@@ -150,12 +157,14 @@ (define* (unpack #:key source #:allow-other-keys) ...@@ -150,12 +157,14 @@ (define* (unpack #:key source #:allow-other-keys)
(define* (configure #:key inputs outputs (jar-name #f) (define* (configure #:key inputs outputs (jar-name #f)
(source-dir "src") (source-dir "src")
(test-dir "src/test") (test-dir "src/test")
(main-class #f) #:allow-other-keys) (main-class #f)
(test-include '("**/*Test.java"))
(test-exclude '("**/Abstract*.java")) #: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 test-dir main-class)) source-dir test-dir main-class test-include test-exclude))
(setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
(setenv "CLASSPATH" (generate-classpath inputs))) (setenv "CLASSPATH" (generate-classpath inputs)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment