From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d76K7-0005ef-94 for guix-patches@gnu.org; Sat, 06 May 2017 16:29:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d76K6-0000Fn-6s for guix-patches@gnu.org; Sat, 06 May 2017 16:29:03 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:60398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d76K6-0000Fh-2g for guix-patches@gnu.org; Sat, 06 May 2017 16:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d76K5-0001Hx-Qa for guix-patches@gnu.org; Sat, 06 May 2017 16:29:01 -0400 Subject: bug#26803: [PATCH 02/36] ant-build-system: Add default "check" target. Resent-Message-ID: References: <20170506153617.3074-1-rekado@elephly.net> <20170506153617.3074-2-rekado@elephly.net> From: Roel Janssen In-reply-to: <20170506153617.3074-2-rekado@elephly.net> Date: Sat, 06 May 2017 22:28:36 +0200 Message-ID: <87r301k9vv.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ricardo Wurmus Cc: 26803@debbugs.gnu.org Ricardo Wurmus writes: > * 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". > --- > guix/build-system/ant.scm | 4 +++- > guix/build/ant-build-system.scm | 40 +++++++++++++++++++++++++++++++++++++--- > 2 files changed, 40 insertions(+), 4 deletions(-) > > diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm > index a309a0c86..bf2f3b411 100644 > --- a/guix/build-system/ant.scm > +++ b/guix/build-system/ant.scm > @@ -93,12 +93,13 @@ > (define* (ant-build store name inputs > #:key > (tests? #t) > - (test-target "tests") > + (test-target "check") > (configure-flags ''()) > (make-flags ''()) > (build-target "jar") > (jar-name #f) > (source-dir "src") > + (test-dir "src/test") > (phases '(@ (guix build ant-build-system) > %standard-phases)) > (outputs '("out")) Is this only for 'build.xml' files generated by the ant-build-system? I'm not sure whether there is a consensus within the Java world about the name of a test phase. I think 'check' would be good, because it is consistent with other build systems within Guix. So.. long story short, it looks good to me. > @@ -128,6 +129,7 @@ > #:build-target ,build-target > #:jar-name ,jar-name > #:source-dir ,source-dir > + #:test-dir ,test-dir > #:phases ,phases > #:outputs %outputs > #:search-paths ',(map search-path-specification->sexp > diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm > index 8ec7a9486..4042630a1 100644 > --- a/guix/build/ant-build-system.scm > +++ b/guix/build/ant-build-system.scm > @@ -36,7 +36,7 @@ > ;; Code: > > (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." > (call-with-output-file "build.xml" > (lambda (port) > @@ -48,6 +48,10 @@ > (value "${basedir}/build/jar"))) > (property (@ (name "dist.dir") > (value ,prefix))) > + (property (@ (name "test.home") > + (value ,test-dir))) > + (property (@ (name "test.classes.dir") > + (value "${basedir}/build/test-classes"))) > > ;; respect the CLASSPATH environment variable > (property (@ (name "build.sysclasspath") > @@ -63,6 +67,35 @@ > (destdir "${classes.dir}") > (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") > (depends "compile")) > (mkdir (@ (dir "${jar.dir}"))) Cool! > @@ -99,12 +132,13 @@ to the default GNU unpack strategy." > ((assq-ref gnu:%standard-phases 'unpack) #:source source))) > > (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 > (default-build.xml jar-name > (string-append (assoc-ref outputs "out") > "/share/java") > - source-dir)) > + source-dir test-dir)) > (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) > (setenv "CLASSPATH" (generate-classpath inputs))) LGTM. Thanks a lot for this! Kind regards, Roel Janssen