guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Nicolò Balzarotti
Subject: [bug#38546] [PATCH 2/3] gnu: julia-build-system: Enable tests.
Date: Mon, 09 Dec 2019 14:02:12 -0000

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

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)
-- 
2.24.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]