summaryrefslogtreecommitdiff
path: root/tests/size.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-06-18 00:22:13 +0200
committerLudovic Courtès <ludo@gnu.org>2015-06-18 00:36:09 +0200
commitfcc58db68b2af59dea0cae41bc1e2df47911d588 (patch)
tree1ef2ec63a3b7043de50716e651a49f2ae18dbccc /tests/size.scm
parent39bee8a2937ea28e74b5c807962fb8bc87fe6887 (diff)
Add 'guix size'.
* guix/scripts/size.scm: New file. * Makefile.am (MODULES): Add it. (SCM_TESTS): Add tests/size.scm. * doc.am (SUBCOMMANDS): Add 'size'. * po/guix/POTFILES.in: Add guix/scripts/size.scm. * tests/size.scm: New file. * doc/guix.texi (Packages with Multiple Outputs): Add xref to "Invoking guix size". (Invoking guix size): New node. (Invoking guix gc): Add index for "closure" and xref to the above. * doc/contributing.texi (Submitting Patches): Use @enumerate for the check list. Add item about 'guix size'.
Diffstat (limited to 'tests/size.scm')
-rw-r--r--tests/size.scm87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/size.scm b/tests/size.scm
new file mode 100644
index 00000000000..95b99a88ef7
--- /dev/null
+++ b/tests/size.scm
@@ -0,0 +1,87 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
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))
31
32(define %store
33 (open-connection-for-tests))
34
35(define-syntax-rule (test-assertm name exp)
36 (test-assert name
37 (run-with-store %store exp
38 #:guile-for-build (%guile-for-build))))
39
40
41(test-begin "size")
42
43(test-assertm "store-profile"
44 (mlet* %store-monad ((file1 (gexp->derivation "file1"
45 #~(symlink #$%bootstrap-guile
46 #$output)))
47 (file2 (text-file* "file2"
48 "the file => " file1)))
49 (define (matching-profile item)
50 (lambda (profile)
51 (string=? item (profile-file profile))))
52
53 (mbegin %store-monad
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))
60 profiles))
61
62 (letrec-syntax ((match* (syntax-rules (=>)
63 ((_ ((drv => profile) rest ...) body)
64 (match (lookup-profile drv)
65 ((? profile? profile)
66 (match* (rest ...) body))))
67 ((_ () body)
68 body))))
69 ;; Make sure we get all three profiles with sensible values.
70 (return (and (= (length profiles) 3)
71 (match* ((file1 => profile1)
72 (file2 => profile2)
73 (guile => profile3))
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))))))))))))
79
80(test-end "size")
81
82
83(exit (= (test-runner-fail-count (test-runner-current)) 0))
84
85;;; Local Variables:
86;;; eval: (put 'match* 'scheme-indent-function 1)
87;;; End: