diff mbox series

[bug#38546,2/3] gnu: julia-build-system: Enable tests.

Message ID 87sgltvbs1.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
State Accepted
Headers show
Series Julia: fix package build and add julia-xyz | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Nicolò Balzarotti Oct. 10, 2019, 3:49 p.m. UTC
---
 guix/build-system/julia.scm       |  4 +++-
 guix/build/julia-build-system.scm | 28 +++++++++++++++++++---------
 2 files changed, 22 insertions(+), 10 deletions(-)

Comments

Ludovic Courtès Dec. 15, 2019, 9:45 p.m. UTC | #1
Nicolò Balzarotti <anothersms@gmail.com> skribis:

> ---
>  guix/build-system/julia.scm       |  4 +++-
>  guix/build/julia-build-system.scm | 28 +++++++++++++++++++---------
>  2 files changed, 22 insertions(+), 10 deletions(-)

With a commit log, please.  :-)

> --- a/guix/build/julia-build-system.scm
> +++ b/guix/build/julia-build-system.scm
> @@ -32,7 +32,13 @@
>  ;; Code:
>  
>  (define (invoke-julia code)
> -  (invoke "julia" "-e" code))
> +  ;; Julia stores the result of the time() call
> +  ;; inside the precompiled file. When trying to load it, its precompilation
> +  ;; it fails at comparing the file mtime with the precompilation time,
> +  ;; always triggering a recompile. This fixes the stored value.
> +  ;; Also, libc.jl rand() uses time() as its seed. This might introduce indeterminism while building
> +  ;; Default guix mtime is 1, so I'm setting the same here (if they differ, precompilation is invalid)
> +  (invoke "faketime" "-f" "1970-01-01 00:00:01" "julia" "-e" code))

Do you think it would be feasible to modify Julia to emit this fixed
timestamp, or to honor SOURCE_DATE_EPOCH, instead of using ‘faketime’?

The reason I’m asking is that (1) ‘faketime’ relies on LD_PRELOAD and so
it could introduce its own set of issues, and (2) I wouldn’t be
surprised to find ready-to-use SOURCE_DATE_EPOCH patches from fellow
Reproducible Builders floating around.  :-)

Ludo’.
diff mbox series

Patch

diff --git a/guix/build-system/julia.scm b/guix/build-system/julia.scm
index 488fe9bb1d..0c07484f12 100644
--- a/guix/build-system/julia.scm
+++ b/guix/build-system/julia.scm
@@ -26,6 +26,7 @@ 
   #:use-module (guix build-system gnu)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-26)
+  #:use-module (gnu packages check) ;; libfaketime
   #:export (%julia-build-system-modules
             julia-build
             julia-build-system))
@@ -68,6 +69,7 @@ 
                         ;; Keep the standard inputs of 'gnu-build-system'.
                         ,@(standard-packages)))
          (build-inputs `(("julia" ,julia)
+                         ("libfaketime" ,libfaketime)
                          ,@native-inputs))
          (outputs outputs)
          (build julia-build)
@@ -75,7 +77,7 @@ 
 
 (define* (julia-build store name inputs
                       #:key source
-                      (tests? #f)
+                      (tests? #t)
                       (phases '(@ (guix build julia-build-system)
                                   %standard-phases))
                       (outputs '("out"))
diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm
index ff6fcf5fe3..bd4c64fa11 100644
--- a/guix/build/julia-build-system.scm
+++ b/guix/build/julia-build-system.scm
@@ -32,7 +32,13 @@ 
 ;; Code:
 
 (define (invoke-julia code)
-  (invoke "julia" "-e" code))
+  ;; Julia stores the result of the time() call
+  ;; inside the precompiled file. When trying to load it, its precompilation
+  ;; it fails at comparing the file mtime with the precompilation time,
+  ;; always triggering a recompile. This fixes the stored value.
+  ;; Also, libc.jl rand() uses time() as its seed. This might introduce indeterminism while building
+  ;; Default guix mtime is 1, so I'm setting the same here (if they differ, precompilation is invalid)
+  (invoke "faketime" "-f" "1970-01-01 00:00:01" "julia" "-e" code))
 
 ;; subpath where we store the package content
 (define %package-path "/share/julia/packages/")
@@ -78,13 +84,17 @@ 
     (invoke-julia (string-append "using " package)))
   #t)
 
-(define* (check #:key source inputs outputs #:allow-other-keys)
-  (let* ((out (assoc-ref outputs "out"))
-         (package (strip-store-file-name source))
-         (builddir (string-append out "/share/julia/")))
-    (setenv "JULIA_DEPOT_PATH" builddir)
-    (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs))
-    (invoke-julia (string-append "using Pkg;Pkg.test(\"" package "\")")))
+(define* (check #:key tests? source inputs outputs #:allow-other-keys)
+  (when tests?
+      (let* ((out (assoc-ref outputs "out"))
+             (package (strip-store-file-name source))
+             (builddir (string-append out "/share/julia/")))
+        (setenv "JULIA_DEPOT_PATH" builddir)
+        (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs))
+        (display builddir)
+        (invoke "julia" (string-append builddir
+                                       "packages/"
+                                       package "/test/runtests.jl"))))
   #t)
 
 (define (julia-create-package-toml outputs source
@@ -119,7 +129,7 @@  version = \"" version "\"
     (delete 'check) ; tests must be run after installation
     (replace 'install install)
     (add-after 'install 'precompile precompile)
-    ;; (add-after 'install 'check check)
+    (add-after 'install 'check check)
     ;; TODO: In the future we could add a "system-image-generation" phase
     ;; where we use PackageCompiler.jl to speed up package loading times
     (delete 'configure)