1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-size)
20 #:use-module (guix store)
21 #:use-module (guix monads)
22 #:use-module (guix packages)
23 #:use-module (guix derivations)
24 #:use-module (guix gexp)
25 #:use-module (guix tests)
26 #:use-module (guix scripts size)
27 #:use-module (gnu packages bootstrap)
28 #:use-module (ice-9 match)
29 #:use-module (srfi srfi-1)
30 #:use-module (srfi srfi-64))
33 (open-connection-for-tests))
35 (define-syntax-rule (test-assertm name exp)
37 (run-with-store %store exp
38 #:guile-for-build (%guile-for-build))))
43 (test-assertm "store-profile"
44 (mlet* %store-monad ((file1 (gexp->derivation "file1"
45 #~(symlink #$%bootstrap-guile
47 (file2 (text-file* "file2"
48 "the file => " file1)))
49 (define (matching-profile item)
51 (string=? item (profile-file profile))))
54 (built-derivations (list file2))
55 (mlet %store-monad ((profiles (store-profile
56 (derivation->output-path file2)))
57 (guile (package->derivation %bootstrap-guile)))
58 (define (lookup-profile drv)
59 (find (matching-profile (derivation->output-path drv))
62 (letrec-syntax ((match* (syntax-rules (=>)
63 ((_ ((drv => profile) rest ...) body)
64 (match (lookup-profile drv)
66 (match* (rest ...) body))))
69 ;; Make sure we get all three profiles with sensible values.
70 (return (and (= (length profiles) 3)
71 (match* ((file1 => profile1)
74 (and (> (profile-closure-size profile2) 0)
75 (= (profile-closure-size profile2)
76 (+ (profile-self-size profile1)
77 (profile-self-size profile2)
78 (profile-self-size profile3))))))))))))
83 (exit (= (test-runner-fail-count (test-runner-current)) 0))
86 ;;; eval: (put 'match* 'scheme-indent-function 1)