gnu: r-kernsmooth: Update to 2.23-17.
[jackhill/guix/guix.git] / tests / size.scm
index 95b99a8..0aaa8fb 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module (guix gexp)
   #:use-module (guix tests)
   #:use-module (guix scripts size)
+  #:use-module (gnu packages)
   #:use-module (gnu packages bootstrap)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-64))
 
-(define %store
-  (open-connection-for-tests))
-
-(define-syntax-rule (test-assertm name exp)
-  (test-assert name
-    (run-with-store %store exp
-                    #:guile-for-build (%guile-for-build))))
-
 \f
 (test-begin "size")
 
     (mbegin %store-monad
       (built-derivations (list file2))
       (mlet %store-monad ((profiles (store-profile
-                                     (derivation->output-path file2)))
+                                     (list (derivation->output-path file2))))
+                          (bash     (interned-file
+                                     (search-bootstrap-binary
+                                      "bash" (%current-system)) "bash"
+                                      #:recursive? #t))
                           (guile    (package->derivation %bootstrap-guile)))
-        (define (lookup-profile drv)
-          (find (matching-profile (derivation->output-path drv))
+        (define (lookup-profile item)
+          (find (matching-profile (if (derivation? item)
+                                      (derivation->output-path item)
+                                      item))
                 profiles))
 
         (letrec-syntax ((match* (syntax-rules (=>)
                                   ((_ () body)
                                    body))))
           ;; Make sure we get all three profiles with sensible values.
-          (return (and (= (length profiles) 3)
+          (return (and (= (length profiles) 4)
                        (match* ((file1 => profile1)
                                 (file2 => profile2)
-                                (guile => profile3))
+                                (guile => profile3)
+                                (bash  => profile4)) ;dependency of GUILE
                          (and (> (profile-closure-size profile2) 0)
                               (= (profile-closure-size profile2)
                                  (+ (profile-self-size profile1)
                                     (profile-self-size profile2)
-                                    (profile-self-size profile3))))))))))))
+                                    (profile-self-size profile3)
+                                    (profile-self-size profile4))))))))))))
 
-(test-end "size")
+(test-assertm "store-profile with multiple items"
+  (mlet* %store-monad ((file1 (gexp->derivation "file1"
+                                                #~(symlink #$%bootstrap-guile
+                                                           #$output)))
+                       (file2 (text-file* "file2"
+                                          "the file => " file1)))
+    (mbegin %store-monad
+      (built-derivations (list file2))
+      (mlet %store-monad ((profiles  (store-profile
+                                      (list (derivation->output-path file2)
+                                            (derivation->output-path file1))))
+                          (reference (store-profile
+                                      (list (derivation->output-path file2)))))
+        (return (and (= (length profiles) 4)
+                     (lset= equal? profiles reference)))))))
 
-\f
-(exit (= (test-runner-fail-count (test-runner-current)) 0))
+(test-end "size")
 
 ;;; Local Variables:
 ;;; eval: (put 'match* 'scheme-indent-function 1)