;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013-2023 Ludovic Courtès ;;; Copyright © 2014 Alex Kost ;;; ;;; 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 . (define-module (test-profiles) #:use-module (guix tests) #:use-module (guix profiles) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix derivations) #:use-module (guix build-system trivial) #:use-module (gnu packages bootstrap) #:use-module ((gnu packages base) #:prefix packages:) #:use-module ((gnu packages guile) #:prefix packages:) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (ice-9 popen) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-34) #:use-module (srfi srfi-64)) ;; Test the (guix profiles) module. (define %store (open-connection-for-tests)) ;; Globally disable grafts because they can trigger early builds. (%graft? #f) ;; Example manifest entries. (define guile-1.8.8 (manifest-entry (name "guile") (version "1.8.8") (item "/gnu/store/...") (output "out"))) (define guile-2.0.9 (manifest-entry (name "guile") (version "2.0.9") (item "/gnu/store/...") (output "out"))) (define guile-2.0.9:debug (manifest-entry (inherit guile-2.0.9) (output "debug"))) (define glibc (manifest-entry (name "glibc") (version "2.19") (item "/gnu/store/...") (output "out"))) (test-begin "profiles") (test-assert "manifest-installed?" (let ((m (manifest (list guile-2.0.9 guile-2.0.9:debug)))) (and (manifest-installed? m (manifest-pattern (name "guile"))) (manifest-installed? m (manifest-pattern (name "guile") (output "debug"))) (manifest-installed? m (manifest-pattern (name "guile") (output "out") (version "2.0.9"))) (not (manifest-installed? m (manifest-pattern (name "guile") (version "1.8.8")))) (not (manifest-installed? m (manifest-pattern (name "guile") (output "foobar"))))))) (test-assert "manifest-matching-entries" (let* ((e (list guile-2.0.9 guile-2.0.9:debug)) (m (manifest e))) (and (equal? e (manifest-matching-entries m (list (manifest-pattern (name "guile") (output #f))))) (equal? (list guile-2.0.9) (manifest-matching-entries m (list (manifest-pattern (name "guile") (version "2.0.9")))))))) (test-assert "manifest-matching-entries, no match" (let ((m (manifest (list guile-2.0.9))) (p (manifest-pattern (name "python")))) (guard (c ((unmatched-pattern-error? c) (and (eq? p (unmatched-pattern-error-pattern c)) (eq? m (unmatched-pattern-error-manifest c))))) (manifest-matching-entries m (list p)) #f))) (test-equal "concatenate-manifests" (manifest (list guile-2.0.9 glibc)) (concatenate-manifests (list (manifest (list guile-2.0.9)) (manifest (list glibc))))) (test-assert "manifest-remove" (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug))) (m1 (manifest-remove m0 (list (manifest-pattern (name "guile"))))) (m2 (manifest-remove m1 (list (manifest-pattern (name "guile"))))) ; same (m3 (manifest-remove m2 (list (manifest-pattern (name "guile") (output "debug"))))) (m4 (manifest-remove m3 (list (manifest-pattern (name "guile")))))) (match (manifest-entries m2) ((($ "guile" "2.0.9" "debug")) (and (equal? m1 m2) (null? (manifest-entries m3)) (null? (manifest-entries m4))))))) (test-assert "manifest-add" (let* ((m0 (manifest '())) (m1 (manifest-add m0 (list guile-1.8.8))) (m2 (manifest-add m1 (list guile-2.0.9))) (m3 (manifest-add m2 (list guile-2.0.9:debug))) (m4 (manifest-add m3 (list guile-2.0.9:debug)))) (and (match (manifest-entries m1) ((($ "guile" "1.8.8" "out")) #t) (_ #f)) (match (manifest-entries m2) ((($ "guile" "2.0.9" "out")) #t) (_ #f)) (equal? m3 m4)))) (test-equal "manifest-add removes duplicates" ; (list guile-2.0.9) (manifest-entries (manifest-add (manifest '()) (list guile-2.0.9 guile-2.0.9)))) (test-equal "manifest->code, simple" '(begin (specifications->manifest (list "guile" "guile:debug" "glibc"))) (manifest->code (manifest (list guile-2.0.9 guile-2.0.9:debug glibc)))) (test-equal "manifest->code, simple, versions" '(begin (specifications->manifest (list "guile@2.0.9" "guile@2.0.9:debug" "glibc@2.19"))) (manifest->code (manifest (