;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012 Nikita Karetnikov ;;; Copyright © 2014 Mark H Weaver ;;; Copyright © 2015, 2017 Ricardo Wurmus ;;; Copyright © 2016, 2019, 2022 Efraim Flashner ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2017, 2019, 2020 Marius Bakke ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2017 Eric Bavier ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2019 Miguel ;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen ;;; Copyright © 2020 EuAndreh ;;; Copyright © 2022 gemmaro ;;; Copyright © 2023 Maxim Cournoyer maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/o
aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; 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 (gnu tests package-management)
  #:use-module (gnu packages base)
  #:use-module (gnu packages package-management)
  #:use-module (gnu services)
  #:use-module (gnu services networking)
  #:use-module (gnu services nix)
  #:use-module (gnu system)
  #:use-module (gnu system vm)
  #:use-module (gnu tests)
  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:export (%test-nix))

;;; Commentary:
;;;
;;; This module provides a test definition for the nix-daemon
;;;
;;; Code:

(define* (run-nix-test name test-os)
  "Run tests in TEST-OS, which has nix-daemon running."
  (define os
    (marionette-operating-system
     test-os
     #:imported-modules '((gnu services herd))))

  (define vm
    (virtual-machine
     (operating-system os)
     (port-forwardings '((8080 . 80)))
     (memory-size 1024)))

  (define test
    (with-imported-modules '((gnu build marionette))
      #~(begin
          (use-modules (srfi srfi-11)
                       (srfi srfi-64)
                       (gnu build marionette)
                       (web client)
                       (web response))

          (define marionette
            (make-marionette (list #$vm)))

          (test-runner-current (system-test-runner #$output))
          (test-begin #$name)

          ;; XXX: Shepherd reads the config file *before* binding its control
          ;; socket, so /var/run/shepherd/socket might not exist yet when the
          ;; 'marionette' service is started.
          (test-assert "shepherd socket ready"
            (marionette-eval
             `(begin
                (use-modules (gnu services herd))
                (let loop ((i 10))
                  (cond ((file-exists? (%shepherd-socket-file))
                         #t)
                        ((> i 0)
                         (sleep 1)
                         (loop (- i 1)))
                        (else
                         'failure))))
             marionette))

          (test-assert "Nix daemon running"
            (marionette-eval
             '(begin
                ;; Wait for nix-daemon to be up and running.
                (start-service 'nix-daemon)
                (zero? (system* (string-append #$nix "/bin/nix")
                                "--experimental-features" "nix-command"
                                "store" "ping" "--store" "daemon")))
             marionette))

          (test-end))))

  (gexp->derivation (string-append name "-test") test))

(define %nix-os
  ;; Return operating system under test.
  (let ((base-os
         (simple-operating-system
          (service nix-service-type)
          (service dhcp-client-service-type))))
    (operating-system
      (inherit base-os)
      (packages (cons nix (operating-system-packages base-os))))))

(define %test-nix
  (system-test
   (name "nix")
   (description "Connect to a running nix-daemon")
   (value (run-nix-test name %nix-os))))

;;; package-management.scm ends here
make-flags #~'("VERBOSE=yes"))) (home-page "https://www.gnu.org/software/gettext/") (synopsis "Tools and documentation for translation (used to build other packages)") (description "GNU Gettext is a package providing a framework for translating the textual output of programs into multiple languages. It provides translators with the means to create message catalogs, and a runtime library to load translated messages from the catalogs. Nearly all GNU packages use Gettext.") (properties `((upstream-name . "gettext") (cpe-name . "gettext"))) (license gpl3+))) ;some files are under GPLv2+ ;; Use that name to avoid clashes with Guile's 'gettext' procedure. ;; ;; We used to resort to #:renamer on the user side, but that prevented ;; circular dependencies involving (gnu packages gettext). This is because ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used ;; module when there's a #:renamer, and that module may be empty at that point ;; in case or circular dependencies. (define-public gnu-gettext (package/inherit gettext-minimal (name "gettext") (arguments (substitute-keyword-arguments (package-arguments gettext-minimal) ((#:phases phases) #~(modify-phases #$phases (add-after 'install 'add-emacs-autoloads (lambda* (#:key outputs #:allow-other-keys) ;; Make 'po-mode' and other things available by default. (with-directory-excursion (string-append (assoc-ref outputs "out") "/share/emacs/site-lisp") (symlink "start-po.el" "gettext-autoloads.el")))))))) (native-inputs (list emacs-minimal)) ;for Emacs tools (synopsis "Tools and documentation for translation"))) (define-public libtextstyle (package (name "libtextstyle") (version "0.21") (source (origin (inherit (package-source gnu-gettext)) (uri (string-append "mirror://gnu/gettext/gettext-" version ".tar.gz")) (sha256 (base32 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7")))) (build-system gnu-build-system) (arguments '(#:configure-flags '("--disable-static") #:phases (modify-phases %standard-phases (add-after 'unpack 'chdir (lambda _ (chdir "libtextstyle") #t))))) ;; libtextstyle bundles libxml2, glib (a small subset thereof), and ;; libcroco, but it purposefully prevents users from using an external ;; copy, to reduce the startup time of programs using libtextstyle. (home-page "https://www.gnu.org/software/gettext/") (synopsis "Text styling library") (description "GNU libtextstyle is a C library that provides an easy way to add styling to programs that produce output to a console or terminal emulator window. It allows applications to emit text annotated with styling information, such as color, font attributes (weight, posture), or underlining.") (license gpl3+))) (define-public mdpo (package (name "mdpo") (version "0.3.6") (source (origin (method url-fetch) (uri (pypi-uri "mdpo" version)) (sha256 (base32 "0kgbm0af7jwpfspa2xxiy9nc2l1r2s1rhbhz4r229zcqv49ak6sq")))) (build-system python-build-system) (native-inputs (list python-bump2version python-flake8 python-flake8-implicit-str-concat python-flake8-print python-isort python-pytest python-pytest-cov python-sphinx python-sphinx-argparse python-sphinx-rtd-theme python-twine python-yamllint)) (propagated-inputs (list python-polib python-pymd4c)) (home-page "https://github.com/mondeja/mdpo") (synopsis "Markdown file translation utilities using pofiles") (description "The mdpo utility creates pofiles, the format stabilished by GNU Gettext, from Markdown files.") (license bsd-3))) (define-public po4a (package (name "po4a") (version "0.69") (source (origin (method url-fetch) (uri (string-append "https://github.com/mquinson/po4a" "/releases/download/v" version "/po4a-" version ".tar.gz")) (sha256 (base32 "15llrfdp4ilbrxy65hmmxka86xj0mrbqfiyzv715wrk16vqszm3w")) (patches (search-patches "po4a-partial-texinfo-menu-fix.patch")))) (build-system perl-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (add-after 'install 'wrap-programs (lambda* (#:key inputs outputs #:allow-other-keys) ;; Make sure all executables in "bin" find the Perl modules ;; required by this package at runtime. (let* ((out #$output) (bin (string-append out "/bin/")) (path (string-append out "/lib/perl5/site_perl:" (string-join (map (lambda (name) (string-append (assoc-ref inputs name) "/lib/perl5/site_perl")) (list "perl-gettext" "perl-pod-parser" "perl-sgmls" "perl-syntax-keyword-try" "perl-xs-parse-keyword" "perl-term-readkey" "perl-text-wrapi18n" "perl-unicode-linebreak" "perl-yaml-tiny")) ":")))) (for-each (lambda (file) (wrap-program file `("PERL5LIB" ":" prefix (,path)))) (find-files bin "\\.*$"))))) (add-before 'check 'disable-failing-tests (lambda _ ;; FIXME: fails despite of importing SGMLS (delete-file "t/fmt-sgml.t"))) #$@(if (system-hurd?) #~((add-after 'unpack 'skip-tests/hurd (lambda _ (delete-file "t/cfg-multi.t") (delete-file "t/cfg-single.t") (delete-file "t/cfg-split.t")))) #~())))) (native-inputs (list gettext-minimal perl-module-build docbook-xsl libxml2 libxslt ;; For tests. docbook-xml-4.1.2 perl-test-pod (texlive-updmap.cfg))) (inputs (list bash-minimal perl-gettext perl-pod-parser perl-sgmls perl-syntax-keyword-try perl-xs-parse-keyword perl-term-readkey perl-text-wrapi18n perl-unicode-linebreak perl-yaml-tiny)) (home-page "https://po4a.org/") (synopsis "Scripts to ease maintenance of translations") (description "The po4a (PO for anything) project goal is to ease translations (and more interestingly, the maintenance of translations) using gettext tools on areas where they were not expected like documentation.") (license gpl2+)))