ui: Present 'use-modules' hints with a question mark.
[guix.git] / tests / scripts.scm
blob390171095332cf8999b7757a02469519bdc50626
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/>.
20 (define-module (test-scripts)
21   #:use-module (guix scripts)
22   #:use-module ((guix scripts build)
23                 #:select (%standard-build-options))
24   #:use-module (srfi srfi-64))
26 ;; Test the (guix scripts) module.
28 (define-syntax-rule (with-environment-variable variable value body ...)
29   "Run BODY with VARIABLE set to VALUE."
30   (let ((orig (getenv variable)))
31     (dynamic-wind
32       (lambda ()
33         (setenv variable value))
34       (lambda ()
35         body ...)
36       (lambda ()
37         (if orig
38             (setenv variable orig)
39             (unsetenv variable))))))
42 (test-begin "scripts")
44 (test-equal "parse-command-line"
45   '((argument . "bar") (argument . "foo")
46     (cores . 10)                                  ;takes precedence
47     (substitutes? . #f) (keep-failed? . #t)
48     (max-jobs . 77) (cores . 42))
50   (with-environment-variable "GUIX_BUILD_OPTIONS" "-c 42 -M 77"
51     (parse-command-line '("--keep-failed" "--no-substitutes"
52                           "--cores=10" "foo" "bar")
53                         %standard-build-options
54                         (list '()))))
56 (test-equal "parse-command-line and --no options"
57   '((argument . "foo")
58     (substitutes? . #f))                          ;takes precedence
60   (with-environment-variable "GUIX_BUILD_OPTIONS" "--no-substitutes"
61     (parse-command-line '("foo")
62                         %standard-build-options
63                         (list '((substitutes? . #t))))))
65 (test-end "scripts")
67 ;;; Local Variables:
68 ;;; eval: (put 'with-environment-variable 'scheme-indent-function 2)
69 ;;; End: