aboutsummaryrefslogtreecommitdiff
path: root/tests/builders.scm
blob: 285322746518d2f844c2257a96a3ae58ebfa153c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2018, 2019, 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
;;;
;;; 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 (tests builders)
  #:use-module (guix download)
  #:use-module (guix build-system)
  #:use-module (guix build-system gnu)
  #:use-module (guix build gnu-build-system)
  #:use-module (guix build utils)
  #:use-module (guix build-system python)
  #:use-module (guix grafts)
  #:use-module (guix store)
  #:use-module (guix monads)
  #:use-module (guix utils)
  #:use-module (guix base32)
  #:use-module (guix derivations)
  #:use-module (gcrypt hash)
  #:use-module (guix tests)
  #:use-module (guix packages)
  #:use-module (gnu packages bootstrap)
  #:use-module (ice-9 match)
  #:use-module (ice-9 textual-ports)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-11)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-64))

;; Test the higher-level builders.

(define %store
  (open-connection-for-tests))

(define url-fetch*
  (store-lower url-fetch))

;; Globally disable grafts because they can trigger early builds.
(%graft? #f)


(test-begin "builders")

(unless (network-reachable?) (test-skip 1))
(test-assert "url-fetch"
  (let* ((url      '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
                     "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
         (hash     (nix-base32-string->bytevector
                    "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
         (drv      (url-fetch* %store url 'sha256 hash
                               #:guile %bootstrap-guile))
         (out-path (derivation->output-path drv)))
    (and (build-derivations %store (list drv))
         (file-exists? out-path)
         (valid-path? %store out-path))))

(test-assert "url-fetch, file"
  (let* ((file (search-path %load-path "guix.scm"))
         (hash (call-with-input-file file port-sha256))
         (out  (url-fetch* %store file 'sha256 hash)))
    (and (file-exists? out)
         (valid-path? %store out))))

(test-assert "url-fetch, file URI"
  (let* ((file (search-path %load-path "guix.scm"))
         (hash (call-with-input-file file port-sha256))
         (out  (url-fetch* %store
                           (string-append "file://" (canonicalize-path file))
                           'sha256 hash)))
    (and (file-exists? out)
         (valid-path? %store out))))

(test-assert "gnu-build-system"
  (build-system? gnu-build-system))

(define unpack (assoc-ref %standard-phases 'unpack))

(define compressors '(("gzip"  . "gz")
                      ("xz"    . "xz")
                      ("bzip2" . "bz2")
                      (#f      . #f)))

(for-each
 (match-lambda
   ((comp . ext)

    (unless (network-reachable?) (test-skip 1)) ;for bootstrap binaries
    (test-equal (string-append "gnu-build-system unpack phase, "
                               "single file (compression: "
                               (if comp comp "None") ")")
      "expected text"
      (let*-values
          (((name) "test")
           ((compressed-name) (if ext
                                  (string-append name "." ext)
                                  name))
           ((file hash) (test-file %store compressed-name "expected text")))
        (call-with-temporary-directory
         (lambda (dir)
           (with-directory-excursion dir
             (unpack #:source file)
             (call-with-input-file name get-string-all))))))))
 compressors)


;;;
;;; Test the sanity-check phase of the Python build system.
;;;

(define* (make-python-dummy name #:key (setup-py-extra "")
                            (init-py "") (use-setuptools? #t))
  (dummy-package (string-append "python-dummy-" name)
    (version "0.1")
    (build-system python-build-system)
    (arguments
     `(#:tests? #f
       #:use-setuptools? ,use-setuptools?
       #:phases
       (modify-phases %standard-phases
         (replace 'unpack
           (lambda _
             (mkdir-p "dummy")
             (with-output-to-file "dummy/__init__.py"
               (lambda _
                 (display ,init-py)))
             (with-output-to-file "setup.py"
               (lambda _
                 (format #t "\
~a
setup(
     name='dummy-~a',
     version='0.1',
     packages=['dummy'],
     ~a
     )"
                         (if ,use-setuptools?
                             "from setuptools import setup"
                             "from distutils.core import setup")
                         ,name ,setup-py-extra))))))))))

(define python-dummy-ok
  (make-python-dummy "ok"))

;; distutil won't install any metadata, so make sure our script does not fail
;; on a otherwise fine package.
(define python-dummy-no-setuptools
  (make-python-dummy
   "no-setuptools" #:use-setuptools? #f))

(define python-dummy-fail-requirements
  (make-python-dummy "fail-requirements"
                     #:setup-py-extra "install_requires=['nonexistent'],"))

(define python-dummy-fail-import
  (make-python-dummy "fail-import" #:init-py "import nonexistent"))

(define python-dummy-fail-console-script
  (make-python-dummy "fail-console-script"
                     #:setup-py-extra (string-append "entry_points={'console_scripts': "
                                                     "['broken = dummy:nonexistent']},")))

(define (check-build-success store p)
  (unless store (test-skip 1))
  (test-assert (string-append "python-build-system: " (package-name p))
    (let* ((drv (package-derivation store p)))
      (build-derivations store (list drv)))))

(define (check-build-failure store p)
  (unless store (test-skip 1))
  (test-assert (string-append "python-build-system: " (package-name p))
    (let ((drv (package-derivation store p)))
      (guard (c ((store-protocol-error? c)
                 (pk 'failure c #t)))             ;good!
        (build-derivations store (list drv))
        #f))))                                    ;bad: it should have failed

(with-external-store store
  (for-each (lambda (p) (check-build-success store p))
            (list
             python-dummy-ok
             python-dummy-no-setuptools))
  (for-each (lambda (p) (check-build-failure store p))
            (list
             python-dummy-fail-requirements
             python-dummy-fail-import
             python-dummy-fail-console-script)))

(test-end "builders")
goaziou.fr> Sharlatan Hellseher 2021-01-02gnu: routino: Update to 3.3.3....* gnu/packages/geo.scm (routino): Update to 3.3.3. Tobias Geerinckx-Rice 2020-12-29gnu: readosm: Update source hash....Looks like the tarball was changed by upstream, lots of timestamps changed from 2020-08-02 to 2020-08-23, and there were some minor changes to file contents. * gnu/packages/geo.scm (source): Update hash. Christopher Baines 2020-12-29gnu: gnome-maps: Patch DBUS service....* gnu/packages/geo.scm (gnome-maps): [arguments]<#:phases>: Add patch-dbus-service. Leo Prikler 2020-12-23gnu: grass: Update to 7.8.5....* gnu/packages/geo.scm (grass): Update to 7.8.5. Tobias Geerinckx-Rice 2020-12-13gnu: josm: Update to 17329....* gnu/packages/geo.scm (josm): Update to 17329. Julien Lepiller 2020-12-01gnu: libspatialite: Update to 5.0.0....* gnu/packages/geo.scm (libspatialite, spatialite-tools): Update to 5.0.0. [inputs]: Add new required dependencies minizip and librttopo. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> Felix Gruber 2020-12-01gnu: Add librttopo....* gnu/packages/geo.scm (librttopo): New variable. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> Felix Gruber 2020-11-24gnu: postgis: Update to 3.0.3....* gnu/packages/geo.scm (postgis): Update to 3.0.3. Tobias Geerinckx-Rice 2020-11-19gnu: Don't append '.git' to GitHub uris....* gnu/packages/admin.scm (nmrpflash)[source]: Remove '.git' from URI. * gnu/packages/aidc.scm (zxing-cpp), * gnu/packages/assembly.scm (mbuild), * gnu/packages/audio.scm (opensles, wildmidi, tinyalsa), * gnu/packages/browser-extensions.scm (ublock-origin-chromium), * gnu/packages/check.scm (mutest), * gnu/packages/compression.scm (unshield), * gnu/packages/coq.scm (subset), * gnu/packages/dictionaries.scm (translate-shell), * gnu/packages/disk.scm (memkind), * gnu/packages/documentation.scm (latex2html), * gnu/packages/emacs-xyz.scm (emacs-chronometrist, emacs-flycheck-ledger, emacs-counsel-notmuch, emacs-spaceline, emacs-org-generate), * gnu/packages/embedded.scm (ebusd, ebusd-configuration), * gnu/packages/enchant.scm (nuspell), * gnu/packages/fontutils.scm (woff2), * gnu/packages/geo.scm (memphis), * gnu/packages/gimp.scm (mrg), * gnu/packages/gnome-xyz.scm (gnome-shell-extension-appindicator), * gnu/packages/gnome.scm (parlatype), * gnu/packages/golang.scm (go-github-com-tv42-httpunix, go-github-com-ayufan-golang-kardianos-service), * gnu/packages/graphics.scm (eglexternalplatform, egl-wayland, mmm, directfb, flux), * gnu/packages/gstreamer.scm (openni2, ccextractor, libvisual, graphene), * gnu/packages/guile-xyz.scm (guile-srfi-180, guile-torrent), * gnu/packages/image.scm (openjpeg-data), * gnu/packages/java.scm (javacc), * gnu/packages/language.scm (liblouis, liblouisutdml), * gnu/packages/linux.scm (pamela, ttyebus), * gnu/packages/lxqt.scm (lxqt-connman-applet), * gnu/packages/mail.scm (libetpan), * gnu/packages/man.scm (ronn), * gnu/packages/music.scm (tascam-gtk, artyfx), * gnu/packages/networking.scm (srt, lksctp-tools, nng, nanomsg), * gnu/packages/python-crypto.scm (pure-python-otr), * gnu/packages/qt.scm (qtspell), * gnu/packages/raspberry-pi.scm (raspi-gpio, raspi-open-firmware), * gnu/packages/rdp.scm (freerdp), * gnu/packages/ruby.scm (ruby-prawn-templates, ruby-treetop, ruby-gimme, ruby-standard, ruby-rubocop-ast, ruby-rexml, ruby-range-compressor, ruby-regexp-property-values, ruby-regexp-parser, ruby-rubocop, ruby-pdf-reader, ruby-pdf-inspector, ruby-prawn), * gnu/packages/syncthing.scm (syncthing-gtk), * gnu/packages/video.scm (svt-hevc, mediasdk, libvideogfx, libde265, tslib), * gnu/packages/xml.scm (libxmlb, libxmlplusplus)[source]: Same. Efraim Flashner 2020-10-26gnu: qgis: Fix many plugins....Fixes <https://issues.guix.gnu.org/42941>. This fixes the installation of many plugins. * gnu/packages/geo.scm (qgis)[inputs]: Add python-future. Signed-off-by: Christopher Baines <mail@cbaines.net> Jonathan Brielmaier 2020-10-22gnu: josm: Update to 17084....* gnu/packages/geo.scm (josm): Update to 17084. Julien Lepiller 2020-10-16gnu: grass: Fix start-up without python@3 in profile....* gnu/packages/geo.scm (grass)[arguments]: Rename ‘wrap-python’ phase to ‘python:wrap’. Add ‘wrap-with-python-interpreter’ phase. Tobias Geerinckx-Rice 2020-10-16gnu: grass: Update to 7.8.4....* gnu/packages/geo.scm (grass): Update to 7.8.4. Tobias Geerinckx-Rice 2020-10-03gnu: josm: Update to 17013....* gnu/packages/geo.scm (josm): Update to 17013. Julien Lepiller 2020-09-30gnu: Fix package references....* gnu/packages/algebra.scm (iml)[inputs]: Correctly refer to package inputs. * gnu/packages/astronomy.scm (xplanet), * gnu/packages/audio.scm (redkite, libaudec, lv2lint, lv2toweb), * gnu/packages/bioconductor.scm (r-cummerbund), * gnu/packages/chicken.scm (chicken), * gnu/packages/conky.scm (conky), * gnu/packages/cran.scm (r-latex2exp), * gnu/packages/crates-io.scm (rust-rgb), * gnu/packages/databases.scm (mariadb), * gnu/packages/diffoscope.scm (reprotest), * gnu/packages/file-systems.scm (glusterfs), * gnu/packages/finance.scm (electron-cash), * gnu/packages/games.scm (rinutils, ksudoku, kdiamond, kigo), * gnu/packages/geo.scm (grass), * gnu/packages/gnome.scm (libmediaart, gnome-contacts, geoclue), * gnu/packages/gnucash.scm (aqbanking), * gnu/packages/image.scm (mtpaint), * gnu/packages/kde-internet.scm (kopete, ktorrent), * gnu/packages/kde-utils.scm (kmousetool, kmouth, kronometer), * gnu/packages/linphone.scm (liblinphone), * gnu/packages/maths.scm (ppl), * gnu/packages/mercury.scm (mercury-minimal), * gnu/packages/music.scm (bjumblr, bschaffl, lsp-plugins, spectacle-analyzer, helm, tap-lv2, wolf-shaper, shiru-lv2), * gnu/packages/networking.scm (restinio), * gnu/packages/prolog.scm (swi-prolog), * gnu/packages/python-web.scm (gunicorn), * gnu/packages/python-xyz.scm (python-docusign-esign), * gnu/packages/ruby.scm (ruby-cucumber, ruby_version, ruby-addressable), * gnu/packages/sagemath.scm (python-cypari2), * gnu/packages/skarnet.scm (s6-linux-init), * gnu/packages/vpn.scm (sshuttle), * gnu/packages/web.scm (libcyaml), * gnu/packages/xdisorg.scm (kbdd), * gnu/packages/xorg.scm (xpra): Same. Efraim Flashner 2020-09-13gnu: josm: Fix formatting and install more files....This means that JOSM appears in the GNOME Shell menu. * gnu/packages/geo.scm (josm)[source]: Replace tab character. [arguments]: Reduce line length, and add install-share-directories phase. Christopher Baines 2020-08-18gnu: postgis: Update to 3.0.2....* gnu/packages/geo.scm (postgis): Update to 3.0.2. Tobias Geerinckx-Rice 2020-08-18gnu: Add memphis....* gnu/packages/geo.scm (memphis): New variable. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Raghav Gururajan