2014-04-28 17:00:57 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2023-11-23 09:22:42 -05:00
|
|
|
|
;;; Copyright © 2014-2023 Ludovic Courtès <ludo@gnu.org>
|
2022-03-03 08:57:03 -05:00
|
|
|
|
;;; Copyright © 2021-2022 Maxime Devos <maximedevos@telenet.be>
|
2014-04-28 17:00:57 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (test-gexp)
|
|
|
|
|
#:use-module (guix store)
|
|
|
|
|
#:use-module (guix monads)
|
|
|
|
|
#:use-module (guix gexp)
|
2022-11-10 12:20:23 -05:00
|
|
|
|
#:use-module ((guix grafts) #:select (%graft-with-utf8-locale?))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (guix derivations)
|
2014-05-01 10:15:00 -04:00
|
|
|
|
#:use-module (guix packages)
|
2018-05-28 12:14:37 -04:00
|
|
|
|
#:use-module (guix build-system trivial)
|
2014-08-23 13:18:01 -04:00
|
|
|
|
#:use-module (guix tests)
|
2016-06-16 03:33:24 -04:00
|
|
|
|
#:use-module ((guix build utils) #:select (with-directory-excursion))
|
2018-03-23 13:21:28 -04:00
|
|
|
|
#:use-module ((guix utils) #:select (call-with-temporary-directory))
|
2022-02-16 05:27:43 -05:00
|
|
|
|
#:use-module ((guix ui) #:select (load*))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (gnu packages)
|
|
|
|
|
#:use-module (gnu packages base)
|
|
|
|
|
#:use-module (gnu packages bootstrap)
|
2020-11-05 08:52:29 -05:00
|
|
|
|
#:use-module ((guix diagnostics) #:select (guix-warning-port))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
2015-02-11 16:10:14 -05:00
|
|
|
|
#:use-module (srfi srfi-34)
|
2014-04-28 17:00:57 -04:00
|
|
|
|
#:use-module (srfi srfi-64)
|
|
|
|
|
#:use-module (rnrs io ports)
|
|
|
|
|
#:use-module (ice-9 match)
|
2014-07-17 09:40:06 -04:00
|
|
|
|
#:use-module (ice-9 regex)
|
2016-06-15 18:06:27 -04:00
|
|
|
|
#:use-module (ice-9 popen)
|
|
|
|
|
#:use-module (ice-9 ftw))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
;; Test the (guix gexp) module.
|
|
|
|
|
|
|
|
|
|
(define %store
|
2014-08-23 13:18:01 -04:00
|
|
|
|
(open-connection-for-tests))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
2016-03-06 15:53:28 -05:00
|
|
|
|
;; Globally disable grafts because they can trigger early builds.
|
|
|
|
|
(%graft? #f)
|
|
|
|
|
|
2022-11-10 12:20:23 -05:00
|
|
|
|
;; When grafting, do not add dependency on 'glibc-utf8-locales'.
|
|
|
|
|
(%graft-with-utf8-locale? #f)
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
;; For white-box testing.
|
2015-03-14 17:28:39 -04:00
|
|
|
|
(define (gexp-inputs x)
|
|
|
|
|
((@@ (guix gexp) gexp-inputs) x))
|
|
|
|
|
(define (gexp-outputs x)
|
|
|
|
|
((@@ (guix gexp) gexp-outputs) x))
|
|
|
|
|
(define (gexp->sexp . x)
|
|
|
|
|
(apply (@@ (guix gexp) gexp->sexp) x))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(define* (gexp->sexp* exp #:optional target)
|
2021-02-17 08:25:43 -05:00
|
|
|
|
(run-with-store %store (gexp->sexp exp (%current-system) target)
|
2014-08-23 13:18:01 -04:00
|
|
|
|
#:guile-for-build (%guile-for-build)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(define (gexp-input->tuple input)
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(list (gexp-input-thing input) (gexp-input-output input)
|
|
|
|
|
(gexp-input-native? input)))
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
|
2018-05-28 12:14:37 -04:00
|
|
|
|
(define %extension-package
|
|
|
|
|
;; Example of a package to use when testing 'with-extensions'.
|
|
|
|
|
(dummy-package "extension"
|
|
|
|
|
(build-system trivial-build-system)
|
|
|
|
|
(arguments
|
|
|
|
|
`(#:guile ,%bootstrap-guile
|
|
|
|
|
#:modules ((guix build utils))
|
|
|
|
|
#:builder
|
|
|
|
|
(begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(let* ((out (string-append (assoc-ref %outputs "out")
|
|
|
|
|
"/share/guile/site/"
|
|
|
|
|
(effective-version))))
|
|
|
|
|
(mkdir-p out)
|
|
|
|
|
(call-with-output-file (string-append out "/hg2g.scm")
|
|
|
|
|
(lambda (port)
|
2020-05-25 10:04:33 -04:00
|
|
|
|
(define defmod 'define-module) ;fool Geiser
|
|
|
|
|
(write `(,defmod (hg2g)
|
2018-05-28 12:14:37 -04:00
|
|
|
|
#:export (the-answer))
|
|
|
|
|
port)
|
|
|
|
|
(write '(define the-answer 42) port)))))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
(test-begin "gexp")
|
|
|
|
|
|
2021-06-28 13:24:44 -04:00
|
|
|
|
(test-equal "no references"
|
|
|
|
|
'(display "hello gexp->approximate-sexp!")
|
|
|
|
|
(gexp->approximate-sexp #~(display "hello gexp->approximate-sexp!")))
|
|
|
|
|
|
|
|
|
|
(test-equal "unquoted gexp"
|
|
|
|
|
'(display "hello")
|
|
|
|
|
(let ((inside #~"hello"))
|
|
|
|
|
(gexp->approximate-sexp #~(display #$inside))))
|
|
|
|
|
|
|
|
|
|
(test-equal "unquoted gexp (native)"
|
|
|
|
|
'(display "hello")
|
|
|
|
|
(let ((inside #~"hello"))
|
|
|
|
|
(gexp->approximate-sexp #~(display #+inside))))
|
|
|
|
|
|
|
|
|
|
(test-equal "spliced gexp"
|
|
|
|
|
'(display '(fresh vegetables))
|
|
|
|
|
(let ((inside #~(fresh vegetables)))
|
|
|
|
|
(gexp->approximate-sexp #~(display '(#$@inside)))))
|
|
|
|
|
|
|
|
|
|
(test-equal "unspliced gexp, approximated"
|
|
|
|
|
;; (*approximate*) is really an implementation detail
|
|
|
|
|
'(display '(*approximate*))
|
|
|
|
|
(let ((inside (file-append coreutils "/bin/hello")))
|
|
|
|
|
(gexp->approximate-sexp #~(display '(#$@inside)))))
|
|
|
|
|
|
|
|
|
|
(test-equal "unquoted gexp, approximated"
|
|
|
|
|
'(display '(*approximate*))
|
|
|
|
|
(let ((inside (file-append coreutils "/bin/hello")))
|
|
|
|
|
(gexp->approximate-sexp #~(display '#$inside))))
|
|
|
|
|
|
2022-03-03 08:57:03 -05:00
|
|
|
|
;; See <https://issues.guix.gnu.org/54236>.
|
|
|
|
|
(test-equal "unquoted sexp (not a gexp!)"
|
|
|
|
|
'(list #(foo) (foo) () "foo" foo #xf00)
|
|
|
|
|
(let ((inside/vector #(foo))
|
|
|
|
|
(inside/list '(foo))
|
|
|
|
|
(inside/empty '())
|
|
|
|
|
(inside/string "foo")
|
|
|
|
|
(inside/symbol 'foo)
|
|
|
|
|
(inside/number #xf00))
|
|
|
|
|
(gexp->approximate-sexp
|
|
|
|
|
#~(list #$inside/vector #$inside/list #$inside/empty #$inside/string
|
|
|
|
|
#$inside/symbol #$inside/number))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-equal "no refs"
|
|
|
|
|
'(display "hello!")
|
|
|
|
|
(let ((exp (gexp (display "hello!"))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(null? (gexp-inputs exp))
|
|
|
|
|
(gexp->sexp* exp))))
|
|
|
|
|
|
2021-02-28 15:29:53 -05:00
|
|
|
|
(test-equal "sexp->gexp"
|
|
|
|
|
'(a b (c d) e)
|
|
|
|
|
(let ((exp (sexp->gexp '(a b (c d) e))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(null? (gexp-inputs exp))
|
|
|
|
|
(gexp->sexp* exp))))
|
|
|
|
|
|
2022-03-03 09:14:22 -05:00
|
|
|
|
(test-equal "gexp->approximate-sexp, outputs"
|
|
|
|
|
'(list 'out:foo (*approximate*) 'out:bar (*approximate*))
|
|
|
|
|
(gexp->approximate-sexp
|
|
|
|
|
#~(list 'out:foo #$output:foo 'out:bar #$output:bar)))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-equal "unquote"
|
|
|
|
|
'(display `(foo ,(+ 2 3)))
|
|
|
|
|
(let ((exp (gexp (display `(foo ,(+ 2 3))))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(null? (gexp-inputs exp))
|
|
|
|
|
(gexp->sexp* exp))))
|
|
|
|
|
|
|
|
|
|
(test-assert "one input package"
|
|
|
|
|
(let ((exp (gexp (display (ungexp coreutils)))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(eq? (gexp-input-thing input) coreutils)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(equal? `(display ,(derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils)))
|
|
|
|
|
(gexp->sexp* exp)))))
|
2017-01-01 16:22:14 -05:00
|
|
|
|
|
|
|
|
|
(test-assert "one input package, dotted list"
|
|
|
|
|
(let ((exp (gexp (coreutils . (ungexp coreutils)))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(eq? (gexp-input-thing input) coreutils)))
|
2017-01-01 16:22:14 -05:00
|
|
|
|
(equal? `(coreutils . ,(derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils)))
|
|
|
|
|
(gexp->sexp* exp)))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(test-assert "one input origin"
|
|
|
|
|
(let ((exp (gexp (display (ungexp (package-source coreutils))))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) (package-source coreutils))
|
|
|
|
|
(string=? (gexp-input-output input) "out"))))
|
2014-05-01 10:15:00 -04:00
|
|
|
|
(equal? `(display ,(derivation->output-path
|
|
|
|
|
(package-source-derivation
|
|
|
|
|
%store (package-source coreutils))))
|
|
|
|
|
(gexp->sexp* exp)))))
|
|
|
|
|
|
2015-03-28 16:26:33 -04:00
|
|
|
|
(test-assert "one local file"
|
|
|
|
|
(let* ((file (search-path %load-path "guix.scm"))
|
|
|
|
|
(local (local-file file))
|
|
|
|
|
(exp (gexp (display (ungexp local))))
|
2015-06-18 17:25:49 -04:00
|
|
|
|
(intd (add-to-store %store (basename file) #f
|
2015-03-28 16:26:33 -04:00
|
|
|
|
"sha256" file)))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) local)
|
|
|
|
|
(string=? (gexp-input-output input) "out"))))
|
2015-03-28 16:26:33 -04:00
|
|
|
|
(equal? `(display ,intd) (gexp->sexp* exp)))))
|
|
|
|
|
|
2015-06-19 04:18:44 -04:00
|
|
|
|
(test-assert "one local file, symlink"
|
|
|
|
|
(let ((file (search-path %load-path "guix.scm"))
|
|
|
|
|
(link (tmpnam)))
|
|
|
|
|
(dynamic-wind
|
|
|
|
|
(const #t)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(symlink (canonicalize-path file) link)
|
|
|
|
|
(let* ((local (local-file link "my-file" #:recursive? #f))
|
|
|
|
|
(exp (gexp (display (ungexp local))))
|
|
|
|
|
(intd (add-to-store %store "my-file" #f
|
|
|
|
|
"sha256" file)))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) local)
|
|
|
|
|
(string=? (gexp-input-output input) "out"))))
|
2015-06-19 04:18:44 -04:00
|
|
|
|
(equal? `(display ,intd) (gexp->sexp* exp)))))
|
|
|
|
|
(lambda ()
|
|
|
|
|
(false-if-exception (delete-file link))))))
|
|
|
|
|
|
2016-06-16 03:33:24 -04:00
|
|
|
|
(test-equal "local-file, relative file name"
|
|
|
|
|
(canonicalize-path (search-path %load-path "guix/base32.scm"))
|
|
|
|
|
(let ((directory (dirname (search-path %load-path
|
|
|
|
|
"guix/build-system/gnu.scm"))))
|
|
|
|
|
(with-directory-excursion directory
|
|
|
|
|
(let ((file (local-file "../guix/base32.scm")))
|
|
|
|
|
(local-file-absolute-file-name file)))))
|
|
|
|
|
|
2019-11-30 11:17:00 -05:00
|
|
|
|
(test-equal "local-file, non-literal relative file name"
|
|
|
|
|
(canonicalize-path (search-path %load-path "guix/base32.scm"))
|
|
|
|
|
(let ((directory (dirname (search-path %load-path
|
|
|
|
|
"guix/build-system/gnu.scm"))))
|
|
|
|
|
(with-directory-excursion directory
|
|
|
|
|
(let ((file (local-file (string-copy "../base32.scm"))))
|
|
|
|
|
(local-file-absolute-file-name file)))))
|
|
|
|
|
|
2022-02-16 05:27:43 -05:00
|
|
|
|
(test-assert "local-file, relative file name, within gexp"
|
|
|
|
|
(let* ((file (search-path %load-path "guix/base32.scm"))
|
|
|
|
|
(interned (add-to-store %store "base32.scm" #f "sha256" file)))
|
|
|
|
|
(equal? `(the file is ,interned)
|
|
|
|
|
(gexp->sexp*
|
|
|
|
|
#~(the file is #$(local-file "../guix/base32.scm"))))))
|
|
|
|
|
|
|
|
|
|
(test-assert "local-file, relative file name, within gexp, compiled"
|
|
|
|
|
;; In Guile 3.0.8, everything read by the #~ and #$ read hash extensions
|
|
|
|
|
;; would lack source location info, which in turn would lead
|
|
|
|
|
;; (current-source-directory), called by 'local-file', to return #f, thereby
|
|
|
|
|
;; breaking 'local-file' resolution. See
|
|
|
|
|
;; <https://issues.guix.gnu.org/54003>.
|
|
|
|
|
(let ((file (tmpnam)))
|
|
|
|
|
(call-with-output-file file
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display (string-append "#~(this file is #$(local-file \""
|
|
|
|
|
(basename file) "\" \"t.scm\"))")
|
|
|
|
|
port)))
|
|
|
|
|
|
|
|
|
|
(let* ((interned (add-to-store %store "t.scm" #f "sha256" file))
|
|
|
|
|
(module (make-fresh-user-module)))
|
|
|
|
|
(module-use! module (resolve-interface '(guix gexp)))
|
|
|
|
|
(equal? `(this file is ,interned)
|
|
|
|
|
(gexp->sexp* (load* file module))))))
|
|
|
|
|
|
2016-06-15 18:06:27 -04:00
|
|
|
|
(test-assertm "local-file, #:select?"
|
|
|
|
|
(mlet* %store-monad ((select? -> (lambda (file stat)
|
|
|
|
|
(member (basename file)
|
|
|
|
|
'("guix.scm" "tests"
|
|
|
|
|
"gexp.scm"))))
|
|
|
|
|
(file -> (local-file ".." "directory"
|
|
|
|
|
#:recursive? #t
|
|
|
|
|
#:select? select?))
|
|
|
|
|
(dir (lower-object file)))
|
|
|
|
|
(return (and (store-path? dir)
|
|
|
|
|
(equal? (scandir dir)
|
|
|
|
|
'("." ".." "guix.scm" "tests"))
|
|
|
|
|
(equal? (scandir (string-append dir "/tests"))
|
|
|
|
|
'("." ".." "gexp.scm"))))))
|
|
|
|
|
|
2015-06-03 05:45:27 -04:00
|
|
|
|
(test-assert "one plain file"
|
|
|
|
|
(let* ((file (plain-file "hi" "Hello, world!"))
|
|
|
|
|
(exp (gexp (display (ungexp file))))
|
|
|
|
|
(expected (add-text-to-store %store "hi" "Hello, world!")))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) file)
|
|
|
|
|
(string=? (gexp-input-output input) "out"))))
|
2015-06-03 05:45:27 -04:00
|
|
|
|
(equal? `(display ,expected) (gexp->sexp* exp)))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assert "same input twice"
|
|
|
|
|
(let ((exp (gexp (begin
|
|
|
|
|
(display (ungexp coreutils))
|
|
|
|
|
(display (ungexp coreutils))))))
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) coreutils)
|
|
|
|
|
(string=? (gexp-input-output input) "out"))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(let ((e `(display ,(derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils)))))
|
|
|
|
|
(equal? `(begin ,e ,e) (gexp->sexp* exp))))))
|
|
|
|
|
|
|
|
|
|
(test-assert "two input packages, one derivation, one file"
|
|
|
|
|
(let* ((drv (build-expression->derivation
|
|
|
|
|
%store "foo" 'bar
|
|
|
|
|
#:guile-for-build (package-derivation %store %bootstrap-guile)))
|
|
|
|
|
(txt (add-text-to-store %store "foo" "Hello, world!"))
|
|
|
|
|
(exp (gexp (begin
|
|
|
|
|
(display (ungexp coreutils))
|
|
|
|
|
(display (ungexp %bootstrap-guile))
|
|
|
|
|
(display (ungexp drv))
|
|
|
|
|
(display (ungexp txt))))))
|
|
|
|
|
(define (match-input thing)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(lambda (input)
|
|
|
|
|
(eq? (gexp-input-thing input) thing)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
|
|
|
|
(and (gexp? exp)
|
|
|
|
|
(= 4 (length (gexp-inputs exp)))
|
|
|
|
|
(every (lambda (input)
|
|
|
|
|
(find (match-input input) (gexp-inputs exp)))
|
|
|
|
|
(list drv coreutils %bootstrap-guile txt))
|
|
|
|
|
(let ((e0 `(display ,(derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils))))
|
|
|
|
|
(e1 `(display ,(derivation->output-path
|
|
|
|
|
(package-derivation %store %bootstrap-guile))))
|
|
|
|
|
(e2 `(display ,(derivation->output-path drv)))
|
|
|
|
|
(e3 `(display ,txt)))
|
|
|
|
|
(equal? `(begin ,e0 ,e1 ,e2 ,e3) (gexp->sexp* exp))))))
|
|
|
|
|
|
2016-09-09 16:46:36 -04:00
|
|
|
|
(test-assert "file-append"
|
|
|
|
|
(let* ((drv (package-derivation %store %bootstrap-guile))
|
|
|
|
|
(fa (file-append %bootstrap-guile "/bin/guile"))
|
|
|
|
|
(exp #~(here we go #$fa)))
|
|
|
|
|
(and (match (gexp->sexp* exp)
|
|
|
|
|
(('here 'we 'go (? string? result))
|
|
|
|
|
(string=? result
|
|
|
|
|
(string-append (derivation->output-path drv)
|
|
|
|
|
"/bin/guile"))))
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) fa)
|
|
|
|
|
(string=? (gexp-input-output input) "out")))))))
|
2016-09-09 16:46:36 -04:00
|
|
|
|
|
|
|
|
|
(test-assert "file-append, output"
|
|
|
|
|
(let* ((drv (package-derivation %store glibc))
|
|
|
|
|
(fa (file-append glibc "/lib" "/debug"))
|
|
|
|
|
(exp #~(foo #$fa:debug)))
|
|
|
|
|
(and (match (gexp->sexp* exp)
|
|
|
|
|
(('foo (? string? result))
|
|
|
|
|
(string=? result
|
|
|
|
|
(string-append (derivation->output-path drv "debug")
|
|
|
|
|
"/lib/debug"))))
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (gexp-input-thing input) fa)
|
|
|
|
|
(string=? (gexp-input-output input) "debug")))))))
|
2016-09-09 16:46:36 -04:00
|
|
|
|
|
|
|
|
|
(test-assert "file-append, nested"
|
|
|
|
|
(let* ((drv (package-derivation %store glibc))
|
|
|
|
|
(dir (file-append glibc "/bin"))
|
|
|
|
|
(slash (file-append dir "/"))
|
|
|
|
|
(file (file-append slash "getent"))
|
|
|
|
|
(exp #~(foo #$file)))
|
|
|
|
|
(and (match (gexp->sexp* exp)
|
|
|
|
|
(('foo (? string? result))
|
|
|
|
|
(string=? result
|
|
|
|
|
(string-append (derivation->output-path drv)
|
|
|
|
|
"/bin/getent"))))
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(eq? (gexp-input-thing input) file))))))
|
2016-09-09 16:46:36 -04:00
|
|
|
|
|
2020-05-25 10:06:03 -04:00
|
|
|
|
(test-assert "file-append, raw store item"
|
|
|
|
|
(let* ((obj (plain-file "example.txt" "Hello!"))
|
|
|
|
|
(a (file-append obj "/a"))
|
|
|
|
|
(b (file-append a "/b"))
|
|
|
|
|
(c (file-append b "/c"))
|
|
|
|
|
(exp #~(list #$c))
|
|
|
|
|
(item (run-with-store %store (lower-object obj)))
|
|
|
|
|
(lexp (run-with-store %store (lower-gexp exp))))
|
|
|
|
|
(and (equal? (lowered-gexp-sexp lexp)
|
|
|
|
|
`(list ,(string-append item "/a/b/c")))
|
|
|
|
|
(equal? (lowered-gexp-sources lexp)
|
|
|
|
|
(list item))
|
|
|
|
|
(null? (lowered-gexp-inputs lexp)))))
|
|
|
|
|
|
2023-11-12 16:47:43 -05:00
|
|
|
|
(test-equal "gexp references non-existent output"
|
|
|
|
|
"no-default-output"
|
|
|
|
|
(guard (c ((derivation-missing-output-error? c)
|
|
|
|
|
(derivation-name (derivation-error-derivation c))))
|
|
|
|
|
(let* ((obj (computed-file "no-default-output"
|
|
|
|
|
#~(mkdir #$output:bar)))
|
|
|
|
|
(exp #~(symlink #$obj #$output))
|
|
|
|
|
(drv (run-with-store %store (lower-gexp exp))))
|
|
|
|
|
(pk 'oops! drv #f))))
|
|
|
|
|
|
|
|
|
|
(test-assert "gexp-input, as first-class input"
|
|
|
|
|
;; Insert a <gexp-input> record in a gexp as a way to specify which output
|
|
|
|
|
;; of OBJ should be used.
|
|
|
|
|
(let* ((obj (computed-file "foo" #~(mkdir #$output:bar)))
|
|
|
|
|
(exp #~(list #$(gexp-input obj "bar")))
|
|
|
|
|
(drv (run-with-store %store (lower-object obj)))
|
|
|
|
|
(item (derivation->output-path drv "bar"))
|
|
|
|
|
(lexp (run-with-store %store (lower-gexp exp))))
|
|
|
|
|
(and (match (lowered-gexp-inputs lexp)
|
|
|
|
|
((input)
|
|
|
|
|
(eq? (derivation-input-derivation input) drv)))
|
|
|
|
|
(equal? (lowered-gexp-sexp lexp)
|
|
|
|
|
`(list ,item)))))
|
|
|
|
|
|
2020-03-06 05:25:43 -05:00
|
|
|
|
(test-assertm "with-parameters for %current-system"
|
|
|
|
|
(mlet* %store-monad ((system -> (match (%current-system)
|
|
|
|
|
("aarch64-linux" "x86_64-linux")
|
|
|
|
|
(_ "aarch64-linux")))
|
|
|
|
|
(drv (package->derivation coreutils system))
|
|
|
|
|
(obj -> (with-parameters ((%current-system system))
|
|
|
|
|
coreutils))
|
|
|
|
|
(result (lower-object obj)))
|
|
|
|
|
(return (string=? (derivation-file-name drv)
|
|
|
|
|
(derivation-file-name result)))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "with-parameters for %current-target-system"
|
|
|
|
|
(mlet* %store-monad ((target -> "riscv64-linux-gnu")
|
|
|
|
|
(drv (package->cross-derivation coreutils target))
|
|
|
|
|
(obj -> (with-parameters
|
|
|
|
|
((%current-target-system target))
|
|
|
|
|
coreutils))
|
|
|
|
|
(result (lower-object obj)))
|
|
|
|
|
(return (string=? (derivation-file-name drv)
|
|
|
|
|
(derivation-file-name result)))))
|
|
|
|
|
|
|
|
|
|
(test-assert "with-parameters + file-append"
|
|
|
|
|
(let* ((system (match (%current-system)
|
|
|
|
|
("aarch64-linux" "x86_64-linux")
|
|
|
|
|
(_ "aarch64-linux")))
|
|
|
|
|
(drv (package-derivation %store coreutils system))
|
|
|
|
|
(param (make-parameter 7))
|
|
|
|
|
(exp #~(here we go #$(with-parameters ((%current-system system)
|
|
|
|
|
(param 42))
|
|
|
|
|
(if (= (param) 42)
|
|
|
|
|
(file-append coreutils "/bin/touch")
|
|
|
|
|
%bootstrap-guile)))))
|
|
|
|
|
(match (gexp->sexp* exp)
|
|
|
|
|
(('here 'we 'go (? string? result))
|
|
|
|
|
(string=? result
|
|
|
|
|
(string-append (derivation->output-path drv)
|
|
|
|
|
"/bin/touch"))))))
|
2017-11-14 04:16:22 -05:00
|
|
|
|
(test-equal "let-system"
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(list `(begin ,(%current-system) #t) '(system-binding)
|
2017-11-14 04:16:22 -05:00
|
|
|
|
'low '() '())
|
|
|
|
|
(let* ((exp #~(begin
|
|
|
|
|
#$(let-system system system)
|
|
|
|
|
#t))
|
|
|
|
|
(low (run-with-store %store (lower-gexp exp))))
|
|
|
|
|
(list (lowered-gexp-sexp low)
|
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (struct-vtable (gexp-input-thing input))
|
|
|
|
|
(@@ (guix gexp) <system-binding>))
|
|
|
|
|
(string=? (gexp-input-output input) "out")
|
|
|
|
|
'(system-binding)))
|
2017-11-14 04:16:22 -05:00
|
|
|
|
(x x))
|
|
|
|
|
'low
|
|
|
|
|
(lowered-gexp-inputs low)
|
|
|
|
|
(lowered-gexp-sources low))))
|
|
|
|
|
|
|
|
|
|
(test-equal "let-system, target"
|
|
|
|
|
(list `(list ,(%current-system) #f)
|
|
|
|
|
`(list ,(%current-system) "aarch64-linux-gnu"))
|
|
|
|
|
(let ((exp #~(list #$@(let-system (system target)
|
|
|
|
|
(list system target)))))
|
|
|
|
|
(list (gexp->sexp* exp)
|
|
|
|
|
(gexp->sexp* exp "aarch64-linux-gnu"))))
|
|
|
|
|
|
|
|
|
|
(test-equal "let-system, ungexp-native, target"
|
|
|
|
|
`(here it is: ,(%current-system) #f)
|
|
|
|
|
(let ((exp #~(here it is: #+@(let-system (system target)
|
|
|
|
|
(list system target)))))
|
|
|
|
|
(gexp->sexp* exp "aarch64-linux-gnu")))
|
|
|
|
|
|
|
|
|
|
(test-equal "let-system, nested"
|
|
|
|
|
(list `(system* ,(string-append "qemu-system-" (%current-system))
|
|
|
|
|
"-m" "256")
|
|
|
|
|
'(system-binding))
|
|
|
|
|
(let ((exp #~(system*
|
|
|
|
|
#+(let-system (system target)
|
|
|
|
|
(file-append (@@ (gnu packages virtualization)
|
|
|
|
|
qemu)
|
|
|
|
|
"/bin/qemu-system-"
|
|
|
|
|
system))
|
|
|
|
|
"-m" "256")))
|
|
|
|
|
(list (match (gexp->sexp* exp)
|
|
|
|
|
(('system* command rest ...)
|
|
|
|
|
`(system* ,(and (string-prefix? (%store-prefix) command)
|
|
|
|
|
(basename command))
|
|
|
|
|
,@rest))
|
|
|
|
|
(x x))
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(match (gexp-inputs exp)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
((input)
|
|
|
|
|
(and (eq? (struct-vtable (gexp-input-thing input))
|
|
|
|
|
(@@ (guix gexp) <system-binding>))
|
|
|
|
|
(string=? (gexp-input-output input) "out")
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(gexp-input-native? input)
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
'(system-binding)))
|
2017-11-14 04:16:22 -05:00
|
|
|
|
(x x)))))
|
2020-03-06 05:25:43 -05:00
|
|
|
|
|
2021-11-27 16:10:38 -05:00
|
|
|
|
(test-assert "let-system in file-append"
|
|
|
|
|
(let ((mixed (file-append (let-system (system target)
|
|
|
|
|
(if (not target) grep sed))
|
|
|
|
|
"/bin"))
|
|
|
|
|
(grep (file-append grep "/bin"))
|
|
|
|
|
(sed (file-append sed "/bin")))
|
|
|
|
|
(and (equal? (gexp->sexp* #~(list #$mixed))
|
|
|
|
|
(gexp->sexp* #~(list #$grep)))
|
|
|
|
|
(equal? (gexp->sexp* #~(list #$mixed) "powerpc64le-linux-gnu")
|
|
|
|
|
(gexp->sexp* #~(list #$sed) "powerpc64le-linux-gnu")))))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(test-assert "ungexp + ungexp-native"
|
|
|
|
|
(let* ((exp (gexp (list (ungexp-native %bootstrap-guile)
|
|
|
|
|
(ungexp coreutils)
|
|
|
|
|
(ungexp-native glibc)
|
|
|
|
|
(ungexp binutils))))
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(target "mips64el-linux-gnu")
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(guile (derivation->output-path
|
|
|
|
|
(package-derivation %store %bootstrap-guile)))
|
|
|
|
|
(cu (derivation->output-path
|
|
|
|
|
(package-cross-derivation %store coreutils target)))
|
|
|
|
|
(libc (derivation->output-path
|
|
|
|
|
(package-derivation %store glibc)))
|
|
|
|
|
(bu (derivation->output-path
|
|
|
|
|
(package-cross-derivation %store binutils target))))
|
|
|
|
|
(and (lset= equal?
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,%bootstrap-guile "out" #t)
|
|
|
|
|
(,coreutils "out" #f)
|
|
|
|
|
(,glibc "out" #t)
|
|
|
|
|
(,binutils "out" #f))
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(equal? `(list ,guile ,cu ,libc ,bu)
|
|
|
|
|
(gexp->sexp* exp target)))))
|
|
|
|
|
|
2015-03-22 18:17:37 -04:00
|
|
|
|
(test-equal "ungexp + ungexp-native, nested"
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,%bootstrap-guile "out" #f) (,coreutils "out" #t))
|
2015-03-22 18:17:37 -04:00
|
|
|
|
(let* ((exp (gexp (list (ungexp-native (gexp (ungexp coreutils)))
|
|
|
|
|
(ungexp %bootstrap-guile)))))
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp))))
|
2015-03-22 18:17:37 -04:00
|
|
|
|
|
2016-12-19 11:06:12 -05:00
|
|
|
|
(test-equal "ungexp + ungexp-native, nested, special mixture"
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,coreutils "out" #t))
|
2016-12-19 11:06:12 -05:00
|
|
|
|
|
|
|
|
|
(let* ((foo (gexp (foo (ungexp-native coreutils))))
|
|
|
|
|
(exp (gexp (bar (ungexp foo)))))
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp))))
|
2016-12-19 11:06:12 -05:00
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assert "input list"
|
|
|
|
|
(let ((exp (gexp (display
|
|
|
|
|
'(ungexp (list %bootstrap-guile coreutils)))))
|
|
|
|
|
(guile (derivation->output-path
|
|
|
|
|
(package-derivation %store %bootstrap-guile)))
|
|
|
|
|
(cu (derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils))))
|
|
|
|
|
(and (lset= equal?
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,%bootstrap-guile "out" #f) (,coreutils "out" #f))
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(equal? `(display '(,guile ,cu))
|
|
|
|
|
(gexp->sexp* exp)))))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(test-assert "input list + ungexp-native"
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(let* ((target "mips64el-linux-gnu")
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(exp (gexp (display
|
|
|
|
|
(cons '(ungexp-native (list %bootstrap-guile coreutils))
|
|
|
|
|
'(ungexp (list glibc binutils))))))
|
|
|
|
|
(guile (derivation->output-path
|
|
|
|
|
(package-derivation %store %bootstrap-guile)))
|
|
|
|
|
(cu (derivation->output-path
|
|
|
|
|
(package-derivation %store coreutils)))
|
|
|
|
|
(xlibc (derivation->output-path
|
|
|
|
|
(package-cross-derivation %store glibc target)))
|
|
|
|
|
(xbu (derivation->output-path
|
|
|
|
|
(package-cross-derivation %store binutils target))))
|
|
|
|
|
(and (lset= equal?
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,%bootstrap-guile "out" #t) (,coreutils "out" #t)
|
|
|
|
|
(,glibc "out" #f) (,binutils "out" #f))
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(equal? `(display (cons '(,guile ,cu) '(,xlibc ,xbu)))
|
|
|
|
|
(gexp->sexp* exp target)))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assert "input list splicing"
|
2015-03-15 16:59:19 -04:00
|
|
|
|
(let* ((inputs (list (gexp-input glibc "debug") %bootstrap-guile))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(outputs (list (derivation->output-path
|
|
|
|
|
(package-derivation %store glibc)
|
|
|
|
|
"debug")
|
|
|
|
|
(derivation->output-path
|
|
|
|
|
(package-derivation %store %bootstrap-guile))))
|
|
|
|
|
(exp (gexp (list (ungexp-splicing (cons (+ 2 3) inputs))))))
|
|
|
|
|
(and (lset= equal?
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,glibc "debug" #f) (,%bootstrap-guile "out" #f))
|
gexp: 'gexp-inputs' returns a list of <gexp-input> records.
This slightly reduces memory allocation.
* guix/gexp.scm (lower-inputs): Expect a list of <gexp-input> rather
than a list of tuples.
(lower-reference-graphs)[tuple->gexp-input]: New procedure.
Use it.
(gexp-inputs): Return a list of <gexp-input> rather than a list of
tuples.
* tests/gexp.scm (gexp-input->tuple): New procedure.
("one input package")
("one input package, dotted list")
("one input origin")
("one local file")
("one local file, symlink")
("one plain file")
("two input packages, one derivation, one file")
("file-append")
("file-append, output")
("file-append, nested")
("let-system")
("let-system, nested")
("ungexp + ungexp-native")
("ungexp + ungexp-native, nested")
("ungexp + ungexp-native, nested, special mixture")
("input list")
("input list + ungexp-native")
("input list splicing")
("input list splicing + ungexp-native-splicing")
("gexp list splicing + ungexp-splicing"): Adjust accordingly.
2021-02-16 14:54:27 -05:00
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(equal? (gexp->sexp* exp)
|
|
|
|
|
`(list ,@(cons 5 outputs))))))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(test-assert "input list splicing + ungexp-native-splicing"
|
2016-12-19 11:06:12 -05:00
|
|
|
|
(let* ((inputs (list (gexp-input glibc "debug" #:native? #t)
|
|
|
|
|
%bootstrap-guile))
|
2015-03-15 16:45:37 -04:00
|
|
|
|
(exp (gexp (list (ungexp-native-splicing (cons (+ 2 3) inputs))))))
|
|
|
|
|
(and (lset= equal?
|
2021-02-16 15:46:18 -05:00
|
|
|
|
`((,glibc "debug" #t) (,%bootstrap-guile "out" #t))
|
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
2015-03-15 16:45:37 -04:00
|
|
|
|
(equal? (gexp->sexp* exp) ;native
|
|
|
|
|
(gexp->sexp* exp "mips64el-linux")))))
|
|
|
|
|
|
2017-07-17 17:21:55 -04:00
|
|
|
|
(test-assert "gexp list splicing + ungexp-splicing"
|
|
|
|
|
(let* ((inner (gexp (ungexp-native glibc)))
|
|
|
|
|
(exp (gexp (list (ungexp-splicing (list inner))))))
|
2021-02-16 15:46:18 -05:00
|
|
|
|
(and (equal? `((,glibc "out" #t))
|
|
|
|
|
(map gexp-input->tuple (gexp-inputs exp)))
|
2017-07-17 17:21:55 -04:00
|
|
|
|
(equal? (gexp->sexp* exp) ;native
|
|
|
|
|
(gexp->sexp* exp "mips64el-linux")))))
|
|
|
|
|
|
2015-02-27 16:01:54 -05:00
|
|
|
|
(test-equal "output list"
|
|
|
|
|
2
|
|
|
|
|
(let ((exp (gexp (begin (mkdir (ungexp output))
|
|
|
|
|
(mkdir (ungexp output "bar"))))))
|
|
|
|
|
(length (gexp-outputs exp)))) ;XXX: <output-ref> is private
|
|
|
|
|
|
|
|
|
|
(test-assert "output list, combined gexps"
|
|
|
|
|
(let* ((exp0 (gexp (mkdir (ungexp output))))
|
|
|
|
|
(exp1 (gexp (mkdir (ungexp output "foo"))))
|
|
|
|
|
(exp2 (gexp (begin (display "hi!") (ungexp exp0) (ungexp exp1)))))
|
|
|
|
|
(and (lset= equal?
|
|
|
|
|
(append (gexp-outputs exp0) (gexp-outputs exp1))
|
|
|
|
|
(gexp-outputs exp2))
|
|
|
|
|
(= 2 (length (gexp-outputs exp2))))))
|
|
|
|
|
|
2015-03-02 10:26:13 -05:00
|
|
|
|
(test-equal "output list, combined gexps, duplicate output"
|
|
|
|
|
1
|
|
|
|
|
(let* ((exp0 (gexp (mkdir (ungexp output))))
|
|
|
|
|
(exp1 (gexp (begin (mkdir (ungexp output)) (ungexp exp0))))
|
|
|
|
|
(exp2 (gexp (begin (mkdir (ungexp output)) (ungexp exp1)))))
|
|
|
|
|
(length (gexp-outputs exp2))))
|
|
|
|
|
|
2015-02-27 16:05:40 -05:00
|
|
|
|
(test-assert "output list + ungexp-splicing list, combined gexps"
|
|
|
|
|
(let* ((exp0 (gexp (mkdir (ungexp output))))
|
|
|
|
|
(exp1 (gexp (mkdir (ungexp output "foo"))))
|
|
|
|
|
(exp2 (gexp (begin (display "hi!")
|
|
|
|
|
(ungexp-splicing (list exp0 exp1))))))
|
|
|
|
|
(and (lset= equal?
|
|
|
|
|
(append (gexp-outputs exp0) (gexp-outputs exp1))
|
|
|
|
|
(gexp-outputs exp2))
|
|
|
|
|
(= 2 (length (gexp-outputs exp2))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assertm "gexp->file"
|
|
|
|
|
(mlet* %store-monad ((exp -> (gexp (display (ungexp %bootstrap-guile))))
|
|
|
|
|
(guile (package-file %bootstrap-guile))
|
2021-02-17 08:25:43 -05:00
|
|
|
|
(sexp (gexp->sexp exp (%current-system) #f))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(drv (gexp->file "foo" exp))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv)))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(refs (references* out)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(return (and (equal? sexp (call-with-input-file out read))
|
|
|
|
|
(equal? (list guile) refs)))))
|
|
|
|
|
|
2016-09-09 16:46:36 -04:00
|
|
|
|
(test-assertm "gexp->file + file-append"
|
|
|
|
|
(mlet* %store-monad ((exp -> #~#$(file-append %bootstrap-guile
|
|
|
|
|
"/bin/guile"))
|
|
|
|
|
(guile (package-file %bootstrap-guile))
|
|
|
|
|
(drv (gexp->file "foo" exp))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv)))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(refs (references* out)))
|
2016-09-09 16:46:36 -04:00
|
|
|
|
(return (and (equal? (string-append guile "/bin/guile")
|
|
|
|
|
(call-with-input-file out read))
|
|
|
|
|
(equal? (list guile) refs)))))
|
|
|
|
|
|
2018-04-10 18:52:40 -04:00
|
|
|
|
(test-assertm "gexp->file + #:splice?"
|
|
|
|
|
(mlet* %store-monad ((exp -> (list
|
|
|
|
|
#~(define foo 'bar)
|
|
|
|
|
#~(define guile #$%bootstrap-guile)))
|
|
|
|
|
(guile (package-file %bootstrap-guile))
|
|
|
|
|
(drv (gexp->file "splice" exp #:splice? #t))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv)))
|
|
|
|
|
(refs (references* out)))
|
|
|
|
|
(pk 'splice out)
|
|
|
|
|
(return (and (equal? `((define foo 'bar)
|
|
|
|
|
(define guile ,guile)
|
|
|
|
|
,(call-with-input-string "" read))
|
|
|
|
|
(call-with-input-file out
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(list (read port) (read port) (read port)))))
|
|
|
|
|
(equal? (list guile) refs)))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assertm "gexp->derivation"
|
|
|
|
|
(mlet* %store-monad ((file (text-file "foo" "Hello, world!"))
|
|
|
|
|
(exp -> (gexp
|
|
|
|
|
(begin
|
|
|
|
|
(mkdir (ungexp output))
|
|
|
|
|
(chdir (ungexp output))
|
|
|
|
|
(symlink
|
|
|
|
|
(string-append (ungexp %bootstrap-guile)
|
|
|
|
|
"/bin/guile")
|
|
|
|
|
"foo")
|
|
|
|
|
(symlink (ungexp file)
|
|
|
|
|
(ungexp output "2nd")))))
|
|
|
|
|
(drv (gexp->derivation "foo" exp))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(out2 -> (derivation->output-path drv "2nd"))
|
|
|
|
|
(done (built-derivations (list drv)))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(refs (references* out))
|
|
|
|
|
(refs2 (references* out2))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(guile (package-file %bootstrap-guile "bin/guile")))
|
|
|
|
|
(return (and (string=? (readlink (string-append out "/foo")) guile)
|
|
|
|
|
(string=? (readlink out2) file)
|
|
|
|
|
(equal? refs (list (dirname (dirname guile))))
|
2018-11-26 16:14:11 -05:00
|
|
|
|
(equal? refs2 (list file))
|
|
|
|
|
(null? (derivation-properties drv))))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->derivation properties"
|
|
|
|
|
(mlet %store-monad ((drv (gexp->derivation "foo"
|
|
|
|
|
#~(mkdir #$output)
|
|
|
|
|
#:properties '((type . test)))))
|
|
|
|
|
(return (equal? '((type . test))
|
|
|
|
|
(derivation-properties drv)))))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
2015-02-13 17:14:05 -05:00
|
|
|
|
(test-assertm "gexp->derivation vs. grafts"
|
2016-03-06 15:53:28 -05:00
|
|
|
|
(mlet* %store-monad ((graft? (set-grafting #f))
|
|
|
|
|
(p0 -> (dummy-package "dummy"
|
2015-02-13 17:14:05 -05:00
|
|
|
|
(arguments
|
|
|
|
|
'(#:implicit-inputs? #f))))
|
|
|
|
|
(r -> (package (inherit p0) (name "DuMMY")))
|
|
|
|
|
(p1 -> (package (inherit p0) (replacement r)))
|
|
|
|
|
(exp0 -> (gexp (frob (ungexp p0) (ungexp output))))
|
|
|
|
|
(exp1 -> (gexp (frob (ungexp p1) (ungexp output))))
|
|
|
|
|
(void (set-guile-for-build %bootstrap-guile))
|
2016-03-06 15:53:28 -05:00
|
|
|
|
(drv0 (gexp->derivation "t" exp0 #:graft? #t))
|
|
|
|
|
(drv1 (gexp->derivation "t" exp1 #:graft? #t))
|
|
|
|
|
(drv1* (gexp->derivation "t" exp1 #:graft? #f))
|
|
|
|
|
(_ (set-grafting graft?)))
|
2015-02-13 17:14:05 -05:00
|
|
|
|
(return (and (not (string=? (derivation->output-path drv0)
|
|
|
|
|
(derivation->output-path drv1)))
|
|
|
|
|
(string=? (derivation->output-path drv0)
|
|
|
|
|
(derivation->output-path drv1*))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assertm "gexp->derivation, composed gexps"
|
|
|
|
|
(mlet* %store-monad ((exp0 -> (gexp (begin
|
|
|
|
|
(mkdir (ungexp output))
|
|
|
|
|
(chdir (ungexp output)))))
|
|
|
|
|
(exp1 -> (gexp (symlink
|
|
|
|
|
(string-append (ungexp %bootstrap-guile)
|
|
|
|
|
"/bin/guile")
|
|
|
|
|
"foo")))
|
|
|
|
|
(exp -> (gexp (begin (ungexp exp0) (ungexp exp1))))
|
|
|
|
|
(drv (gexp->derivation "foo" exp))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv)))
|
|
|
|
|
(guile (package-file %bootstrap-guile "bin/guile")))
|
|
|
|
|
(return (string=? (readlink (string-append out "/foo"))
|
|
|
|
|
guile))))
|
|
|
|
|
|
2014-07-12 16:11:12 -04:00
|
|
|
|
(test-assertm "gexp->derivation, default system"
|
|
|
|
|
;; The default system should be the one at '>>=' time, not the one at
|
|
|
|
|
;; invocation time. See <http://bugs.gnu.org/18002>.
|
|
|
|
|
(let ((system (%current-system))
|
|
|
|
|
(mdrv (parameterize ((%current-system "foobar64-linux"))
|
|
|
|
|
(gexp->derivation "foo"
|
|
|
|
|
(gexp
|
|
|
|
|
(mkdir (ungexp output)))))))
|
|
|
|
|
(mlet %store-monad ((drv mdrv))
|
|
|
|
|
(return (string=? system (derivation-system drv))))))
|
|
|
|
|
|
2015-03-28 16:26:33 -04:00
|
|
|
|
(test-assertm "gexp->derivation, local-file"
|
|
|
|
|
(mlet* %store-monad ((file -> (search-path %load-path "guix.scm"))
|
2015-06-18 17:25:49 -04:00
|
|
|
|
(intd (interned-file file #:recursive? #f))
|
2015-03-28 16:26:33 -04:00
|
|
|
|
(local -> (local-file file))
|
|
|
|
|
(exp -> (gexp (begin
|
|
|
|
|
(stat (ungexp local))
|
|
|
|
|
(symlink (ungexp local)
|
|
|
|
|
(ungexp output)))))
|
|
|
|
|
(drv (gexp->derivation "local-file" exp)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(return (string=? (readlink (derivation->output-path drv))
|
|
|
|
|
intd)))))
|
|
|
|
|
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(test-assertm "gexp->derivation, cross-compilation"
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(mlet* %store-monad ((target -> "mips64el-linux-gnu")
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(exp -> (gexp (list (ungexp coreutils)
|
|
|
|
|
(ungexp output))))
|
|
|
|
|
(xdrv (gexp->derivation "foo" exp
|
|
|
|
|
#:target target))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(refs (references*
|
2014-08-17 15:20:11 -04:00
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xcu (package->cross-derivation coreutils
|
|
|
|
|
target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name xcu) refs)
|
|
|
|
|
(not (member (derivation-file-name cu) refs))))))
|
|
|
|
|
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(test-assertm "gexp->derivation, ungexp-native"
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(mlet* %store-monad ((target -> "mips64el-linux-gnu")
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(exp -> (gexp (list (ungexp-native coreutils)
|
|
|
|
|
(ungexp output))))
|
|
|
|
|
(xdrv (gexp->derivation "foo" exp
|
|
|
|
|
#:target target))
|
|
|
|
|
(drv (gexp->derivation "foo" exp)))
|
|
|
|
|
(return (string=? (derivation-file-name drv)
|
|
|
|
|
(derivation-file-name xdrv)))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->derivation, ungexp + ungexp-native"
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(mlet* %store-monad ((target -> "mips64el-linux-gnu")
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(exp -> (gexp (list (ungexp-native coreutils)
|
|
|
|
|
(ungexp glibc)
|
|
|
|
|
(ungexp output))))
|
|
|
|
|
(xdrv (gexp->derivation "foo" exp
|
|
|
|
|
#:target target))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(refs (references*
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xglibc (package->cross-derivation glibc target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name cu) refs)
|
|
|
|
|
(member (derivation-file-name xglibc) refs)))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->derivation, ungexp-native + composed gexps"
|
tests: Fix wrong target triplets.
* tests/gexp.scm (ungexp + ungexp-native,
input list + ungexp-native,
input list splicing + ungexp-native-splicing,
gexp list splicinng + ungexp-splicing,
gexp->derivation, cross-compilation,
gexp->derivation, ungexp-native,
gexp->derivation, ungexp + ungexp-native,
gexp->derivation, ungexp-native + composed gexps): Change
mips64el-linux to mips64el-linux-gnu.
* tests/guix-pack.sh: Change arm-unknown-linux-gnueabihf to
arm-linux-gnueabihf.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2022-05-24 11:55:22 -04:00
|
|
|
|
(mlet* %store-monad ((target -> "mips64el-linux-gnu")
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(exp0 -> (gexp (list 1 2
|
|
|
|
|
(ungexp coreutils))))
|
|
|
|
|
(exp -> (gexp (list 0 (ungexp-native exp0))))
|
|
|
|
|
(xdrv (gexp->derivation "foo" exp
|
|
|
|
|
#:target target))
|
|
|
|
|
(drv (gexp->derivation "foo" exp)))
|
|
|
|
|
(return (string=? (derivation-file-name drv)
|
|
|
|
|
(derivation-file-name xdrv)))))
|
|
|
|
|
|
2014-09-04 17:05:12 -04:00
|
|
|
|
(test-assertm "gexp->derivation, store copy"
|
|
|
|
|
(let ((build-one #~(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display "This is the one." port))))
|
|
|
|
|
(build-two (lambda (one)
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(symlink #$one (string-append #$output "/one"))
|
|
|
|
|
(call-with-output-file (string-append #$output "/two")
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display "This is the second one." port))))))
|
2023-11-23 09:22:42 -05:00
|
|
|
|
(build-drv
|
|
|
|
|
(with-imported-modules '((guix build store-copy)
|
|
|
|
|
(guix build syscalls)
|
|
|
|
|
(guix progress)
|
|
|
|
|
(guix records)
|
|
|
|
|
(guix sets)
|
|
|
|
|
(guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build store-copy)
|
|
|
|
|
(guix build utils)
|
|
|
|
|
(srfi srfi-1))
|
|
|
|
|
|
|
|
|
|
(define (canonical-file? file)
|
|
|
|
|
;; Copied from (guix tests).
|
|
|
|
|
(let ((st (lstat file)))
|
|
|
|
|
(or (not (string-prefix? (%store-directory) file))
|
|
|
|
|
(eq? 'symlink (stat:type st))
|
|
|
|
|
(and (= 1 (stat:mtime st))
|
|
|
|
|
(zero? (logand #o222 (stat:mode st)))))))
|
|
|
|
|
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(populate-store '("graph") #$output
|
|
|
|
|
#:deduplicate? #f)
|
|
|
|
|
|
|
|
|
|
;; Check whether 'populate-store' canonicalizes
|
|
|
|
|
;; permissions and timestamps.
|
|
|
|
|
(unless (every canonical-file? (find-files #$output))
|
|
|
|
|
(error "not canonical!" #$output))))))
|
2014-09-04 17:05:12 -04:00
|
|
|
|
(mlet* %store-monad ((one (gexp->derivation "one" build-one))
|
|
|
|
|
(two (gexp->derivation "two" (build-two one)))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(drv (gexp->derivation "store-copy" build-drv
|
2014-09-04 17:05:12 -04:00
|
|
|
|
#:references-graphs
|
2023-11-23 09:22:42 -05:00
|
|
|
|
`(("graph" ,two))))
|
2014-09-04 17:05:12 -04:00
|
|
|
|
(ok? (built-derivations (list drv)))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(let ((one (derivation->output-path one))
|
|
|
|
|
(two (derivation->output-path two)))
|
|
|
|
|
(return (and ok?
|
|
|
|
|
(file-exists? (string-append out "/" one))
|
|
|
|
|
(file-exists? (string-append out "/" two))
|
|
|
|
|
(file-exists? (string-append out "/" two "/two"))
|
|
|
|
|
(string=? (readlink (string-append out "/" two "/one"))
|
|
|
|
|
one)))))))
|
|
|
|
|
|
2015-02-13 11:23:17 -05:00
|
|
|
|
(test-assertm "imported-files"
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((files -> `(("x" . ,(search-path %load-path "ice-9/q.scm"))
|
|
|
|
|
("a/b/c" . ,(search-path %load-path
|
|
|
|
|
"guix/derivations.scm"))
|
|
|
|
|
("p/q" . ,(search-path %load-path "guix.scm"))
|
|
|
|
|
("p/z" . ,(search-path %load-path "guix/store.scm"))))
|
2018-07-16 05:17:55 -04:00
|
|
|
|
(dir (imported-files files)))
|
2015-02-13 11:23:17 -05:00
|
|
|
|
(mbegin %store-monad
|
2018-07-16 05:17:55 -04:00
|
|
|
|
(return
|
|
|
|
|
(every (match-lambda
|
|
|
|
|
((path . source)
|
|
|
|
|
(equal? (call-with-input-file (string-append dir "/" path)
|
|
|
|
|
get-bytevector-all)
|
|
|
|
|
(call-with-input-file source
|
|
|
|
|
get-bytevector-all))))
|
|
|
|
|
files)))))
|
2015-02-13 11:23:17 -05:00
|
|
|
|
|
2017-03-15 17:14:36 -04:00
|
|
|
|
(test-assertm "imported-files with file-like objects"
|
|
|
|
|
(mlet* %store-monad ((plain -> (plain-file "foo" "bar!"))
|
|
|
|
|
(q-scm -> (search-path %load-path "ice-9/q.scm"))
|
|
|
|
|
(files -> `(("a/b/c" . ,q-scm)
|
|
|
|
|
("p/q" . ,plain)))
|
|
|
|
|
(drv (imported-files files)))
|
|
|
|
|
(mbegin %store-monad
|
2018-07-26 16:59:49 -04:00
|
|
|
|
(built-derivations (list (pk 'drv drv)))
|
2017-03-15 17:14:36 -04:00
|
|
|
|
(mlet %store-monad ((dir -> (derivation->output-path drv))
|
|
|
|
|
(plain* (text-file "foo" "bar!"))
|
|
|
|
|
(q-scm* (interned-file q-scm "c")))
|
|
|
|
|
(return
|
2021-11-13 10:11:25 -05:00
|
|
|
|
(and (file=? (string-append dir "/a/b/c") q-scm* stat)
|
|
|
|
|
(file=? (string-append dir "/p/q") plain* stat)))))))
|
2017-03-15 17:14:36 -04:00
|
|
|
|
|
2016-07-03 16:26:19 -04:00
|
|
|
|
(test-equal "gexp-modules & ungexp"
|
|
|
|
|
'((bar) (foo))
|
|
|
|
|
((@@ (guix gexp) gexp-modules)
|
|
|
|
|
#~(foo #$(with-imported-modules '((foo)) #~+)
|
|
|
|
|
#+(with-imported-modules '((bar)) #~-))))
|
|
|
|
|
|
|
|
|
|
(test-equal "gexp-modules & ungexp-splicing"
|
|
|
|
|
'((foo) (bar))
|
|
|
|
|
((@@ (guix gexp) gexp-modules)
|
|
|
|
|
#~(foo #$@(list (with-imported-modules '((foo)) #~+)
|
|
|
|
|
(with-imported-modules '((bar)) #~-)))))
|
|
|
|
|
|
2018-10-27 09:45:45 -04:00
|
|
|
|
(test-assert "gexp-modules deletes duplicates" ;<https://bugs.gnu.org/32966>
|
|
|
|
|
(let ((make-file (lambda ()
|
|
|
|
|
;; Use 'eval' to make sure we get an object that's not
|
|
|
|
|
;; 'eq?' nor 'equal?' due to the closures it embeds.
|
|
|
|
|
(eval '(scheme-file "bar.scm" #~(define-module (bar)))
|
|
|
|
|
(current-module)))))
|
|
|
|
|
(define result
|
|
|
|
|
((@@ (guix gexp) gexp-modules)
|
|
|
|
|
(with-imported-modules `(((bar) => ,(make-file))
|
|
|
|
|
((bar) => ,(make-file))
|
|
|
|
|
(foo) (foo))
|
|
|
|
|
#~+)))
|
|
|
|
|
|
|
|
|
|
(match result
|
|
|
|
|
(((('bar) '=> (? scheme-file?)) ('foo)) #t))))
|
|
|
|
|
|
2017-04-19 10:11:25 -04:00
|
|
|
|
(test-equal "gexp-modules and literal Scheme object"
|
|
|
|
|
'()
|
|
|
|
|
(gexp-modules #t))
|
|
|
|
|
|
2020-11-05 08:52:29 -05:00
|
|
|
|
(test-assert "gexp-modules, warning"
|
|
|
|
|
(string-match "tests/gexp.scm:[0-9]+:[0-9]+: warning: \
|
|
|
|
|
importing.* \\(guix config\\) from the host"
|
|
|
|
|
(call-with-output-string
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(parameterize ((guix-warning-port port))
|
|
|
|
|
(let* ((x (with-imported-modules '((guix config))
|
|
|
|
|
#~(+ 1 2 3)))
|
|
|
|
|
(y #~(+ 39 #$x)))
|
|
|
|
|
(gexp-modules y)))))))
|
|
|
|
|
|
2015-02-13 11:23:17 -05:00
|
|
|
|
(test-assertm "gexp->derivation #:modules"
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((build -> #~(begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(mkdir-p (string-append #$output "/guile/guix/nix"))
|
|
|
|
|
#t))
|
|
|
|
|
(drv (gexp->derivation "test-with-modules" build
|
|
|
|
|
#:modules '((guix build utils)))))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((p (derivation->output-path drv))
|
|
|
|
|
(s (stat (string-append p "/guile/guix/nix"))))
|
|
|
|
|
(return (eq? (stat:type s) 'directory))))))
|
|
|
|
|
|
2016-07-03 16:26:19 -04:00
|
|
|
|
(test-assertm "gexp->derivation & with-imported-modules"
|
|
|
|
|
;; Same test as above, but using 'with-imported-modules'.
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((build -> (with-imported-modules '((guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(mkdir-p (string-append #$output "/guile/guix/nix"))
|
|
|
|
|
#t)))
|
|
|
|
|
(drv (gexp->derivation "test-with-modules" build)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((p (derivation->output-path drv))
|
|
|
|
|
(s (stat (string-append p "/guile/guix/nix"))))
|
|
|
|
|
(return (eq? (stat:type s) 'directory))))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->derivation & nested with-imported-modules"
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((build1 -> (with-imported-modules '((guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(mkdir-p (string-append #$output "/guile/guix/nix"))
|
|
|
|
|
#t)))
|
|
|
|
|
(build2 -> (with-imported-modules '((guix build bournish))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build bournish)
|
|
|
|
|
(system base compile))
|
|
|
|
|
#+build1
|
|
|
|
|
(call-with-output-file (string-append #$output "/b")
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(write
|
|
|
|
|
(read-and-compile (open-input-string "cd /foo")
|
|
|
|
|
#:from %bournish-language
|
|
|
|
|
#:to 'scheme)
|
|
|
|
|
port))))))
|
|
|
|
|
(drv (gexp->derivation "test-with-modules" build2)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((p (derivation->output-path drv))
|
|
|
|
|
(s (stat (string-append p "/guile/guix/nix")))
|
|
|
|
|
(b (string-append p "/b")))
|
|
|
|
|
(return (and (eq? (stat:type s) 'directory)
|
|
|
|
|
(equal? '(chdir "/foo")
|
|
|
|
|
(call-with-input-file b read))))))))
|
|
|
|
|
|
2017-03-15 17:14:36 -04:00
|
|
|
|
(test-assertm "gexp->derivation & with-imported-module & computed module"
|
|
|
|
|
(mlet* %store-monad
|
2018-04-10 18:52:40 -04:00
|
|
|
|
((module -> (scheme-file "x" #~(;; splice!
|
2017-03-15 17:14:36 -04:00
|
|
|
|
(define-module (foo bar)
|
|
|
|
|
#:export (the-answer))
|
|
|
|
|
|
2018-04-10 18:52:40 -04:00
|
|
|
|
(define the-answer 42))
|
|
|
|
|
#:splice? #t))
|
2017-03-15 17:14:36 -04:00
|
|
|
|
(build -> (with-imported-modules `(((foo bar) => ,module)
|
|
|
|
|
(guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(foo bar))
|
|
|
|
|
mkdir-p
|
|
|
|
|
(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(write the-answer port))))))
|
|
|
|
|
(drv (gexp->derivation "thing" build))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(return (= 42 (call-with-input-file out read))))))
|
|
|
|
|
|
2018-05-28 12:14:37 -04:00
|
|
|
|
(test-equal "gexp-extensions & ungexp"
|
|
|
|
|
(list sed grep)
|
|
|
|
|
((@@ (guix gexp) gexp-extensions)
|
|
|
|
|
#~(foo #$(with-extensions (list grep) #~+)
|
|
|
|
|
#+(with-extensions (list sed) #~-))))
|
|
|
|
|
|
|
|
|
|
(test-equal "gexp-extensions & ungexp-splicing"
|
|
|
|
|
(list grep sed)
|
|
|
|
|
((@@ (guix gexp) gexp-extensions)
|
|
|
|
|
#~(foo #$@(list (with-extensions (list grep) #~+)
|
|
|
|
|
(with-imported-modules '((foo))
|
|
|
|
|
(with-extensions (list sed) #~-))))))
|
|
|
|
|
|
|
|
|
|
(test-equal "gexp-extensions and literal Scheme object"
|
|
|
|
|
'()
|
|
|
|
|
((@@ (guix gexp) gexp-extensions) #t))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->derivation & with-extensions"
|
|
|
|
|
;; Create a fake Guile extension and make sure it is accessible both to the
|
|
|
|
|
;; imported modules and to the derivation build script.
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((extension -> %extension-package)
|
|
|
|
|
(module -> (scheme-file "x" #~( ;; splice!
|
|
|
|
|
(define-module (foo)
|
|
|
|
|
#:use-module (hg2g)
|
|
|
|
|
#:export (multiply))
|
|
|
|
|
|
|
|
|
|
(define (multiply x)
|
|
|
|
|
(* the-answer x)))
|
|
|
|
|
#:splice? #t))
|
|
|
|
|
(build -> (with-extensions (list extension)
|
|
|
|
|
(with-imported-modules `((guix build utils)
|
|
|
|
|
((foo) => ,module))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(hg2g) (foo))
|
|
|
|
|
(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(write (list the-answer (multiply 2))
|
|
|
|
|
port)))))))
|
|
|
|
|
(drv (gexp->derivation "thingie" build
|
|
|
|
|
;; %BOOTSTRAP-GUILE is 2.0.
|
|
|
|
|
#:effective-version "2.0"))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(return (equal? '(42 84) (call-with-input-file out read))))))
|
|
|
|
|
|
2019-06-10 08:34:36 -04:00
|
|
|
|
(test-assertm "lower-gexp"
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((extension -> %extension-package)
|
|
|
|
|
(extension-drv (package->derivation %extension-package))
|
|
|
|
|
(coreutils-drv (package->derivation coreutils))
|
|
|
|
|
(exp -> (with-extensions (list extension)
|
|
|
|
|
(with-imported-modules `((guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build utils)
|
|
|
|
|
(hg2g))
|
|
|
|
|
#$coreutils:debug
|
|
|
|
|
mkdir-p
|
|
|
|
|
the-answer))))
|
|
|
|
|
(lexp (lower-gexp exp
|
|
|
|
|
#:effective-version "2.0")))
|
|
|
|
|
(define (matching-input drv output)
|
|
|
|
|
(lambda (input)
|
2019-07-09 17:05:01 -04:00
|
|
|
|
(and (eq? (derivation-input-derivation input) drv)
|
|
|
|
|
(equal? (derivation-input-sub-derivations input)
|
|
|
|
|
(list output)))))
|
2019-06-10 08:34:36 -04:00
|
|
|
|
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(return (and (find (matching-input extension-drv "out")
|
|
|
|
|
(lowered-gexp-inputs (pk 'lexp lexp)))
|
|
|
|
|
(find (matching-input coreutils-drv "debug")
|
|
|
|
|
(lowered-gexp-inputs lexp))
|
|
|
|
|
(member (string-append
|
|
|
|
|
(derivation->output-path extension-drv)
|
|
|
|
|
"/share/guile/site/2.0")
|
|
|
|
|
(lowered-gexp-load-path lexp))
|
|
|
|
|
(= 2 (length (lowered-gexp-load-path lexp)))
|
|
|
|
|
(member (string-append
|
|
|
|
|
(derivation->output-path extension-drv)
|
|
|
|
|
"/lib/guile/2.0/site-ccache")
|
|
|
|
|
(lowered-gexp-load-compiled-path lexp))
|
|
|
|
|
(= 2 (length (lowered-gexp-load-compiled-path lexp)))
|
2019-07-10 12:39:25 -04:00
|
|
|
|
(eq? (derivation-input-derivation (lowered-gexp-guile lexp))
|
|
|
|
|
(%guile-for-build)))))))
|
2019-06-10 08:34:36 -04:00
|
|
|
|
|
2019-12-06 17:12:49 -05:00
|
|
|
|
(test-assertm "lower-gexp, raw-derivation-file"
|
|
|
|
|
(mlet* %store-monad ((thing -> (program-file "prog" #~(display "hi!")))
|
|
|
|
|
(exp -> #~(list #$(raw-derivation-file thing)))
|
|
|
|
|
(drv (lower-object thing))
|
|
|
|
|
(lexp (lower-gexp exp #:effective-version "2.0")))
|
|
|
|
|
(return (and (equal? `(list ,(derivation-file-name drv))
|
|
|
|
|
(lowered-gexp-sexp lexp))
|
|
|
|
|
(equal? (list (derivation-file-name drv))
|
|
|
|
|
(lowered-gexp-sources lexp))
|
|
|
|
|
(null? (lowered-gexp-inputs lexp))))))
|
|
|
|
|
|
2019-09-23 16:17:39 -04:00
|
|
|
|
(test-eq "lower-gexp, non-self-quoting input"
|
|
|
|
|
+
|
|
|
|
|
(guard (c ((gexp-input-error? c)
|
|
|
|
|
(gexp-error-invalid-input c)))
|
|
|
|
|
(run-with-store %store
|
|
|
|
|
(lower-gexp #~(foo #$+)))))
|
|
|
|
|
|
2019-12-15 15:27:31 -05:00
|
|
|
|
(test-equal "lower-gexp, character literal"
|
|
|
|
|
'(#\+)
|
|
|
|
|
(lowered-gexp-sexp
|
|
|
|
|
(run-with-store %store
|
|
|
|
|
(lower-gexp #~(#\+)))))
|
|
|
|
|
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(test-assertm "gexp->derivation #:references-graphs"
|
|
|
|
|
(mlet* %store-monad
|
2015-07-20 07:36:36 -04:00
|
|
|
|
((one (text-file "one" (random-text)))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(two (gexp->derivation "two"
|
|
|
|
|
#~(symlink #$one #$output:chbouib)))
|
2016-07-12 12:00:16 -04:00
|
|
|
|
(build -> (with-imported-modules '((guix build store-copy)
|
2018-09-27 17:46:44 -04:00
|
|
|
|
(guix progress)
|
|
|
|
|
(guix records)
|
2018-06-04 16:06:34 -04:00
|
|
|
|
(guix sets)
|
2016-07-12 12:00:16 -04:00
|
|
|
|
(guix build utils))
|
|
|
|
|
#~(begin
|
|
|
|
|
(use-modules (guix build store-copy))
|
|
|
|
|
(with-output-to-file #$output
|
|
|
|
|
(lambda ()
|
2018-06-04 16:06:34 -04:00
|
|
|
|
(write (map store-info-item
|
|
|
|
|
(call-with-input-file "guile"
|
|
|
|
|
read-reference-graph)))))
|
2016-07-12 12:00:16 -04:00
|
|
|
|
(with-output-to-file #$output:one
|
|
|
|
|
(lambda ()
|
2018-06-04 16:06:34 -04:00
|
|
|
|
(write (map store-info-item
|
|
|
|
|
(call-with-input-file "one"
|
|
|
|
|
read-reference-graph)))))
|
2016-07-12 12:00:16 -04:00
|
|
|
|
(with-output-to-file #$output:two
|
|
|
|
|
(lambda ()
|
2018-06-04 16:06:34 -04:00
|
|
|
|
(write (map store-info-item
|
|
|
|
|
(call-with-input-file "two"
|
|
|
|
|
read-reference-graph))))))))
|
2016-07-12 12:00:16 -04:00
|
|
|
|
(drv (gexp->derivation "ref-graphs" build
|
2014-09-06 09:45:32 -04:00
|
|
|
|
#:references-graphs `(("one" ,one)
|
|
|
|
|
("two" ,two "chbouib")
|
2016-07-12 12:00:16 -04:00
|
|
|
|
("guile" ,%bootstrap-guile))))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(ok? (built-derivations (list drv)))
|
|
|
|
|
(guile-drv (package->derivation %bootstrap-guile))
|
2015-07-11 16:37:08 -04:00
|
|
|
|
(bash (interned-file (search-bootstrap-binary "bash"
|
|
|
|
|
(%current-system))
|
|
|
|
|
"bash" #:recursive? #t))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
(g-one -> (derivation->output-path drv "one"))
|
|
|
|
|
(g-two -> (derivation->output-path drv "two"))
|
|
|
|
|
(g-guile -> (derivation->output-path drv)))
|
|
|
|
|
(return (and ok?
|
|
|
|
|
(equal? (call-with-input-file g-one read) (list one))
|
2015-07-20 07:36:36 -04:00
|
|
|
|
(lset= string=?
|
|
|
|
|
(call-with-input-file g-two read)
|
|
|
|
|
(list one (derivation->output-path two "chbouib")))
|
2015-07-11 16:37:08 -04:00
|
|
|
|
|
|
|
|
|
;; Note: %BOOTSTRAP-GUILE depends on the bootstrap Bash.
|
2015-07-20 07:36:36 -04:00
|
|
|
|
(lset= string=?
|
|
|
|
|
(call-with-input-file g-guile read)
|
|
|
|
|
(list (derivation->output-path guile-drv) bash))))))
|
2014-09-06 09:45:32 -04:00
|
|
|
|
|
2021-03-03 06:27:18 -05:00
|
|
|
|
(test-assertm "gexp->derivation #:references-graphs cross-compilation"
|
|
|
|
|
;; The objects passed in #:references-graphs implicitly refer to
|
|
|
|
|
;; cross-compiled derivations. Make sure this is the case.
|
|
|
|
|
(mlet* %store-monad ((drv1 (lower-object coreutils (%current-system)
|
|
|
|
|
#:target "i586-pc-gnu"))
|
|
|
|
|
(drv2 (lower-object coreutils (%current-system)
|
|
|
|
|
#:target #f))
|
|
|
|
|
(drv3 (gexp->derivation "three"
|
|
|
|
|
#~(symlink #$coreutils #$output)
|
|
|
|
|
#:target "i586-pc-gnu"
|
|
|
|
|
#:references-graphs
|
|
|
|
|
`(("coreutils" ,coreutils))))
|
|
|
|
|
(refs (references* (derivation-file-name drv3))))
|
|
|
|
|
(return (and (member (derivation-file-name drv1) refs)
|
|
|
|
|
(not (member (derivation-file-name drv2) refs))))))
|
|
|
|
|
|
2015-02-11 16:10:14 -05:00
|
|
|
|
(test-assertm "gexp->derivation #:allowed-references"
|
|
|
|
|
(mlet %store-monad ((drv (gexp->derivation "allowed-refs"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(chdir #$output)
|
|
|
|
|
(symlink #$output "self")
|
|
|
|
|
(symlink #$%bootstrap-guile
|
|
|
|
|
"guile"))
|
|
|
|
|
#:allowed-references
|
|
|
|
|
(list "out" %bootstrap-guile))))
|
|
|
|
|
(built-derivations (list drv))))
|
|
|
|
|
|
2015-03-21 18:21:53 -04:00
|
|
|
|
(test-assertm "gexp->derivation #:allowed-references, specific output"
|
|
|
|
|
(mlet* %store-monad ((in (gexp->derivation "thing"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output:ok)
|
|
|
|
|
(mkdir #$output:not-ok))))
|
|
|
|
|
(drv (gexp->derivation "allowed-refs"
|
|
|
|
|
#~(begin
|
|
|
|
|
(pk #$in:not-ok)
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(chdir #$output)
|
|
|
|
|
(symlink #$output "self")
|
|
|
|
|
(symlink #$in:ok "ok"))
|
|
|
|
|
#:allowed-references
|
|
|
|
|
(list "out"
|
|
|
|
|
(gexp-input in "ok")))))
|
|
|
|
|
(built-derivations (list drv))))
|
|
|
|
|
|
2015-02-11 16:10:14 -05:00
|
|
|
|
(test-assert "gexp->derivation #:allowed-references, disallowed"
|
|
|
|
|
(let ((drv (run-with-store %store
|
|
|
|
|
(gexp->derivation "allowed-refs"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(chdir #$output)
|
|
|
|
|
(symlink #$%bootstrap-guile "guile"))
|
|
|
|
|
#:allowed-references '()))))
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 11:41:11 -05:00
|
|
|
|
(guard (c ((store-protocol-error? c) #t))
|
2015-02-11 16:10:14 -05:00
|
|
|
|
(build-derivations %store (list drv))
|
|
|
|
|
#f)))
|
|
|
|
|
|
2016-03-20 17:44:03 -04:00
|
|
|
|
(test-assertm "gexp->derivation #:disallowed-references, allowed"
|
|
|
|
|
(mlet %store-monad ((drv (gexp->derivation "disallowed-refs"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(chdir #$output)
|
|
|
|
|
(symlink #$output "self")
|
|
|
|
|
(symlink #$%bootstrap-guile
|
|
|
|
|
"guile"))
|
|
|
|
|
#:disallowed-references '())))
|
|
|
|
|
(built-derivations (list drv))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(test-assert "gexp->derivation #:disallowed-references"
|
|
|
|
|
(let ((drv (run-with-store %store
|
|
|
|
|
(gexp->derivation "disallowed-refs"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(chdir #$output)
|
|
|
|
|
(symlink #$%bootstrap-guile "guile"))
|
|
|
|
|
#:disallowed-references (list %bootstrap-guile)))))
|
store: Rename '&nix-error' to '&store-error'.
* guix/store.scm (&nix-error): Rename to...
(&store-error): ... this, and adjust users.
(&nix-connection-error): Rename to...
(&store-connection-error): ... this, and adjust users.
(&nix-protocol-error): Rename to...
(&store-protocol-error): ... this, adjust users.
(&nix-error, &nix-connection-error, &nix-protocol-error): Define these
condition types and their getters as deprecrated aliases.
* build-aux/run-system-tests.scm, guix/derivations.scm,
guix/grafts.scm, guix/scripts/challenge.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/offload.scm, guix/serialization.scm,
guix/ssh.scm, guix/tests.scm, guix/ui.scm,
tests/derivations.scm, tests/gexp.scm, tests/guix-daemon.sh,
tests/packages.scm, tests/store.scm, doc/guix.texi: Adjust to use the
new names.
2019-01-21 11:41:11 -05:00
|
|
|
|
(guard (c ((store-protocol-error? c) #t))
|
2016-03-20 17:44:03 -04:00
|
|
|
|
(build-derivations %store (list drv))
|
|
|
|
|
#f)))
|
|
|
|
|
|
2014-06-04 11:26:54 -04:00
|
|
|
|
(define shebang
|
2014-08-23 13:18:01 -04:00
|
|
|
|
(string-append "#!" (derivation->output-path (%guile-for-build))
|
2014-06-04 11:26:54 -04:00
|
|
|
|
"/bin/guile --no-auto-compile"))
|
|
|
|
|
|
|
|
|
|
;; If we're going to hit the silly shebang limit (128 chars on Linux-based
|
|
|
|
|
;; systems), then skip the following test.
|
2015-11-04 05:59:46 -05:00
|
|
|
|
(test-skip (if (> (string-length shebang) 127) 2 0))
|
2014-06-04 11:26:54 -04:00
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-assertm "gexp->script"
|
|
|
|
|
(mlet* %store-monad ((n -> (random (expt 2 50)))
|
|
|
|
|
(exp -> (gexp
|
|
|
|
|
(system*
|
|
|
|
|
(string-append (ungexp %bootstrap-guile)
|
|
|
|
|
"/bin/guile")
|
|
|
|
|
"-c" (object->string
|
|
|
|
|
'(display (expt (ungexp n) 2))))))
|
|
|
|
|
(drv (gexp->script "guile-thing" exp
|
|
|
|
|
#:guile %bootstrap-guile))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv))))
|
|
|
|
|
(let* ((pipe (open-input-pipe out))
|
|
|
|
|
(str (get-string-all pipe)))
|
|
|
|
|
(return (and (zero? (close-pipe pipe))
|
|
|
|
|
(= (expt n 2) (string->number str)))))))
|
|
|
|
|
|
2018-07-13 15:53:25 -04:00
|
|
|
|
(test-assert "gexp->script #:module-path"
|
2018-03-23 13:21:28 -04:00
|
|
|
|
(call-with-temporary-directory
|
|
|
|
|
(lambda (directory)
|
|
|
|
|
(define str
|
|
|
|
|
"Fake (guix base32) module!")
|
|
|
|
|
|
|
|
|
|
(mkdir (string-append directory "/guix"))
|
|
|
|
|
(call-with-output-file (string-append directory "/guix/base32.scm")
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(write `(begin (define-module (guix base32))
|
|
|
|
|
(define-public %fake! ,str))
|
|
|
|
|
port)))
|
|
|
|
|
|
2018-07-13 15:53:25 -04:00
|
|
|
|
(run-with-store %store
|
|
|
|
|
(mlet* %store-monad ((exp -> (with-imported-modules '((guix base32))
|
|
|
|
|
(gexp (begin
|
|
|
|
|
(use-modules (guix base32))
|
|
|
|
|
(write (list %load-path
|
|
|
|
|
%fake!))))))
|
|
|
|
|
(drv (gexp->script "guile-thing" exp
|
|
|
|
|
#:guile %bootstrap-guile
|
|
|
|
|
#:module-path (list directory)))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(done (built-derivations (list drv))))
|
|
|
|
|
(let* ((pipe (open-input-pipe out))
|
|
|
|
|
(data (read pipe)))
|
|
|
|
|
(return (and (zero? (close-pipe pipe))
|
|
|
|
|
(match data
|
|
|
|
|
((load-path str*)
|
|
|
|
|
(and (string=? str* str)
|
|
|
|
|
(not (member directory load-path)))))))))))))
|
2018-03-23 13:21:28 -04:00
|
|
|
|
|
2015-09-08 16:44:26 -04:00
|
|
|
|
(test-assertm "program-file"
|
|
|
|
|
(let* ((n (random (expt 2 50)))
|
2016-07-03 16:26:19 -04:00
|
|
|
|
(exp (with-imported-modules '((guix build utils))
|
|
|
|
|
(gexp (begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(display (ungexp n))))))
|
2015-09-08 16:44:26 -04:00
|
|
|
|
(file (program-file "program" exp
|
|
|
|
|
#:guile %bootstrap-guile)))
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object file))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((pipe (open-input-pipe out))
|
|
|
|
|
(str (get-string-all pipe)))
|
|
|
|
|
(return (and (zero? (close-pipe pipe))
|
|
|
|
|
(= n (string->number str)))))))))
|
|
|
|
|
|
2018-07-13 15:53:25 -04:00
|
|
|
|
(test-assert "program-file #:module-path"
|
2018-03-23 13:35:32 -04:00
|
|
|
|
(call-with-temporary-directory
|
|
|
|
|
(lambda (directory)
|
|
|
|
|
(define text (random-text))
|
|
|
|
|
|
|
|
|
|
(call-with-output-file (string-append directory "/stupid-module.scm")
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(write `(begin (define-module (stupid-module))
|
|
|
|
|
(define-public %stupid-thing ,text))
|
|
|
|
|
port)))
|
|
|
|
|
|
|
|
|
|
(let* ((exp (with-imported-modules '((stupid-module))
|
|
|
|
|
(gexp (begin
|
|
|
|
|
(use-modules (stupid-module))
|
|
|
|
|
(display %stupid-thing)))))
|
|
|
|
|
(file (program-file "program" exp
|
|
|
|
|
#:guile %bootstrap-guile
|
|
|
|
|
#:module-path (list directory))))
|
2018-07-13 15:53:25 -04:00
|
|
|
|
(run-with-store %store
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object file))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((pipe (open-input-pipe out))
|
|
|
|
|
(str (get-string-all pipe)))
|
|
|
|
|
(return (and (zero? (close-pipe pipe))
|
|
|
|
|
(string=? text str)))))))))))
|
2018-03-23 13:35:32 -04:00
|
|
|
|
|
2018-05-28 12:14:37 -04:00
|
|
|
|
(test-assertm "program-file & with-extensions"
|
|
|
|
|
(let* ((exp (with-extensions (list %extension-package)
|
|
|
|
|
(gexp (begin
|
|
|
|
|
(use-modules (hg2g))
|
|
|
|
|
(display the-answer)))))
|
|
|
|
|
(file (program-file "program" exp
|
|
|
|
|
#:guile %bootstrap-guile)))
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object file))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(let* ((pipe (open-input-pipe out))
|
|
|
|
|
(str (get-string-all pipe)))
|
|
|
|
|
(return (and (zero? (close-pipe pipe))
|
|
|
|
|
(= 42 (string->number str)))))))))
|
|
|
|
|
|
2019-07-26 17:48:03 -04:00
|
|
|
|
(test-assertm "program-file #:system"
|
|
|
|
|
(let* ((exp (with-imported-modules '((guix build utils))
|
|
|
|
|
(gexp (begin
|
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
|
(display "hi!")))))
|
|
|
|
|
(system (if (string=? (%current-system) "x86_64-linux")
|
|
|
|
|
"armhf-linux"
|
|
|
|
|
"x86_64-linux"))
|
|
|
|
|
(file (program-file "program" exp)))
|
|
|
|
|
(mlet %store-monad ((drv (lower-object file system)))
|
|
|
|
|
(return (and (string=? (derivation-system drv) system)
|
|
|
|
|
(find (lambda (input)
|
|
|
|
|
(let ((drv (pk (derivation-input-derivation input))))
|
|
|
|
|
(and (string=? (derivation-name drv)
|
|
|
|
|
"module-import-compiled")
|
|
|
|
|
(string=? (derivation-system drv)
|
|
|
|
|
system))))
|
|
|
|
|
(derivation-inputs drv)))))))
|
|
|
|
|
|
2015-09-16 09:03:52 -04:00
|
|
|
|
(test-assertm "scheme-file"
|
|
|
|
|
(let* ((text (plain-file "foo" "Hello, world!"))
|
|
|
|
|
(scheme (scheme-file "bar" #~(list "foo" #$text))))
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object scheme))
|
|
|
|
|
(text (lower-object text))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(mlet %store-monad ((refs (references* out)))
|
2015-09-16 09:03:52 -04:00
|
|
|
|
(return (and (equal? refs (list text))
|
|
|
|
|
(equal? `(list "foo" ,text)
|
|
|
|
|
(call-with-input-file out read)))))))))
|
|
|
|
|
|
2019-12-06 17:12:49 -05:00
|
|
|
|
(test-assertm "raw-derivation-file"
|
|
|
|
|
(let* ((exp #~(let ((drv #$(raw-derivation-file coreutils)))
|
|
|
|
|
(when (file-exists? drv)
|
|
|
|
|
(symlink drv #$output)))))
|
|
|
|
|
(mlet* %store-monad ((dep (lower-object coreutils))
|
|
|
|
|
(drv (gexp->derivation "drv-ref" exp))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(mlet %store-monad ((refs (references* out)))
|
|
|
|
|
(return (and (member (derivation-file-name dep)
|
|
|
|
|
(derivation-sources drv))
|
|
|
|
|
(not (member (derivation-file-name dep)
|
|
|
|
|
(map derivation-input-path
|
|
|
|
|
(derivation-inputs drv))))
|
|
|
|
|
(equal? (readlink out) (derivation-file-name dep))
|
|
|
|
|
(equal? refs (list (derivation-file-name dep))))))))))
|
|
|
|
|
|
2015-01-12 17:26:52 -05:00
|
|
|
|
(test-assert "text-file*"
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(run-with-store %store
|
|
|
|
|
(mlet* %store-monad
|
|
|
|
|
((drv (package->derivation %bootstrap-guile))
|
|
|
|
|
(guile -> (derivation->output-path drv))
|
|
|
|
|
(file (text-file "bar" "This is bar."))
|
|
|
|
|
(text (text-file* "foo"
|
|
|
|
|
%bootstrap-guile "/bin/guile "
|
|
|
|
|
(gexp-input %bootstrap-guile "out") "/bin/guile "
|
|
|
|
|
drv "/bin/guile "
|
|
|
|
|
file))
|
|
|
|
|
(done (built-derivations (list text)))
|
|
|
|
|
(out -> (derivation->output-path text))
|
|
|
|
|
(refs (references* out)))
|
|
|
|
|
;; Make sure we get the right references and the right content.
|
|
|
|
|
(return (and (lset= string=? refs (list guile file))
|
|
|
|
|
(equal? (call-with-input-file out get-string-all)
|
|
|
|
|
(string-append guile "/bin/guile "
|
|
|
|
|
guile "/bin/guile "
|
|
|
|
|
guile "/bin/guile "
|
|
|
|
|
file)))))
|
|
|
|
|
#:guile-for-build (package-derivation %store %bootstrap-guile)))
|
2015-01-12 17:26:52 -05:00
|
|
|
|
|
2015-09-09 03:44:43 -04:00
|
|
|
|
(test-assertm "mixed-text-file"
|
|
|
|
|
(mlet* %store-monad ((file -> (mixed-text-file "mixed"
|
2022-02-11 17:17:00 -05:00
|
|
|
|
#:guile %bootstrap-guile
|
2015-09-09 03:44:43 -04:00
|
|
|
|
"export PATH="
|
|
|
|
|
%bootstrap-guile "/bin"))
|
|
|
|
|
(drv (lower-object file))
|
|
|
|
|
(out -> (derivation->output-path drv))
|
|
|
|
|
(guile-drv (package->derivation %bootstrap-guile))
|
|
|
|
|
(guile -> (derivation->output-path guile-drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
2016-11-19 11:05:07 -05:00
|
|
|
|
(mlet %store-monad ((refs (references* out)))
|
2015-09-09 03:44:43 -04:00
|
|
|
|
(return (and (string=? (string-append "export PATH=" guile "/bin")
|
|
|
|
|
(call-with-input-file out get-string-all))
|
|
|
|
|
(equal? refs (list guile))))))))
|
|
|
|
|
|
2018-09-08 16:56:40 -04:00
|
|
|
|
(test-assertm "file-union"
|
|
|
|
|
(mlet* %store-monad ((union -> (file-union "union"
|
|
|
|
|
`(("a" ,(plain-file "a" "1"))
|
|
|
|
|
("b/c/d" ,(plain-file "d" "2"))
|
2022-02-11 17:17:00 -05:00
|
|
|
|
("e" ,(plain-file "e" "3")))
|
|
|
|
|
#:guile %bootstrap-guile))
|
2018-09-08 16:56:40 -04:00
|
|
|
|
(drv (lower-object union))
|
|
|
|
|
(out -> (derivation->output-path drv)))
|
|
|
|
|
(define (contents=? file str)
|
|
|
|
|
(string=? (call-with-input-file (string-append out "/" file)
|
|
|
|
|
get-string-all)
|
|
|
|
|
str))
|
|
|
|
|
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
|
|
|
|
(return (and (contents=? "a" "1")
|
|
|
|
|
(contents=? "b/c/d" "2")
|
|
|
|
|
(contents=? "e" "3"))))))
|
|
|
|
|
|
2015-07-07 16:57:54 -04:00
|
|
|
|
(test-assert "gexp->derivation vs. %current-target-system"
|
|
|
|
|
(let ((mval (gexp->derivation "foo"
|
|
|
|
|
#~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(foo #+gnu-make))
|
|
|
|
|
#:target #f)))
|
|
|
|
|
;; The value of %CURRENT-TARGET-SYSTEM at bind-time should have no
|
|
|
|
|
;; influence.
|
|
|
|
|
(parameterize ((%current-target-system "fooooo"))
|
|
|
|
|
(derivation? (run-with-store %store mval)))))
|
|
|
|
|
|
2015-08-26 05:28:23 -04:00
|
|
|
|
(test-assertm "lower-object"
|
|
|
|
|
(mlet %store-monad ((drv1 (lower-object %bootstrap-guile))
|
|
|
|
|
(drv2 (lower-object (package-source coreutils)))
|
|
|
|
|
(item (lower-object (plain-file "foo" "Hello!"))))
|
|
|
|
|
(return (and (derivation? drv1) (derivation? drv2)
|
|
|
|
|
(store-path? item)))))
|
|
|
|
|
|
2015-09-07 16:37:14 -04:00
|
|
|
|
(test-assertm "lower-object, computed-file"
|
|
|
|
|
(let* ((text (plain-file "foo" "Hello!"))
|
|
|
|
|
(exp #~(begin
|
|
|
|
|
(mkdir #$output)
|
|
|
|
|
(symlink #$%bootstrap-guile
|
|
|
|
|
(string-append #$output "/guile"))
|
|
|
|
|
(symlink #$text (string-append #$output "/text"))))
|
2022-02-11 17:17:00 -05:00
|
|
|
|
(computed (computed-file "computed" exp
|
|
|
|
|
#:guile %bootstrap-guile)))
|
2015-09-07 16:37:14 -04:00
|
|
|
|
(mlet* %store-monad ((text (lower-object text))
|
|
|
|
|
(guile-drv (lower-object %bootstrap-guile))
|
|
|
|
|
(comp-drv (lower-object computed))
|
|
|
|
|
(comp -> (derivation->output-path comp-drv)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list comp-drv))
|
|
|
|
|
(return (and (string=? (readlink (string-append comp "/guile"))
|
|
|
|
|
(derivation->output-path guile-drv))
|
|
|
|
|
(string=? (readlink (string-append comp "/text"))
|
|
|
|
|
text)))))))
|
|
|
|
|
|
gexp: Leave grafting as is when lowering allowed/disallowed references.
Fixes <https://issues.guix.gnu.org/50676>.
Reported by Mathieu Othacehe <othacehe@gnu.org>.
Commit a779363b6aa581e88eda21f9f35530962d54ac25 was partially incorrect:
references passed to #:allowed-references or #:references-graphs *can*
be lowered as references to grafted elements. This is for example the
case when doing:
(computed-file "partition.img" exp
#:options `(#:references-graphs ,inputs))
Here INPUTS must be lowered as a reference to suitably grafted elements.
Failing to do that, the reference graph will not match the actual
INPUTS.
However, when building a package, those references must indeed refer
only to ungrafted packages. This commit preserves that by having build
systems pass #:graft? #f.
* guix/gexp.scm (lower-reference-graphs, lower-references): Remove uses
of 'without-grafting'. This reverts
a779363b6aa581e88eda21f9f35530962d54ac25.
* guix/build-system/cmake.scm (cmake-build, cmake-cross-build):
Pass #:graft? #f.
* guix/build-system/glib-or-gtk.scm (glib-or-gtk-build)
(glib-or-gtk-cross-build): Likewise.
* guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Likewise.
* guix/build-system/meson.scm (meson-build, meson-cross-build): Likewise.
* guix/build-system/trivial.scm (trivial-build, trivial-cross-build):
Likewise.
* tests/gexp.scm ("lower-object, computed-file + grafts"): New test.
* tests/packages.scm ("trivial with #:allowed-references + grafts"): New
test.
2021-09-24 17:00:11 -04:00
|
|
|
|
(test-assert "lower-object, computed-file + grafts"
|
|
|
|
|
;; The reference graph should refer to grafted packages when grafts are
|
|
|
|
|
;; enabled. See <https://issues.guix.gnu.org/50676>.
|
|
|
|
|
(let* ((base (package
|
|
|
|
|
(inherit (dummy-package "trivial"))
|
|
|
|
|
(build-system trivial-build-system)
|
|
|
|
|
(arguments
|
|
|
|
|
`(#:guile ,%bootstrap-guile
|
|
|
|
|
#:builder (mkdir %output)))))
|
|
|
|
|
(pkg (package
|
|
|
|
|
(inherit base)
|
|
|
|
|
(version "1.1")
|
|
|
|
|
(replacement (package
|
|
|
|
|
(inherit base)
|
|
|
|
|
(version "9.9")))))
|
|
|
|
|
(exp #~(begin
|
|
|
|
|
(use-modules (ice-9 rdelim))
|
|
|
|
|
(let ((item (call-with-input-file "graph" read-line)))
|
|
|
|
|
(call-with-output-file #$output
|
|
|
|
|
(lambda (port)
|
|
|
|
|
(display item port))))))
|
|
|
|
|
(computed (computed-file "computed" exp
|
|
|
|
|
#:options
|
2022-02-11 17:17:00 -05:00
|
|
|
|
`(#:references-graphs (("graph" ,pkg)))
|
|
|
|
|
#:guile %bootstrap-guile))
|
gexp: Leave grafting as is when lowering allowed/disallowed references.
Fixes <https://issues.guix.gnu.org/50676>.
Reported by Mathieu Othacehe <othacehe@gnu.org>.
Commit a779363b6aa581e88eda21f9f35530962d54ac25 was partially incorrect:
references passed to #:allowed-references or #:references-graphs *can*
be lowered as references to grafted elements. This is for example the
case when doing:
(computed-file "partition.img" exp
#:options `(#:references-graphs ,inputs))
Here INPUTS must be lowered as a reference to suitably grafted elements.
Failing to do that, the reference graph will not match the actual
INPUTS.
However, when building a package, those references must indeed refer
only to ungrafted packages. This commit preserves that by having build
systems pass #:graft? #f.
* guix/gexp.scm (lower-reference-graphs, lower-references): Remove uses
of 'without-grafting'. This reverts
a779363b6aa581e88eda21f9f35530962d54ac25.
* guix/build-system/cmake.scm (cmake-build, cmake-cross-build):
Pass #:graft? #f.
* guix/build-system/glib-or-gtk.scm (glib-or-gtk-build)
(glib-or-gtk-cross-build): Likewise.
* guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Likewise.
* guix/build-system/meson.scm (meson-build, meson-cross-build): Likewise.
* guix/build-system/trivial.scm (trivial-build, trivial-cross-build):
Likewise.
* tests/gexp.scm ("lower-object, computed-file + grafts"): New test.
* tests/packages.scm ("trivial with #:allowed-references + grafts"): New
test.
2021-09-24 17:00:11 -04:00
|
|
|
|
(drv0 (package-derivation %store pkg #:graft? #t))
|
|
|
|
|
(drv1 (parameterize ((%graft? #t))
|
|
|
|
|
(run-with-store %store
|
|
|
|
|
(lower-object computed)))))
|
|
|
|
|
(build-derivations %store (list drv1))
|
|
|
|
|
|
|
|
|
|
;; The graph obtained in COMPUTED should refer to the grafted version of
|
|
|
|
|
;; PKG, not to PKG itself.
|
|
|
|
|
(string=? (call-with-input-file (derivation->output-path drv1)
|
|
|
|
|
get-string-all)
|
|
|
|
|
(derivation->output-path drv0))))
|
|
|
|
|
|
2019-01-04 18:01:18 -05:00
|
|
|
|
(test-equal "lower-object, computed-file, #:system"
|
|
|
|
|
'("mips64el-linux")
|
|
|
|
|
(run-with-store %store
|
|
|
|
|
(let* ((exp #~(symlink #$coreutils #$output))
|
|
|
|
|
(computed (computed-file "computed" exp
|
|
|
|
|
#:guile %bootstrap-guile)))
|
|
|
|
|
;; Make sure that the SYSTEM argument to 'lower-object' is honored.
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object computed "mips64el-linux"))
|
|
|
|
|
(refs (references* (derivation-file-name drv))))
|
|
|
|
|
(return (delete-duplicates
|
|
|
|
|
(filter-map (lambda (file)
|
|
|
|
|
(and (string-suffix? ".drv" file)
|
|
|
|
|
(let ((drv (read-derivation-from-file
|
|
|
|
|
file)))
|
|
|
|
|
(derivation-system drv))))
|
|
|
|
|
(cons (derivation-file-name drv)
|
|
|
|
|
refs))))))))
|
|
|
|
|
|
2022-02-15 03:31:42 -05:00
|
|
|
|
(test-assertm "lower-object, computed-file, #:target"
|
|
|
|
|
(let* ((target "i586-pc-gnu")
|
|
|
|
|
(computed (computed-file "computed-cross"
|
|
|
|
|
#~(symlink #$coreutils output)
|
|
|
|
|
#:guile (default-guile))))
|
|
|
|
|
;; When lowered to TARGET, the derivation of COMPUTED should run natively,
|
|
|
|
|
;; using a native Guile, but it should refer to the target COREUTILS.
|
|
|
|
|
(mlet* %store-monad ((drv (lower-object computed (%current-system)
|
|
|
|
|
#:target target))
|
|
|
|
|
(refs (references* (derivation-file-name drv)))
|
|
|
|
|
(guile (lower-object (default-guile)
|
|
|
|
|
(%current-system)
|
|
|
|
|
#:target #f))
|
|
|
|
|
(cross (lower-object coreutils #:target target))
|
|
|
|
|
(native (lower-object coreutils #:target #f)))
|
|
|
|
|
(return (and (string=? (derivation-system (pk 'drv drv)) (%current-system))
|
|
|
|
|
(string=? (derivation-builder drv)
|
|
|
|
|
(string-append (derivation->output-path guile)
|
|
|
|
|
"/bin/guile"))
|
|
|
|
|
(not (member (derivation-file-name native) refs))
|
|
|
|
|
(member (derivation-file-name cross) refs))))))
|
|
|
|
|
|
2022-04-13 13:59:03 -04:00
|
|
|
|
(test-assertm "references-file"
|
|
|
|
|
(let* ((exp #~(symlink #$%bootstrap-guile #$output))
|
|
|
|
|
(computed (computed-file "computed" exp
|
|
|
|
|
#:guile %bootstrap-guile))
|
|
|
|
|
(refs (references-file computed "refs"
|
|
|
|
|
#:guile %bootstrap-guile)))
|
|
|
|
|
(mlet* %store-monad ((drv0 (lower-object %bootstrap-guile))
|
|
|
|
|
(drv1 (lower-object computed))
|
|
|
|
|
(drv2 (lower-object refs)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv2))
|
|
|
|
|
(mlet %store-monad ((refs ((store-lift requisites)
|
|
|
|
|
(list (derivation->output-path drv1)))))
|
|
|
|
|
(return (lset= string=?
|
|
|
|
|
(call-with-input-file (derivation->output-path drv2)
|
|
|
|
|
read)
|
|
|
|
|
refs)))))))
|
|
|
|
|
|
2017-04-03 17:52:19 -04:00
|
|
|
|
(test-assert "lower-object & gexp-input-error?"
|
|
|
|
|
(guard (c ((gexp-input-error? c)
|
|
|
|
|
(gexp-error-invalid-input c)))
|
|
|
|
|
(run-with-store %store
|
|
|
|
|
(lower-object (current-module))
|
|
|
|
|
#:guile-for-build (%guile-for-build))))
|
|
|
|
|
|
2014-07-17 09:40:06 -04:00
|
|
|
|
(test-assert "printer"
|
|
|
|
|
(string-match "^#<gexp \\(string-append .*#<package coreutils.*\
|
2020-11-05 08:32:04 -05:00
|
|
|
|
\"/bin/uname\"\\) [[:graph:]]+tests/gexp\\.scm:[0-9]+:[0-9]+ [[:xdigit:]]+>$"
|
2014-07-17 09:40:06 -04:00
|
|
|
|
(with-output-to-string
|
|
|
|
|
(lambda ()
|
|
|
|
|
(write
|
|
|
|
|
(gexp (string-append (ungexp coreutils)
|
|
|
|
|
"/bin/uname")))))))
|
|
|
|
|
|
|
|
|
|
(test-assert "printer vs. ungexp-splicing"
|
|
|
|
|
(string-match "^#<gexp .* [[:xdigit:]]+>$"
|
|
|
|
|
(with-output-to-string
|
|
|
|
|
(lambda ()
|
|
|
|
|
;; #~(begin #$@#~())
|
|
|
|
|
(write
|
|
|
|
|
(gexp (begin (ungexp-splicing (gexp ())))))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-equal "sugar"
|
|
|
|
|
'(gexp (foo (ungexp bar) (ungexp baz "out")
|
|
|
|
|
(ungexp (chbouib 42))
|
gexp: Add 'ungexp-native' and 'ungexp-native-splicing'.
* guix/gexp.scm (<gexp>)[natives]: New field.
(write-gexp): Use both 'gexp-references' and
'gexp-native-references'.
(gexp->derivation): Use both 'gexp-inputs' and 'gexp-native-inputs',
and append them.
(gexp-inputs): Add 'references' parameter and honor it.
(gexp-native-inputs): New procedure.
(gexp->sexp)[reference->sexp]: Add 'native?' parameter and honor it.
Use it, and use 'gexp-native-references'.
(gexp)[collect-native-escapes]: New procedure.
[escape->ref]: Handle 'ungexp-native' and 'ungexp-native-splicing'.
[substitute-ungexp, substitute-ungexp-splicing]: New procedures.
[substitute-references]: Use them, and handle 'ungexp-native' and
'ungexp-native-splicing'.
Adjust generated 'make-gexp' call to provide both normal references
and native references.
[read-ungexp]: Support 'ungexp-native' and
'ungexp-native-splicing'.
Add reader extension for #+.
* tests/gexp.scm (gexp-native-inputs): New procedure.
(gexp->sexp*): Add 'target' parameter.
("ungexp + ungexp-native",
"input list + ungexp-native",
"input list splicing + ungexp-native-splicing",
"gexp->derivation, ungexp-native",
"gexp->derivation, ungexp + ungexp-native"): New tests.
("sugar"): Add tests for #+ and #+@.
* doc/guix.texi (G-Expressions): Document 'ungexp-native' et al.
2014-08-18 08:53:10 -04:00
|
|
|
|
(ungexp-splicing (list x y z))
|
|
|
|
|
(ungexp-native foo) (ungexp-native foo "out")
|
|
|
|
|
(ungexp-native (chbouib 42))
|
|
|
|
|
(ungexp-native-splicing (list x y z))))
|
|
|
|
|
'#~(foo #$bar #$baz:out #$(chbouib 42) #$@(list x y z)
|
|
|
|
|
#+foo #+foo:out #+(chbouib 42) #+@(list x y z)))
|
2014-04-28 17:00:57 -04:00
|
|
|
|
|
2020-03-06 04:06:54 -05:00
|
|
|
|
(test-assertm "gexp->file, cross-compilation"
|
|
|
|
|
(mlet* %store-monad ((target -> "aarch64-linux-gnu")
|
|
|
|
|
(exp -> (gexp (list (ungexp coreutils))))
|
|
|
|
|
(xdrv (gexp->file "foo" exp #:target target))
|
|
|
|
|
(refs (references*
|
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xcu (package->cross-derivation coreutils
|
|
|
|
|
target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name xcu) refs)
|
|
|
|
|
(not (member (derivation-file-name cu) refs))))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->file, cross-compilation with default target"
|
|
|
|
|
(mlet* %store-monad ((target -> "aarch64-linux-gnu")
|
|
|
|
|
(_ (set-current-target target))
|
|
|
|
|
(exp -> (gexp (list (ungexp coreutils))))
|
|
|
|
|
(xdrv (gexp->file "foo" exp))
|
|
|
|
|
(refs (references*
|
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xcu (package->cross-derivation coreutils
|
|
|
|
|
target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name xcu) refs)
|
|
|
|
|
(not (member (derivation-file-name cu) refs))))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->script, cross-compilation"
|
|
|
|
|
(mlet* %store-monad ((target -> "aarch64-linux-gnu")
|
|
|
|
|
(exp -> (gexp (list (ungexp coreutils))))
|
|
|
|
|
(xdrv (gexp->script "foo" exp #:target target))
|
|
|
|
|
(refs (references*
|
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xcu (package->cross-derivation coreutils
|
|
|
|
|
target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name xcu) refs)
|
|
|
|
|
(not (member (derivation-file-name cu) refs))))))
|
|
|
|
|
|
|
|
|
|
(test-assertm "gexp->script, cross-compilation with default target"
|
|
|
|
|
(mlet* %store-monad ((target -> "aarch64-linux-gnu")
|
|
|
|
|
(_ (set-current-target target))
|
|
|
|
|
(exp -> (gexp (list (ungexp coreutils))))
|
|
|
|
|
(xdrv (gexp->script "foo" exp))
|
|
|
|
|
(refs (references*
|
|
|
|
|
(derivation-file-name xdrv)))
|
|
|
|
|
(xcu (package->cross-derivation coreutils
|
|
|
|
|
target))
|
|
|
|
|
(cu (package->derivation coreutils)))
|
|
|
|
|
(return (and (member (derivation-file-name xcu) refs)
|
|
|
|
|
(not (member (derivation-file-name cu) refs))))))
|
|
|
|
|
|
2014-04-28 17:00:57 -04:00
|
|
|
|
(test-end "gexp")
|
|
|
|
|
|
|
|
|
|
;; Local Variables:
|
|
|
|
|
;; eval: (put 'test-assertm 'scheme-indent-function 1)
|
|
|
|
|
;; End:
|