Archived
1
0
Fork 0

build: julia-build-system: Add support for parallel tests.

The tests are defined by the script 'test/runtests.jl' from packages and the
parallelism depends on the implementation of this script.  Therefore, 'julia'
is launched using local worker processes accordingly with 'parallel?'.

* guix/build/julia-build-system.scm (check): Set the JULIA_CPU_THREADS
environment variable and invoke julia with the '--procs' option.
* guix/build-system/julia.scm (julia-build)[parallel-tests?]: New argument.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
zimoun 2021-11-25 02:24:43 +01:00 committed by Maxim Cournoyer
parent 6312c68f70
commit 905b090582
No known key found for this signature in database
GPG key ID: 1260E46482E63562
2 changed files with 11 additions and 1 deletions

View file

@ -2,6 +2,7 @@
;;; Copyright © 2019 Nicolò Balzarotti <nicolo@nixo.xyz> ;;; Copyright © 2019 Nicolò Balzarotti <nicolo@nixo.xyz>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me> ;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -79,6 +80,7 @@
(define* (julia-build name inputs (define* (julia-build name inputs
#:key source #:key source
(tests? #t) (tests? #t)
(parallel-tests? #t)
(phases '%standard-phases) (phases '%standard-phases)
(outputs '("out")) (outputs '("out"))
(search-paths '()) (search-paths '())
@ -98,6 +100,7 @@
#:source #+source #:source #+source
#:system #$system #:system #$system
#:tests? #$tests? #:tests? #$tests?
#:parallel-tests? #$parallel-tests?
#:phases #$phases #:phases #$phases
#:outputs #$(outputs->gexp outputs) #:outputs #$(outputs->gexp outputs)
#:search-paths '#$(sexp->gexp #:search-paths '#$(sexp->gexp

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Nicolò Balzarotti <nicolo@nixo.xyz> ;;; Copyright © 2019, 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me> ;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -103,11 +104,15 @@ Project.toml)."
#t) #t)
(define* (check #:key tests? source inputs outputs julia-package-name (define* (check #:key tests? source inputs outputs julia-package-name
parallel-tests?
#:allow-other-keys) #:allow-other-keys)
(when tests? (when tests?
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(package (or julia-package-name (project.toml->name "Project.toml"))) (package (or julia-package-name (project.toml->name "Project.toml")))
(builddir (string-append out "/share/julia/"))) (builddir (string-append out "/share/julia/"))
(jobs (if parallel-tests?
(number->string (parallel-job-count))
"1")))
;; With a patch, SOURCE_DATE_EPOCH is honored ;; With a patch, SOURCE_DATE_EPOCH is honored
(setenv "SOURCE_DATE_EPOCH" "1") (setenv "SOURCE_DATE_EPOCH" "1")
(setenv "JULIA_DEPOT_PATH" builddir) (setenv "JULIA_DEPOT_PATH" builddir)
@ -115,8 +120,10 @@ Project.toml)."
(string-append builddir "loadpath/" ":" (string-append builddir "loadpath/" ":"
(or (getenv "JULIA_LOAD_PATH") (or (getenv "JULIA_LOAD_PATH")
""))) "")))
(setenv "JULIA_CPU_THREADS" jobs)
(setenv "HOME" "/tmp") (setenv "HOME" "/tmp")
(invoke "julia" "--depwarn=yes" (invoke "julia" "--depwarn=yes"
(string-append "--procs=" jobs)
(string-append builddir "loadpath/" (string-append builddir "loadpath/"
package "/test/runtests.jl")))) package "/test/runtests.jl"))))
#t) #t)