diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/derivations.scm | 41 | ||||
-rw-r--r-- | tests/elpa.scm | 3 | ||||
-rw-r--r-- | tests/gexp.scm | 147 | ||||
-rw-r--r-- | tests/gnu-maintenance.scm | 22 | ||||
-rw-r--r-- | tests/go.scm | 292 | ||||
-rw-r--r-- | tests/guix-build.sh | 6 | ||||
-rw-r--r-- | tests/guix-lint.sh | 5 | ||||
-rw-r--r-- | tests/guix-package.sh | 15 | ||||
-rw-r--r-- | tests/guix-system.sh | 9 | ||||
-rw-r--r-- | tests/lint.scm | 181 | ||||
-rw-r--r-- | tests/publish.scm | 4 | ||||
-rw-r--r-- | tests/store.scm | 2 | ||||
-rw-r--r-- | tests/syscalls.scm | 16 | ||||
-rw-r--r-- | tests/texlive.scm | 3 | ||||
-rw-r--r-- | tests/transformations.scm | 10 |
15 files changed, 549 insertions, 207 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm index 9f1104a887..cd165d1be6 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -77,9 +77,6 @@ (lambda (e1 e2) (string<? (car e1) (car e2))))) -;; Avoid collisions with other tests. -(%http-server-port 10500) - (test-begin "derivations") @@ -205,8 +202,6 @@ (build-derivations %store (list drv)) #f))) -(unless (http-server-can-listen?) - (test-skip 1)) (test-assert "'download' built-in builder" (let ((text (random-text))) (with-http-server `((200 ,text)) @@ -221,8 +216,6 @@ get-string-all) text)))))) -(unless (http-server-can-listen?) - (test-skip 1)) (test-assert "'download' built-in builder, invalid hash" (with-http-server `((200 "hello, world!")) (let* ((drv (derivation %store "world" @@ -236,8 +229,6 @@ (build-derivations %store (list drv)) #f)))) -(unless (http-server-can-listen?) - (test-skip 1)) (test-assert "'download' built-in builder, not found" (with-http-server '((404 "not found")) (let* ((drv (derivation %store "will-never-be-found" @@ -262,26 +253,24 @@ (build-derivations %store (list drv)) #f))) -(unless (http-server-can-listen?) - (test-skip 1)) (test-assert "'download' built-in builder, check mode" ;; Make sure rebuilding the 'builtin:download' derivation in check mode ;; works. See <http://bugs.gnu.org/25089>. - (let* ((text (random-text)) - (drv (derivation %store "world" - "builtin:download" '() - #:env-vars `(("url" - . ,(object->string (%local-url)))) - #:hash-algo 'sha256 - #:hash (gcrypt:sha256 (string->utf8 text))))) - (and (with-http-server `((200 ,text)) - (build-derivations %store (list drv))) - (with-http-server `((200 ,text)) - (build-derivations %store (list drv) - (build-mode check))) - (string=? (call-with-input-file (derivation->output-path drv) - get-string-all) - text)))) + (let* ((text (random-text))) + (with-http-server `((200 ,text)) + (let ((drv (derivation %store "world" + "builtin:download" '() + #:env-vars `(("url" + . ,(object->string (%local-url)))) + #:hash-algo 'sha256 + #:hash (gcrypt:sha256 (string->utf8 text))))) + (and drv (build-derivations %store (list drv)) + (with-http-server `((200 ,text)) + (build-derivations %store (list drv) + (build-mode check))) + (string=? (call-with-input-file (derivation->output-path drv) + get-string-all) + text)))))) (test-equal "derivation-name" "foo-0.0" diff --git a/tests/elpa.scm b/tests/elpa.scm index a008cf993c..01ef948b2e 100644 --- a/tests/elpa.scm +++ b/tests/elpa.scm @@ -40,9 +40,6 @@ nil "Integrated environment for *TeX*" tar ((:url . "http://www.gnu.org/software/auctex/"))]))) -;; Avoid collisions with other tests. -(%http-server-port 10300) - (test-begin "elpa") (define (eval-test-with-elpa pkg) diff --git a/tests/gexp.scm b/tests/gexp.scm index 6e92f0e4b3..834e78b9a0 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -51,18 +51,19 @@ ;; For white-box testing. (define (gexp-inputs x) ((@@ (guix gexp) gexp-inputs) x)) -(define (gexp-native-inputs x) - ((@@ (guix gexp) gexp-native-inputs) x)) (define (gexp-outputs x) ((@@ (guix gexp) gexp-outputs) x)) (define (gexp->sexp . x) (apply (@@ (guix gexp) gexp->sexp) x)) (define* (gexp->sexp* exp #:optional target) - (run-with-store %store (gexp->sexp exp - #:target target) + (run-with-store %store (gexp->sexp exp (%current-system) target) #:guile-for-build (%guile-for-build))) +(define (gexp-input->tuple input) + (list (gexp-input-thing input) (gexp-input-output input) + (gexp-input-native? input))) + (define %extension-package ;; Example of a package to use when testing 'with-extensions'. (dummy-package "extension" @@ -106,8 +107,8 @@ (let ((exp (gexp (display (ungexp coreutils))))) (and (gexp? exp) (match (gexp-inputs exp) - (((p "out")) - (eq? p coreutils))) + ((input) + (eq? (gexp-input-thing input) coreutils))) (equal? `(display ,(derivation->output-path (package-derivation %store coreutils))) (gexp->sexp* exp))))) @@ -116,8 +117,8 @@ (let ((exp (gexp (coreutils . (ungexp coreutils))))) (and (gexp? exp) (match (gexp-inputs exp) - (((p "out")) - (eq? p coreutils))) + ((input) + (eq? (gexp-input-thing input) coreutils))) (equal? `(coreutils . ,(derivation->output-path (package-derivation %store coreutils))) (gexp->sexp* exp))))) @@ -126,8 +127,9 @@ (let ((exp (gexp (display (ungexp (package-source coreutils)))))) (and (gexp? exp) (match (gexp-inputs exp) - (((o "out")) - (eq? o (package-source coreutils)))) + ((input) + (and (eq? (gexp-input-thing input) (package-source coreutils)) + (string=? (gexp-input-output input) "out")))) (equal? `(display ,(derivation->output-path (package-source-derivation %store (package-source coreutils)))) @@ -141,8 +143,9 @@ "sha256" file))) (and (gexp? exp) (match (gexp-inputs exp) - (((x "out")) - (eq? x local))) + ((input) + (and (eq? (gexp-input-thing input) local) + (string=? (gexp-input-output input) "out")))) (equal? `(display ,intd) (gexp->sexp* exp))))) (test-assert "one local file, symlink" @@ -158,8 +161,9 @@ "sha256" file))) (and (gexp? exp) (match (gexp-inputs exp) - (((x "out")) - (eq? x local))) + ((input) + (and (eq? (gexp-input-thing input) local) + (string=? (gexp-input-output input) "out")))) (equal? `(display ,intd) (gexp->sexp* exp))))) (lambda () (false-if-exception (delete-file link)))))) @@ -201,8 +205,9 @@ (expected (add-text-to-store %store "hi" "Hello, world!"))) (and (gexp? exp) (match (gexp-inputs exp) - (((x "out")) - (eq? x file))) + ((input) + (and (eq? (gexp-input-thing input) file) + (string=? (gexp-input-output input) "out")))) (equal? `(display ,expected) (gexp->sexp* exp))))) (test-assert "same input twice" @@ -211,8 +216,9 @@ (display (ungexp coreutils)))))) (and (gexp? exp) (match (gexp-inputs exp) - (((p "out")) - (eq? p coreutils))) + ((input) + (and (eq? (gexp-input-thing input) coreutils) + (string=? (gexp-input-output input) "out")))) (let ((e `(display ,(derivation->output-path (package-derivation %store coreutils))))) (equal? `(begin ,e ,e) (gexp->sexp* exp)))))) @@ -228,9 +234,8 @@ (display (ungexp drv)) (display (ungexp txt)))))) (define (match-input thing) - (match-lambda - ((drv-or-pkg _ ...) - (eq? thing drv-or-pkg)))) + (lambda (input) + (eq? (gexp-input-thing input) thing))) (and (gexp? exp) (= 4 (length (gexp-inputs exp))) @@ -255,8 +260,9 @@ (string-append (derivation->output-path drv) "/bin/guile")))) (match (gexp-inputs exp) - (((thing "out")) - (eq? thing fa)))))) + ((input) + (and (eq? (gexp-input-thing input) fa) + (string=? (gexp-input-output input) "out"))))))) (test-assert "file-append, output" (let* ((drv (package-derivation %store glibc)) @@ -268,8 +274,9 @@ (string-append (derivation->output-path drv "debug") "/lib/debug")))) (match (gexp-inputs exp) - (((thing "debug")) - (eq? thing fa)))))) + ((input) + (and (eq? (gexp-input-thing input) fa) + (string=? (gexp-input-output input) "debug"))))))) (test-assert "file-append, nested" (let* ((drv (package-derivation %store glibc)) @@ -283,8 +290,8 @@ (string-append (derivation->output-path drv) "/bin/getent")))) (match (gexp-inputs exp) - (((thing "out")) - (eq? thing file)))))) + ((input) + (eq? (gexp-input-thing input) file)))))) (test-assert "file-append, raw store item" (let* ((obj (plain-file "example.txt" "Hello!")) @@ -338,7 +345,7 @@ (string-append (derivation->output-path drv) "/bin/touch")))))) (test-equal "let-system" - (list `(begin ,(%current-system) #t) '(system-binding) '() + (list `(begin ,(%current-system) #t) '(system-binding) 'low '() '()) (let* ((exp #~(begin #$(let-system system system) @@ -346,10 +353,12 @@ (low (run-with-store %store (lower-gexp exp)))) (list (lowered-gexp-sexp low) (match (gexp-inputs exp) - (((($ (@@ (guix gexp) <system-binding>)) "out")) - '(system-binding)) + ((input) + (and (eq? (struct-vtable (gexp-input-thing input)) + (@@ (guix gexp) <system-binding>)) + (string=? (gexp-input-output input) "out") + '(system-binding))) (x x)) - (gexp-native-inputs exp) 'low (lowered-gexp-inputs low) (lowered-gexp-sources low)))) @@ -371,7 +380,6 @@ (test-equal "let-system, nested" (list `(system* ,(string-append "qemu-system-" (%current-system)) "-m" "256") - '() '(system-binding)) (let ((exp #~(system* #+(let-system (system target) @@ -386,10 +394,13 @@ (basename command)) ,@rest)) (x x)) - (gexp-inputs exp) - (match (gexp-native-inputs exp) - (((($ (@@ (guix gexp) <system-binding>)) "out")) - '(system-binding)) + (match (gexp-inputs exp) + ((input) + (and (eq? (struct-vtable (gexp-input-thing input)) + (@@ (guix gexp) <system-binding>)) + (string=? (gexp-input-output input) "out") + (gexp-input-native? input) + '(system-binding))) (x x))))) (test-assert "ungexp + ungexp-native" @@ -407,27 +418,26 @@ (bu (derivation->output-path (package-cross-derivation %store binutils target)))) (and (lset= equal? - `((,%bootstrap-guile "out") (,glibc "out")) - (gexp-native-inputs exp)) - (lset= equal? - `((,coreutils "out") (,binutils "out")) - (gexp-inputs exp)) + `((,%bootstrap-guile "out" #t) + (,coreutils "out" #f) + (,glibc "out" #t) + (,binutils "out" #f)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? `(list ,guile ,cu ,libc ,bu) (gexp->sexp* exp target))))) (test-equal "ungexp + ungexp-native, nested" - (list `((,%bootstrap-guile "out")) '<> `((,coreutils "out"))) + `((,%bootstrap-guile "out" #f) (,coreutils "out" #t)) (let* ((exp (gexp (list (ungexp-native (gexp (ungexp coreutils))) (ungexp %bootstrap-guile))))) - (list (gexp-inputs exp) '<> (gexp-native-inputs exp)))) + (map gexp-input->tuple (gexp-inputs exp)))) (test-equal "ungexp + ungexp-native, nested, special mixture" - `(() <> ((,coreutils "out"))) + `((,coreutils "out" #t)) - ;; (gexp-native-inputs exp) used to return '(), wrongfully. (let* ((foo (gexp (foo (ungexp-native coreutils)))) (exp (gexp (bar (ungexp foo))))) - (list (gexp-inputs exp) '<> (gexp-native-inputs exp)))) + (map gexp-input->tuple (gexp-inputs exp)))) (test-assert "input list" (let ((exp (gexp (display @@ -437,8 +447,8 @@ (cu (derivation->output-path (package-derivation %store coreutils)))) (and (lset= equal? - `((,%bootstrap-guile "out") (,coreutils "out")) - (gexp-inputs exp)) + `((,%bootstrap-guile "out" #f) (,coreutils "out" #f)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? `(display '(,guile ,cu)) (gexp->sexp* exp))))) @@ -456,11 +466,9 @@ (xbu (derivation->output-path (package-cross-derivation %store binutils target)))) (and (lset= equal? - `((,%bootstrap-guile "out") (,coreutils "out")) - (gexp-native-inputs exp)) - (lset= equal? - `((,glibc "out") (,binutils "out")) - (gexp-inputs exp)) + `((,%bootstrap-guile "out" #t) (,coreutils "out" #t) + (,glibc "out" #f) (,binutils "out" #f)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? `(display (cons '(,guile ,cu) '(,xlibc ,xbu))) (gexp->sexp* exp target))))) @@ -473,8 +481,8 @@ (package-derivation %store %bootstrap-guile)))) (exp (gexp (list (ungexp-splicing (cons (+ 2 3) inputs)))))) (and (lset= equal? - `((,glibc "debug") (,%bootstrap-guile "out")) - (gexp-inputs exp)) + `((,glibc "debug" #f) (,%bootstrap-guile "out" #f)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? (gexp->sexp* exp) `(list ,@(cons 5 outputs)))))) @@ -483,17 +491,16 @@ %bootstrap-guile)) (exp (gexp (list (ungexp-native-splicing (cons (+ 2 3) inputs)))))) (and (lset= equal? - `((,glibc "debug") (,%bootstrap-guile "out")) - (gexp-native-inputs exp)) - (null? (gexp-inputs exp)) + `((,glibc "debug" #t) (,%bootstrap-guile "out" #t)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? (gexp->sexp* exp) ;native (gexp->sexp* exp "mips64el-linux"))))) (test-assert "gexp list splicing + ungexp-splicing" (let* ((inner (gexp (ungexp-native glibc))) (exp (gexp (list (ungexp-splicing (list inner)))))) - (and (equal? `((,glibc "out")) (gexp-native-inputs exp)) - (null? (gexp-inputs exp)) + (and (equal? `((,glibc "out" #t)) + (map gexp-input->tuple (gexp-inputs exp))) (equal? (gexp->sexp* exp) ;native (gexp->sexp* exp "mips64el-linux"))))) @@ -532,7 +539,7 @@ (test-assertm "gexp->file" (mlet* %store-monad ((exp -> (gexp (display (ungexp %bootstrap-guile)))) (guile (package-file %bootstrap-guile)) - (sexp (gexp->sexp exp)) + (sexp (gexp->sexp exp (%current-system) #f)) (drv (gexp->file "foo" exp)) (out -> (derivation->output-path drv)) (done (built-derivations (list drv))) @@ -1088,6 +1095,22 @@ importing.* \\(guix config\\) from the host" (call-with-input-file g-guile read) (list (derivation->output-path guile-drv) bash)))))) +(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)))))) + (test-assertm "gexp->derivation #:allowed-references" (mlet %store-monad ((drv (gexp->derivation "allowed-refs" #~(begin diff --git a/tests/gnu-maintenance.scm b/tests/gnu-maintenance.scm index 4f2f1ae943..837b80063a 100644 --- a/tests/gnu-maintenance.scm +++ b/tests/gnu-maintenance.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2015, 2021 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,7 +19,8 @@ (define-module (test-gnu-maintenance) #:use-module (guix gnu-maintenance) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-64)) + #:use-module (srfi srfi-64) + #:use-module (ice-9 match)) (test-begin "gnu-maintenance") @@ -29,7 +30,11 @@ '(("gcc" "gcc-5.3.0.tar.bz2") ("texmacs" "TeXmacs-1.0.7.9-src.tar.gz") ("icecat" "icecat-38.4.0-gnu1.tar.bz2") - ("mit-scheme" "mit-scheme-9.2.tar.gz"))) + ("mit-scheme" "mit-scheme-9.2.tar.gz") + ("mediainfo" "mediainfo_20.09.tar.xz") + ("exiv2" "exiv2-0.27.3-Source.tar.gz") + ("mpg321" "mpg321_0.3.2.orig.tar.gz") + ("bvi" "bvi-1.4.1.src.tar.gz"))) (every (lambda (project+file) (not (apply release-file? project+file))) '(("guile" "guile-www-1.1.1.tar.gz") @@ -38,4 +43,15 @@ ("mit-scheme" "mit-scheme-9.2-doc-pdf.tar.gz") ("gnutls" "gnutls-3.2.18-w32.zip"))))) +(test-assert "tarball->version" + (let ((tarball->version (@@ (guix gnu-maintenance) tarball->version))) + (every (match-lambda + ((file version) + (equal? (tarball->version file) version))) + '(("coreutils-8.32.tar.gz" "8.32") + ("mediainfo_20.09.tar.xz" "20.09") + ("exiv2-0.27.3-Source.tar.gz" "0.27.3") + ("mpg321_0.3.2.orig.tar.gz" "0.3.2") + ("bvi-1.4.1.src.tar.gz" "1.4.1"))))) + (test-end) diff --git a/tests/go.scm b/tests/go.scm new file mode 100644 index 0000000000..6ab99f508a --- /dev/null +++ b/tests/go.scm @@ -0,0 +1,292 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 François Joulaud <francois.joulaud@radiofrance.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/>. + +;;; Summary +;; Tests for guix/import/go.scm + +(define-module (test-import-go) + #:use-module (guix base32) + #:use-module (guix build-system go) + #:use-module (guix import go) + #:use-module (guix base32) + #:use-module ((guix utils) #:select (call-with-temporary-directory)) + #:use-module (guix tests) + #:use-module (ice-9 match) + #:use-module (srfi srfi-19) + #:use-module (srfi srfi-64) + #:use-module (web response)) + +(define parse-go.mod + (@@ (guix import go) parse-go.mod)) + +(define fixture-go-mod-simple + "module my/thing +go 1.12 +require other/thing v1.0.2 +require new/thing/v2 v2.3.4 +exclude old/thing v1.2.3 +replace bad/thing v1.4.5 => good/thing v1.4.5 +") + +(define fixture-go-mod-with-block + "module M + +require ( + A v1 + B v1.0.0 + C v1.0.0 + D v1.2.3 + E dev +) + +exclude D v1.2.3 +") + + +(define fixture-go-mod-complete + "module M + +go 1.13 + +replace github.com/myname/myproject/myapi => ./api + +replace github.com/mymname/myproject/thissdk => ../sdk + +replace launchpad.net/gocheck => github.com/go-check/check v0.0.0-20140225173054-eb6ee6f84d0a + +require ( + github.com/user/project v1.1.11 + github.com/user/project/sub/directory v1.1.12 + bitbucket.org/user/project v1.11.20 + bitbucket.org/user/project/sub/directory v1.11.21 + launchpad.net/project v1.1.13 + launchpad.net/project/series v1.1.14 + launchpad.net/project/series/sub/directory v1.1.15 + launchpad.net/~user/project/branch v1.1.16 + launchpad.net/~user/project/branch/sub/directory v1.1.17 + hub.jazz.net/git/user/project v1.1.18 + hub.jazz.net/git/user/project/sub/directory v1.1.19 + k8s.io/kubernetes/subproject v1.1.101 + one.example.com/abitrary/repo v1.1.111 + two.example.com/abitrary/repo v0.0.2 + \"quoted.example.com/abitrary/repo\" v0.0.2 +) + +replace two.example.com/abitrary/repo => github.com/corp/arbitrary-repo v0.0.2 + +replace ( + golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13 + golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13 +) + +") + + + +(define fixture-latest-for-go-check + "{\"Version\":\"v0.0.0-20201130134442-10cb98267c6c\",\"Time\":\"2020-11-30T13:44:42Z\"}") + + +(define fixtures-go-check-test + (let ((version + "{\"Version\":\"v0.0.0-20201130134442-10cb98267c6c\",\"Time\":\"2020-11-30T13:44:42Z\"}") + (go.mod + "module gopkg.in/check.v1 + +go 1.11 + +require github.com/kr/pretty v0.2.1 +") + (go-get + "<!DOCTYPE html> +<html lang=\"en\" > + <head> + <meta charset=\"utf-8\"> + <link rel=\"dns-prefetch\" href=\"https://github.githubassets.com\"> + <script crossorigin=\"anonymous\" defer=\"defer\" integrity=\"sha512-aw5tciVT0IsECUmMuwp9ez60QReE2/yFNL1diLgZnOom6RhU8+0lG3RlAKto4JwbCoEP15E41Pksd7rK5BKfCQ==\" type=\"application/javascript\" src=\"https://github.githubassets.com/assets/topic-suggestions-6b0e6d72.js\"></script> + <meta name=\"viewport\" content=\"width=device-width\"> + + <title>GitHub - go-check/check: Rich testing for the Go language</title> + <meta name=\"description\" content=\"Rich testing for the Go language. Contribute to go-check/check development by creating an account on GitHub.\"> + <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"/opensearch.xml\" title=\"GitHub\"> + <link rel=\"fluid-icon\" href=\"https://github.com/fluidicon.png\" title=\"GitHub\"> + <!-- To prevent page flashing, the optimizely JS needs to be loaded in the + <head> tag before the DOM renders --> + <meta name=\"hostname\" content=\"github.com\"> + <meta name=\"user-login\" content=\"\"> + <link href=\"https://github.com/go-check/check/commits/v1.atom\" rel=\"alternate\" title=\"Recent Commits to check:v1\" type=\"application/atom+xml\"> + <meta name=\"go-import\" content=\"github.com/go-check/check git https://github.com/go-check/check.git\"> + </head> + <body class=\"logged-out env-production page-responsive\" style=\"word-wrap: break-word;\"> + </body> +</html> +") + (pkg.go.dev "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n</head>\n<body class=\"Site Site--wide Site--redesign\">\n <div class=\"Site-content\">\n <div class=\"Container\">\n <div class=\"UnitDetails\" data-test-id=\"UnitDetails\">\n <div class=\"UnitDetails-content js-unitDetailsContent\" role=\"main\" data-test-id=\"UnitDetails-content\">\n <div class=\"UnitReadme js-readme\">\n <h2 class=\"UnitReadme-title\" id=\"section-readme\"><img height=\"25px\" width=\"20px\" src=\"/static/img/pkg-icon-readme_20x16.svg\" alt=\"\">README</h2>\n <div class=\"UnitReadme-content\" data-test-id=\"Unit-readmeContent\">\n <div class=\"Overview-readmeContent js-readmeContent\">\n <h3 class=\"h1\" id=\"readme-instructions\">Instructions</h3>\n <p>Install the package with:</p>\n <pre><code>go get gopkg.in/check.v1\n</code></pre>\n </div>\n <div class=\"UnitReadme-fadeOut\"></div>\n </div>\n </div>\n <div class=\"UnitDoc\">\n <h2 class=\"UnitDoc-title\" id=\"section-documentation\"><img height=\"25px\" width=\"20px\" src=\"/static/img/pkg-icon-doc_20x12.svg\" alt=\"\">Documentation</h2>\n <div class=\"Documentation js-documentation\">\n <div class=\"Documentation-content js-docContent\">\n <section class=\"Documentation-overview\">\n <h3 tabindex=\"-1\" id=\"pkg-overview\" class=\"Documentation-overviewHeader\">Overview <a href=\"#pkg-overview\">¶</a></h3>\n <div role=\"navigation\" aria-label=\"Table of Contents\">\n <ul class=\"Documentation-toc\"></ul>\n </div>\n <p>Package check is a rich testing extension for Go's testing package.</p>\n <p>For details about the project, see:</p>\n <pre><a href=\"http://labix.org/gocheck\">http://labix.org/gocheck</a>\n</pre>\n </section>\n <h3 tabindex=\"-1\" id=\"pkg-constants\" class=\"Documentation-constantsHeader\">Constants <a href=\"#pkg-constants\">¶</a></h3>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</body>\n</html>\n") + (pkg.go.dev-licence "<!DOCTYPE html>\n<html lang=\"en\">\n<meta charset=\"utf-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<body class=\"Site Site--wide Site--redesign\">\n <div class=\"Unit-content\" role=\"main\">\n <section class=\"License\" id=\"lic-0\">\n <h2><div id=\"#lic-0\">BSD-2-Clause</div></h2>\n <p>This is not legal advice. <a href=\"/license-policy\">Read disclaimer.</a></p>\n <pre class=\"License-contents\">Gocheck - A rich testing framework for Go\n \nCopyright line\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met: \n\n1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer. \n2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n</pre>\n </section>\n <div class=\"License-source\">Source: github.com/go-check/check@v0.0.0-20201128035030-22ab2dfb190c/LICENSE</div>\n </div>\n </div>\n")) + `(("https://proxy.golang.org/github.com/go-check/check/@v/v0.0.0-20201130134442-10cb98267c6c.mod" + . ,go.mod) + ("https://proxy.golang.org/github.com/go-check/check/@latest" + . ,version) + ("https://github.com/go-check/check?go-get=1" + . ,go-get) + ("https://pkg.go.dev/github.com/go-check/check" + . ,pkg.go.dev) + ("https://pkg.go.dev/github.com/go-check/check?tab=licenses" + . ,pkg.go.dev-licence)))) + +(test-begin "go") + +;;; Unit tests for go build-system + +(test-equal "go-version basic" + "v1.0.2" + (go-version->git-ref "v1.0.2")) + +(test-equal "go-version omited 'v' character" + "v1.0.2" + (go-version->git-ref "v1.0.2")) + +(test-equal "go-version with embeded git-ref" + "65e3620a7ae7" + (go-version->git-ref "v0.0.0-20190821162956-65e3620a7ae7")) + +(test-equal "go-version with complex embeded git-ref" + "daa7c04131f5" + (go-version->git-ref "v1.2.4-0.20191109021931-daa7c04131f5")) + +;;; Unit tests for (guix import go) + +(test-equal "go-path-escape" + "github.com/!azure/!avere" + ((@@ (guix import go) go-path-escape) "github.com/Azure/Avere")) + + +;; We define a function for all similar tests with different go.mod files +(define (testing-parse-mod name expected input) + (define (inf? p1 p2) + (string<? (car p1) (car p2))) + (let ((input-port (open-input-string input))) + (test-equal name + (sort expected inf?) + (sort + ( (@@ (guix import go) parse-go.mod) + input-port) + inf?)))) + +(testing-parse-mod "parse-go.mod-simple" + '(("good/thing" . "v1.4.5") + ("new/thing/v2" . "v2.3.4") + ("other/thing" . "v1.0.2")) + fixture-go-mod-simple) + +(testing-parse-mod "parse-go.mod-with-block" + '(("A" . "v1") + ("B" . "v1.0.0") + ("C" . "v1.0.0") + ("D" . "v1.2.3") + ("E" . "dev")) + fixture-go-mod-with-block) + +(testing-parse-mod "parse-go.mod-complete" + '(("github.com/corp/arbitrary-repo" . "v0.0.2") + ("quoted.example.com/abitrary/repo" . "v0.0.2") + ("one.example.com/abitrary/repo" . "v1.1.111") + ("hub.jazz.net/git/user/project/sub/directory" . "v1.1.19") + ("hub.jazz.net/git/user/project" . "v1.1.18") + ("launchpad.net/~user/project/branch/sub/directory" . "v1.1.17") + ("launchpad.net/~user/project/branch" . "v1.1.16") + ("launchpad.net/project/series/sub/directory" . "v1.1.15") + ("launchpad.net/project/series" . "v1.1.14") + ("launchpad.net/project" . "v1.1.13") + ("bitbucket.org/user/project/sub/directory" . "v1.11.21") + ("bitbucket.org/user/project" . "v1.11.20") + ("k8s.io/kubernetes/subproject" . "v1.1.101") + ("github.com/user/project/sub/directory" . "v1.1.12") + ("github.com/user/project" . "v1.1.11") + ("github.com/go-check/check" . "v0.0.0-20140225173054-eb6ee6f84d0a")) + fixture-go-mod-complete) + +;;; End-to-end tests for (guix import go) +(define (mock-http-fetch testcase) + (lambda (url . rest) + (let ((body (assoc-ref testcase url))) + (if body + (open-input-string body) + (error "mocked http-fetch Unexpected URL: " url))))) + +(define (mock-http-get testcase) + (lambda (url . rest) + (let ((body (assoc-ref testcase url)) + (response-header + (build-response + #:version '(1 . 1) + #:code 200 + #:reason-phrase "Ok" + #:headers `( + (content-type text/html (charset . "utf-8")) + (date . ,(make-date 0 10 58 12 6 3 2021 0)) + (transfer-encoding (chunked))) + #:port #f + #:validate-headers? #t))) + (if body + (values response-header body) + (error "mocked http-get Unexpected URL: " url))))) + +(test-equal "go-module->guix-package" + '(package + (name "go-github-com-go-check-check") + (version "0.0.0-20201130134442-10cb98267c6c") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/go-check/check.git") + (commit (go-version->git-ref version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5")))) + (build-system go-build-system) + (arguments + (quote (#:import-path "github.com/go-check/check"))) + (inputs + (quasiquote (("go-github-com-kr-pretty" + (unquote go-github-com-kr-pretty))))) + (home-page "https://github.com/go-check/check") + (synopsis "Instructions") + (description #f) + (license license:bsd-2)) + + ;; Replace network resources with sample data. + (call-with-temporary-directory + (lambda (checkout) + (mock ((web client) http-get + (mock-http-get fixtures-go-check-test)) + (mock ((guix http-client) http-fetch + (mock-http-fetch fixtures-go-check-test)) + (mock ((guix git) update-cached-checkout + (lambda* (url #:key ref) + ;; Return an empty directory and its hash. + (values checkout + (nix-base32-string->bytevector + "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") + #f))) + (go-module->guix-package "github.com/go-check/check"))))))) + +(test-end "go") + diff --git a/tests/guix-build.sh b/tests/guix-build.sh index b7602e668c..e20702c521 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -1,6 +1,7 @@ # GNU Guix --- Functional package management for GNU # Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> # Copyright © 2020 Marius Bakke <mbakke@fastmail.com> +# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com> # # This file is part of GNU Guix. # @@ -61,8 +62,9 @@ guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' test `guix build sed -s x86_64-linux -d | wc -l` = 1 # Passing multiple '-s' flags. -all_systems="-s x86_64-linux -s i686-linux -s armhf-linux -s aarch64-linux" -test `guix build sed $all_systems -d | sort -u | wc -l` = 4 +all_systems="-s x86_64-linux -s i686-linux -s armhf-linux -s aarch64-linux \ +-s powerpc64le-linux" +test `guix build sed $all_systems -d | sort -u | wc -l` = 5 # Check there's no weird memoization effect leading to erroneous results. # See <https://bugs.gnu.org/40482>. diff --git a/tests/guix-lint.sh b/tests/guix-lint.sh index fdf548fbf1..97c2ea83fe 100644 --- a/tests/guix-lint.sh +++ b/tests/guix-lint.sh @@ -90,3 +90,8 @@ guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy # that it does find it anyway. See <https://bugs.gnu.org/42543>. (cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out" test -z "$(cat "$module_dir/out")" + +# Likewise, when there's a warning, 'package-field-location' used to crash +# because it can't find "t-xyz/foo.scm". See <https://bugs.gnu.org/46390>. +(cd "$module_dir"/.. ; guix lint -c synopsis -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out" +grep_warning "`cat "$module_dir/out"`" diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 7eaad6823f..39e2b514c3 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -386,6 +386,21 @@ guix package -I # '--dry-run' is passed. GUIX_BUILD_OPTIONS="--no-grafts" +# Install using the "imperative model", export a manifest, instantiate it, and +# make sure we get the same profile. +guix package --bootstrap -i guile-bootstrap --without-tests=foo +profile_directory="$(readlink -f "$default_profile")" +guix package --export-manifest > "$tmpfile" +grep 'without-tests.*foo' "$tmpfile" +guix package --rollback --bootstrap +guix package --bootstrap -m "$tmpfile" +test "$(readlink -f "$default_profile")" = "$profile_directory" +guix package --export-manifest > "$tmpfile.2nd" +cmp "$tmpfile" "$tmpfile.2nd" + +rm -f "$tmpfile.2nd" +guix package --rollback --bootstrap + # Applying a manifest file. cat > "$module_dir/manifest.scm"<<EOF (use-package-modules bootstrap) diff --git a/tests/guix-system.sh b/tests/guix-system.sh index 24cc2591d5..238c8929a8 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -337,12 +337,11 @@ for example in gnu/system/examples/*.tmpl; do guix system -n disk-image $target "$example" done -# Verify that the disk image types can be built. +# Verify that the images can be built. guix system -n vm gnu/system/examples/vm-image.tmpl -guix system -n vm-image gnu/system/examples/vm-image.tmpl -# This invocation was taken care of in the loop above: -# guix system -n disk-image gnu/system/examples/bare-bones.tmpl -guix system -n disk-image -t iso9660 gnu/system/examples/bare-bones.tmpl +guix system -n image gnu/system/images/pinebook-pro.scm +guix system -n image -t qcow2 gnu/system/examples/vm-image.tmpl +guix system -n image -t iso9660 gnu/system/examples/bare-bones.tmpl guix system -n docker-image gnu/system/examples/docker-image.tmpl # Verify that at least the raw image type is available. diff --git a/tests/lint.scm b/tests/lint.scm index 7c24611934..bd8604f589 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -61,9 +61,6 @@ ;; Test the linter. -;; Avoid collisions with other tests. -(%http-server-port 9999) - (define %null-sha256 ;; SHA256 of the empty string. (base32 @@ -500,16 +497,16 @@ (home-page "http://does-not-exist")))) (warning-contains? "domain not found" (check-home-page pkg)))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: Connection refused" - "URI http://localhost:9999/foo/bar unreachable: Connection refused" - (let ((pkg (package - (inherit (dummy-package "x")) - (home-page (%local-url))))) - (single-lint-warning-message - (check-home-page pkg)))) +(parameterize ((%http-server-port 9999)) + ;; TODO skip this test if some process is currently listening at 9999 + (test-equal "home-page: Connection refused" + "URI http://localhost:9999/foo/bar unreachable: Connection refused" + (let ((pkg (package + (inherit (dummy-package "x")) + (home-page (%local-url))))) + (single-lint-warning-message + (check-home-page pkg))))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "home-page: 200" '() (with-http-server `((200 ,%long-string)) @@ -518,10 +515,10 @@ (home-page (%local-url))))) (check-home-page pkg)))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: 200 but short length" - "URI http://localhost:9999/foo/bar returned suspiciously small file (18 bytes)" - (with-http-server `((200 "This is too small.")) +(with-http-server `((200 "This is too small.")) + (test-equal "home-page: 200 but short length" + (format #f "URI ~a returned suspiciously small file (18 bytes)" + (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (home-page (%local-url))))) @@ -529,54 +526,51 @@ (single-lint-warning-message (check-home-page pkg))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: 404" - "URI http://localhost:9999/foo/bar not reachable: 404 (\"Such is life\")" - (with-http-server `((404 ,%long-string)) +(with-http-server `((404 ,%long-string)) + (test-equal "home-page: 404" + (format #f "URI ~a not reachable: 404 (\"Such is life\")" (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (home-page (%local-url))))) (single-lint-warning-message (check-home-page pkg))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: 301, invalid" - "invalid permanent redirect from http://localhost:9999/foo/bar" - (with-http-server `((301 ,%long-string)) +(with-http-server `((301 ,%long-string)) + (test-equal "home-page: 301, invalid" + (format #f "invalid permanent redirect from ~a" (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (home-page (%local-url))))) (single-lint-warning-message (check-home-page pkg))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: 301 -> 200" - "permanent redirect from http://localhost:10000/foo/bar to http://localhost:9999/foo/bar" - (with-http-server `((200 ,%long-string)) - (let* ((initial-url (%local-url)) - (redirect (build-response #:code 301 - #:headers - `((location - . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) - (with-http-server `((,redirect "")) +(with-http-server `((200 ,%long-string)) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port 0)) + (with-http-server `((,redirect "")) + (test-equal "home-page: 301 -> 200" + (format #f "permanent redirect from ~a to ~a" + (%local-url) initial-url) (let ((pkg (package (inherit (dummy-package "x")) (home-page (%local-url))))) (single-lint-warning-message (check-home-page pkg)))))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "home-page: 301 -> 404" - "URI http://localhost:10000/foo/bar not reachable: 404 (\"Such is life\")" - (with-http-server '((404 "booh!")) - (let* ((initial-url (%local-url)) - (redirect (build-response #:code 301 - #:headers - `((location - . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) - (with-http-server `((,redirect "")) +(with-http-server `((404 "booh!")) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port 0)) + (with-http-server `((,redirect "")) + (test-equal "home-page: 301 -> 404" + (format #f "URI ~a not reachable: 404 (\"Such is life\")" (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (home-page (%local-url))))) @@ -706,7 +700,6 @@ (sha256 %null-sha256)))))) (check-source-unstable-tarball pkg))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "source: 200" '() (with-http-server `((200 ,%long-string)) @@ -718,10 +711,10 @@ (sha256 %null-sha256)))))) (check-source pkg)))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "source: 200 but short length" - "URI http://localhost:9999/foo/bar returned suspiciously small file (18 bytes)" - (with-http-server '((200 "This is too small.")) +(with-http-server '((200 "This is too small.")) + (test-equal "source: 200 but short length" + (format #f "URI ~a returned suspiciously small file (18 bytes)" + (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (source (origin @@ -733,10 +726,10 @@ (and (? lint-warning?) second-warning)) (lint-warning-message second-warning)))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "source: 404" - "URI http://localhost:9999/foo/bar not reachable: 404 (\"Such is life\")" - (with-http-server `((404 ,%long-string)) +(with-http-server `((404 ,%long-string)) + (test-equal "source: 404" + (format #f "URI ~a not reachable: 404 (\"Such is life\")" + (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (source (origin @@ -748,7 +741,6 @@ (and (? lint-warning?) second-warning)) (lint-warning-message second-warning)))))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "source: 404 and 200" '() (with-http-server `((404 ,%long-string)) @@ -765,17 +757,17 @@ ;; list. (check-source pkg))))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "source: 301 -> 200" - "permanent redirect from http://localhost:10000/foo/bar to http://localhost:9999/foo/bar" - (with-http-server `((200 ,%long-string)) - (let* ((initial-url (%local-url)) - (redirect (build-response #:code 301 - #:headers - `((location - . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) - (with-http-server `((,redirect "")) +(with-http-server `((200 ,%long-string)) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port 0)) + (with-http-server `((,redirect "")) + (test-equal "source: 301 -> 200" + (format #f "permanent redirect from ~a to ~a" + (%local-url) initial-url) (let ((pkg (package (inherit (dummy-package "x")) (source (origin @@ -787,17 +779,17 @@ (and (? lint-warning?) second-warning)) (lint-warning-message second-warning))))))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "source, git-reference: 301 -> 200" - "permanent redirect from http://localhost:10000/foo/bar to http://localhost:9999/foo/bar" - (with-http-server `((200 ,%long-string)) - (let* ((initial-url (%local-url)) - (redirect (build-response #:code 301 - #:headers - `((location - . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) - (with-http-server `((,redirect "")) +(with-http-server `((200 ,%long-string)) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port 0)) + (with-http-server `((,redirect "")) + (test-equal "source, git-reference: 301 -> 200" + (format #f "permanent redirect from ~a to ~a" + (%local-url) initial-url) (let ((pkg (dummy-package "x" (source (origin @@ -807,17 +799,17 @@ (sha256 %null-sha256)))))) (single-lint-warning-message (check-source pkg)))))))) -(test-skip (if (http-server-can-listen?) 0 1)) -(test-equal "source: 301 -> 404" - "URI http://localhost:10000/foo/bar not reachable: 404 (\"Such is life\")" - (with-http-server '((404 "booh!")) - (let* ((initial-url (%local-url)) - (redirect (build-response #:code 301 - #:headers - `((location - . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) - (with-http-server `((,redirect "")) +(with-http-server '((404 "booh!")) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port 0)) + (with-http-server `((,redirect "")) + (test-equal "source: 301 -> 404" + (format #f "URI ~a not reachable: 404 (\"Such is life\")" + (%local-url)) (let ((pkg (package (inherit (dummy-package "x")) (source (origin @@ -847,7 +839,6 @@ (single-lint-warning-message (check-mirror-url (dummy-package "x" (source source)))))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "github-url" '() (with-http-server `((200 ,%long-string)) @@ -859,7 +850,6 @@ (sha256 %null-sha256))))))) (let ((github-url "https://github.com/foo/bar/bar-1.0.tar.gz")) - (test-skip (if (http-server-can-listen?) 0 1)) (test-equal "github-url: one suggestion" (string-append "URL should be '" github-url "'") @@ -873,7 +863,7 @@ #:headers `((location . ,(string->uri initial-url)))))) - (parameterize ((%http-server-port (+ 1 (%http-server-port)))) + (parameterize ((%http-server-port 0)) (with-http-server `((,redirect "")) (single-lint-warning-message (check-github-url @@ -883,7 +873,6 @@ (uri (%local-url)) (sha256 %null-sha256)))))))))))) - (test-skip (if (http-server-can-listen?) 0 1)) (test-equal "github-url: already the correct github url" '() (check-github-url @@ -1007,7 +996,6 @@ '() (check-formatting (dummy-package "x"))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "archival: missing content" (let* ((origin (origin (method url-fetch) @@ -1019,7 +1007,6 @@ (source origin))))))) (warning-contains? "not archived" warnings))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "archival: content available" '() (let* ((origin (origin @@ -1033,7 +1020,6 @@ (parameterize ((%swh-base-url (%local-url))) (check-archival (dummy-package "x" (source origin))))))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "archival: missing revision" (let* ((origin (origin (method git-fetch) @@ -1053,7 +1039,6 @@ (check-archival (dummy-package "x" (source origin))))))) (warning-contains? "scheduled" warnings))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-equal "archival: revision available" '() (let* ((origin (origin @@ -1069,7 +1054,6 @@ (parameterize ((%swh-base-url (%local-url))) (check-archival (dummy-package "x" (source origin))))))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "archival: rate limit reached" ;; We should get a single warning stating that the rate limit was reached, ;; and nothing more, in particular no other HTTP requests. @@ -1091,7 +1075,6 @@ (string-contains (single-lint-warning-message warnings) "rate limit reached"))) -(test-skip (if (http-server-can-listen?) 0 1)) (test-assert "haskell-stackage" (let* ((stackage (string-append "{ \"packages\": [{" " \"name\":\"x\"," diff --git a/tests/publish.scm b/tests/publish.scm index 52101876b5..3e67c435ac 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -452,8 +452,8 @@ References: ~%" (wait-for-file cached) ;; Both the narinfo and nar should be world-readable. - (= #o644 (stat:perms (lstat cached))) - (= #o644 (stat:perms (lstat nar))) + (= #o444 (logand #o444 (stat:perms (lstat cached)))) + (= #o444 (logand #o444 (stat:perms (lstat nar)))) (let* ((body (http-get-port url)) (compressed (http-get nar-url)) diff --git a/tests/store.scm b/tests/store.scm index cda0e0302f..9c25adf5e9 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -50,7 +50,7 @@ (open-connection-for-tests)) (define %shell - (or (getenv "SHELL") (getenv "CONFIG_SHELL"))) + (or (getenv "SHELL") (getenv "CONFIG_SHELL") "/bin/sh")) (test-begin "store") diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 09aa228e8e..706dd4177f 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2020 Simon South <simon@simonsouth.net> ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com> @@ -56,6 +56,20 @@ ;; Both return values have been encountered in the wild. (memv (system-error-errno args) (list EPERM ENOENT))))) +(test-assert "mounts" + ;; Check for one of the common mount points. + (let ((mounts (mounts))) + (any (match-lambda + ((point . type) + (let ((mount (find (lambda (mount) + (string=? (mount-point mount) point)) + mounts))) + (and mount + (string=? (mount-type mount) type))))) + '(("/proc" . "proc") + ("/sys" . "sysfs") + ("/dev/shm" . "tmpfs"))))) + (test-assert "mount-points" ;; Reportedly "/" is not always listed as a mount point, so check a few ;; others (see <http://bugs.gnu.org/20261>.) diff --git a/tests/texlive.scm b/tests/texlive.scm index f7e5515c4c..a6f08046a8 100644 --- a/tests/texlive.scm +++ b/tests/texlive.scm @@ -69,9 +69,6 @@ (keyval (@ (value "tests") (key "topic"))) "\n null\n"))) -;; Avoid collisions with other tests. -(%http-server-port 10200) - (test-equal "fetch-sxml: returns SXML for valid XML" sxml (with-http-server `((200 ,xml)) diff --git a/tests/transformations.scm b/tests/transformations.scm index 7877029486..902bd45a6a 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -20,6 +20,9 @@ #:use-module (guix tests) #:use-module (guix store) #:use-module ((guix gexp) #:select (lower-object)) + #:use-module ((guix profiles) + #:select (package->manifest-entry + manifest-entry-properties)) #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix git-download) @@ -413,6 +416,13 @@ `((with-latest . "foo"))))) (package-version (t p))))) +(test-equal "options->transformation + package->manifest-entry" + '((transformations . ((without-tests . "foo")))) + (let* ((p (dummy-package "foo")) + (t (options->transformation '((without-tests . "foo")))) + (e (package->manifest-entry (t p)))) + (manifest-entry-properties e))) + (test-end) ;;; Local Variables: |