build: julia-build-system: Correctly disable parallel tests.

* guix/build/julia-build-system.scm: Remove phases trailing #t.
[phases]{check}: Omit the --procs argument when parallel tests are to be
disabled.  Substract 1 from the number of parallel jobs otherwise.

Co-authored-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
zimoun 2021-11-26 00:35:55 +01:00 committed by Maxim Cournoyer
parent 941f776fce
commit 73f55957cf
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -75,8 +75,7 @@ (define* (install #:key source inputs outputs julia-package-name
julia-package-name julia-package-name
(project.toml->name "Project.toml"))))) (project.toml->name "Project.toml")))))
(mkdir-p package-dir) (mkdir-p package-dir)
(copy-recursively (getcwd) package-dir)) (copy-recursively (getcwd) package-dir)))
#t)
(define* (precompile #:key source inputs outputs julia-package-name (define* (precompile #:key source inputs outputs julia-package-name
#:allow-other-keys) #:allow-other-keys)
@ -100,19 +99,22 @@ (define* (precompile #:key source inputs outputs julia-package-name
;; element of DEPOT_PATH. Once the cache file exists, this hack is not ;; element of DEPOT_PATH. Once the cache file exists, this hack is not
;; needed anymore (like in the check phase). If the user install new ;; needed anymore (like in the check phase). If the user install new
;; packages, those will be installed and precompiled in the home dir. ;; packages, those will be installed and precompiled in the home dir.
(string-append "pushfirst!(DEPOT_PATH, pop!(DEPOT_PATH)); using " package))) (string-append "pushfirst!(DEPOT_PATH, pop!(DEPOT_PATH)); using "
#t) package))))
(define* (check #:key tests? source inputs outputs julia-package-name (define* (check #:key tests? source inputs outputs julia-package-name
parallel-tests? 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? (job-count (if parallel-tests?
(number->string (parallel-job-count)) (parallel-job-count)
"1"))) 1))
;; The --proc argument of Julia *adds* extra processors rather than
;; specify the exact count to use, so zero must be specified to
;; disable parallel processing...
(additional-procs (max 0 (1- job-count))))
;; 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)
@ -120,16 +122,21 @@ (define* (check #:key tests? source inputs outputs julia-package-name
(string-append builddir "loadpath/" ":" (string-append builddir "loadpath/" ":"
(or (getenv "JULIA_LOAD_PATH") (or (getenv "JULIA_LOAD_PATH")
""))) "")))
(setenv "JULIA_CPU_THREADS" jobs) (setenv "JULIA_CPU_THREADS" (number->string job-count))
(setenv "HOME" "/tmp") (setenv "HOME" "/tmp")
(invoke "julia" "--depwarn=yes" (apply invoke "julia"
(string-append "--procs=" jobs) `("--depwarn=yes"
(string-append builddir "loadpath/" ,@(if parallel-tests?
package "/test/runtests.jl")))) ;; XXX: ... but '--procs' doesn't accept 0 as a valid
#t) ;; value, so just omit the argument entirely.
(list (string-append "--procs="
(number->string additional-procs)))
'())
,(string-append builddir "loadpath/"
package "/test/runtests.jl"))))))
(define* (link-depot #:key source inputs outputs julia-package-name julia-package-uuid (define* (link-depot #:key source inputs outputs
#:allow-other-keys) julia-package-name julia-package-uuid #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(package-name (or (package-name (or
julia-package-name julia-package-name
@ -144,10 +151,11 @@ (define* (link-depot #:key source inputs outputs julia-package-name julia-packag
;; When installing a package, julia looks first at in the JULIA_DEPOT_PATH ;; When installing a package, julia looks first at in the JULIA_DEPOT_PATH
;; for a path like packages/PACKAGE/XXXX ;; for a path like packages/PACKAGE/XXXX
;; Where XXXX is a slug encoding the package UUID and SHA1 of the files ;; Where XXXX is a slug encoding the package UUID and SHA1 of the files
;; Here we create a link with the correct path to enable julia to find the package ;; Here we create a link with the correct path to enable julia to find the
;; package
(mkdir-p (string-append out "/share/julia/packages/" package-name)) (mkdir-p (string-append out "/share/julia/packages/" package-name))
(symlink package-dir (string-append out "/share/julia/packages/" package-name "/" slug))) (symlink package-dir (string-append out "/share/julia/packages/"
#t) package-name "/" slug))))
(define (julia-create-package-toml outputs source (define (julia-create-package-toml outputs source
name uuid version name uuid version
@ -173,8 +181,7 @@ (define (julia-create-package-toml outputs source
(display (string-append (car (car dep)) " = \"" (cdr (car dep)) "\"\n") (display (string-append (car (car dep)) " = \"" (cdr (car dep)) "\"\n")
f)) f))
deps)) deps))
(close-port f)) (close-port f)))
#t)
(define %standard-phases (define %standard-phases
(modify-phases gnu:%standard-phases (modify-phases gnu:%standard-phases