summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLiliana Marie Prikler <liliana.prikler@gmail.com>2024-01-21 09:59:52 +0100
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2024-01-21 09:59:55 +0100
commitff1ec930e5baa00b483f1ce43fa8bec18c797c03 (patch)
tree1c102408d5d79e12b70fe81f97602d3856ed334e /tests
parent60c97924e9519361494aaf0686e28eb831a42315 (diff)
parentc7f937cfdd9a08bad81705fe731e9fa5937cf562 (diff)
Merge branch 'master' into emacs-team
Diffstat (limited to 'tests')
-rw-r--r--tests/composer.scm88
-rw-r--r--tests/crate.scm576
-rw-r--r--tests/gexp.scm107
-rw-r--r--tests/go.scm6
-rwxr-xr-xtests/guix-locate.sh6
-rw-r--r--tests/guix-shell.sh33
-rw-r--r--tests/guix-time-machine.sh26
-rw-r--r--tests/hackage.scm47
-rw-r--r--tests/pack.scm57
-rw-r--r--tests/profiles.scm4
-rw-r--r--tests/read-print.scm5
-rw-r--r--tests/store.scm25
-rw-r--r--tests/substitute.scm45
-rw-r--r--tests/syscalls.scm8
-rw-r--r--tests/utils.scm12
15 files changed, 910 insertions, 135 deletions
diff --git a/tests/composer.scm b/tests/composer.scm
new file mode 100644
index 0000000000..9114fef19e
--- /dev/null
+++ b/tests/composer.scm
@@ -0,0 +1,88 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
+;;;
+;;; 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-composer)
+ #:use-module (guix import composer)
+ #:use-module (guix base32)
+ #:use-module (gcrypt hash)
+ #:use-module (guix tests http)
+ #:use-module (guix grafts)
+ #:use-module (srfi srfi-64)
+ #:use-module (web client)
+ #:use-module (ice-9 match))
+
+;; Globally disable grafts because they can trigger early builds.
+(%graft? #f)
+
+(define test-json
+ "{
+ \"packages\": {
+ \"foo/bar\": {
+ \"0.1\": {
+ \"name\": \"foo/bar\",
+ \"description\": \"description\",
+ \"keywords\": [\"testing\"],
+ \"homepage\": \"http://example.com\",
+ \"version\": \"0.1\",
+ \"license\": [\"BSD-3-Clause\"],
+ \"source\": {
+ \"type\": \"url\",
+ \"url\": \"http://example.com/Bar-0.1.tar.gz\"
+ },
+ \"require\": {},
+ \"require-dev\": {\"phpunit/phpunit\": \"1.0.0\"}
+ }
+ }
+ }
+}")
+
+(define test-source
+ "foobar")
+
+(test-begin "composer")
+
+(test-assert "composer->guix-package"
+ ;; Replace network resources with sample data.
+ (with-http-server `((200 ,test-json)
+ (200 ,test-source))
+ (parameterize ((%composer-base-url (%local-url))
+ (current-http-proxy (%local-url)))
+ (match (composer->guix-package "foo/bar")
+ (`(package
+ (name "php-foo-bar")
+ (version "0.1")
+ (source (origin
+ (method url-fetch)
+ (uri "http://example.com/Bar-0.1.tar.gz")
+ (sha256
+ (base32
+ ,(? string? hash)))))
+ (build-system composer-build-system)
+ (native-inputs (list php-phpunit-phpunit))
+ (synopsis "")
+ (description "description")
+ (home-page "http://example.com")
+ (license license:bsd-3))
+ (string=? (bytevector->nix-base32-string
+ (call-with-input-string test-source port-sha256))
+ hash))
+ (x
+ (pk 'fail x #f))))))
+
+(test-end "composer")
diff --git a/tests/crate.scm b/tests/crate.scm
index 5aea5efaf3..ce2f08aade 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,7 +25,10 @@
#:use-module (guix import crate)
#:use-module (guix base32)
#:use-module (guix build-system cargo)
- #:use-module (gcrypt hash)
+ #:use-module ((gcrypt hash)
+ #:select ((sha256 . gcrypt-sha256)))
+ #:use-module (guix packages)
+ #:use-module (guix read-print)
#:use-module (guix tests)
#:use-module (gnu packages)
#:use-module (ice-9 iconv)
@@ -37,13 +41,18 @@
;; foo-1.0.0
;; foo-1.0.3
;; leaf-alice 0.7.5
+;; bar-1.0.0
+;; leaf-bob 3.0.1
+;; leaf-bob 3.0.2 (dev-dependency)
+;; leaf-bob 4.0.0 (dev-dependency)
;;
;; root-1.0.0
;; root-1.0.4
-;; intermediate-a 1.0.42
-;; intermeidate-b ^1.0.0
+;; intermediate-a 1.0.42
+;; intermediate-b ^1.0.0
;; leaf-alice ^0.7
-;; leaf-bob ^3
+;; leaf-bob ^3
+;; intermediate-c 1 (dev-dependency)
;;
;; intermediate-a-1.0.40
;; intermediate-a-1.0.42
@@ -55,10 +64,15 @@
;; intermediate-b-1.2.3
;; leaf-bob 3.0.1
;;
+;; intermediate-c-1.0.1
+;; leaf-alice 0.7.5 (dev-dependency)
+;;
;; leaf-alice-0.7.3
;; leaf-alice-0.7.5
;;
;; leaf-bob-3.0.1
+;; leaf-bob-3.0.2 (yanked)
+;; leaf-bob-4.0.0 (yanked)
(define test-foo-crate
@@ -111,6 +125,50 @@
]
}")
+(define test-bar-crate
+ "{
+ \"crate\": {
+ \"max_version\": \"1.0.0\",
+ \"name\": \"bar\",
+ \"description\": \"summary\",
+ \"homepage\": \"http://example.com\",
+ \"repository\": \"http://example.com\",
+ \"keywords\": [\"dummy\", \"test\"],
+ \"categories\": [\"test\"],
+ \"actual_versions\": [
+ { \"id\": 234100,
+ \"num\": \"1.0.0\",
+ \"license\": \"MIT OR Apache-2.0\",
+ \"links\": {
+ \"dependencies\": \"/api/v1/crates/bar/1.0.0/dependencies\"
+ },
+ \"yanked\": false
+ }
+ ]
+ }
+}")
+
+(define test-bar-dependencies
+ "{
+ \"dependencies\": [
+ {
+ \"crate_id\": \"leaf-bob\",
+ \"kind\": \"normal\",
+ \"req\": \"3.0.1\"
+ },
+ {
+ \"crate_id\": \"leaf-bob\",
+ \"kind\": \"dev\",
+ \"req\": \"^3.0.2\"
+ },
+ {
+ \"crate_id\": \"leaf-bob\",
+ \"kind\": \"dev\",
+ \"req\": \"^4.0.0\"
+ }
+ ]
+}")
+
(define test-root-crate
"{
\"crate\": {
@@ -164,6 +222,11 @@
\"crate_id\": \"leaf-bob\",
\"kind\": \"normal\",
\"req\": \"^3\"
+ },
+ {
+ \"crate_id\": \"intermediate-c\",
+ \"kind\": \"dev\",
+ \"req\": \"1\"
}
]
}")
@@ -262,6 +325,40 @@
]
}")
+(define test-intermediate-c-crate
+ "{
+ \"crate\": {
+ \"max_version\": \"1.0.1\",
+ \"name\": \"intermediate-c\",
+ \"description\": \"summary\",
+ \"homepage\": \"http://example.com\",
+ \"repository\": \"http://example.com\",
+ \"keywords\": [\"dummy\", \"test\"],
+ \"categories\": [\"test\"],
+ \"actual_versions\": [
+ { \"id\": 234290,
+ \"num\": \"1.0.1\",
+ \"license\": \"MIT OR Apache-2.0\",
+ \"links\": {
+ \"dependencies\": \"/api/v1/crates/intermediate-c/1.0.1/dependencies\"
+ },
+ \"yanked\": false
+ }
+ ]
+ }
+}")
+
+(define test-intermediate-c-dependencies
+ "{
+ \"dependencies\": [
+ {
+ \"crate_id\": \"leaf-alice\",
+ \"kind\": \"dev\",
+ \"req\": \"0.7.5\"
+ }
+ ]
+}")
+
(define test-leaf-alice-crate
"{
\"crate\": {
@@ -316,6 +413,22 @@
\"dependencies\": \"/api/v1/crates/leaf-bob/3.0.1/dependencies\"
},
\"yanked\": false
+ },
+ { \"id\": 234281,
+ \"num\": \"3.0.2\",
+ \"license\": \"MIT OR Apache-2.0\",
+ \"links\": {
+ \"dependencies\": \"/api/v1/crates/leaf-bob/3.0.2/dependencies\"
+ },
+ \"yanked\": true
+ },
+ { \"id\": 234282,
+ \"num\": \"4.0.0\",
+ \"license\": \"MIT OR Apache-2.0\",
+ \"links\": {
+ \"dependencies\": \"/api/v1/crates/leaf-bob/4.0.0/dependencies\"
+ },
+ \"yanked\": true
}
]
}
@@ -355,7 +468,7 @@
("https://crates.io/api/v1/crates/foo/1.0.3/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/foo/1.0.3/dependencies"
(open-input-string test-foo-dependencies))
@@ -364,7 +477,7 @@
("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies"
(open-input-string test-leaf-alice-dependencies))
@@ -398,7 +511,7 @@
(pk 'fail x #f)))))
(unless have-guile-semver? (test-skip 1))
-(test-assert "cargo-recursive-import"
+(test-assert "crate-recursive-import"
;; Replace network resources with sample data.
(mock ((guix http-client) http-fetch
(lambda (url . rest)
@@ -408,7 +521,7 @@
("https://crates.io/api/v1/crates/root/1.0.4/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/root/1.0.4/dependencies"
(open-input-string test-root-dependencies))
@@ -417,7 +530,7 @@
("https://crates.io/api/v1/crates/intermediate-a/1.0.42/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/intermediate-a/1.0.42/dependencies"
(open-input-string test-intermediate-a-dependencies))
@@ -426,16 +539,25 @@
("https://crates.io/api/v1/crates/intermediate-b/1.2.3/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies"
(open-input-string test-intermediate-b-dependencies))
+ ("https://crates.io/api/v1/crates/intermediate-c"
+ (open-input-string test-intermediate-c-crate))
+ ("https://crates.io/api/v1/crates/intermediate-c/1.0.1/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/intermediate-c/1.0.1/dependencies"
+ (open-input-string test-intermediate-c-dependencies))
("https://crates.io/api/v1/crates/leaf-alice"
(open-input-string test-leaf-alice-crate))
("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies"
(open-input-string test-leaf-alice-dependencies))
@@ -444,7 +566,7 @@
("https://crates.io/api/v1/crates/leaf-bob/3.0.1/download"
(set! test-source-hash
(bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
(open-input-string "empty file\n"))
("https://crates.io/api/v1/crates/leaf-bob/3.0.1/dependencies"
(open-input-string test-leaf-bob-dependencies))
@@ -452,7 +574,27 @@
(match (crate-recursive-import "root")
;; rust-intermediate-b has no dependency on the rust-leaf-alice
;; package, so this is a valid ordering
- (((define-public 'rust-leaf-alice-0.7
+ (((define-public 'rust-intermediate-c-1
+ (package
+ (name "rust-intermediate-c")
+ (version "1.0.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "intermediate-c" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:skip-build? #t)))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-leaf-alice-0.7
(package
(name "rust-leaf-alice")
(version "0.7.5")
@@ -563,10 +705,157 @@
("rust-leaf-alice"
('unquote 'rust-leaf-alice-0.7))
("rust-leaf-bob"
+ ('unquote rust-leaf-bob-3)))
+ #:cargo-development-inputs
+ (("rust-intermediate-c"
+ ('unquote rust-intermediate-c-1))))))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0)))))
+ #t)
+ (x
+ (pk 'fail x #f)))
+ (match (crate-recursive-import "root"
+ #:recursive-dev-dependencies? #t)
+ ;; rust-intermediate-b has no dependency on the rust-leaf-alice
+ ;; package, so this is a valid ordering
+ (((define-public 'rust-intermediate-c-1
+ (package
+ (name "rust-intermediate-c")
+ (version "1.0.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "intermediate-c" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:cargo-development-inputs
+ (("rust-leaf-alice"
+ ('unquote rust-leaf-alice-0.7))))))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-leaf-alice-0.7
+ (package
+ (name "rust-leaf-alice")
+ (version "0.7.5")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "leaf-alice" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-leaf-bob-3
+ (package
+ (name "rust-leaf-bob")
+ (version "3.0.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "leaf-bob" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-intermediate-b-1
+ (package
+ (name "rust-intermediate-b")
+ (version "1.2.3")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "intermediate-b" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:cargo-inputs
+ (("rust-leaf-bob"
+ ('unquote rust-leaf-bob-3))))))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-intermediate-a-1
+ (package
+ (name "rust-intermediate-a")
+ (version "1.0.42")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "intermediate-a" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:cargo-inputs
+ (("rust-intermediate-b"
+ ('unquote rust-intermediate-b-1))
+ ("rust-leaf-alice"
+ ('unquote 'rust-leaf-alice-0.7))
+ ("rust-leaf-bob"
('unquote rust-leaf-bob-3))))))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-root-1
+ (package
+ (name "rust-root")
+ (version "1.0.4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "root" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:cargo-inputs
+ (("rust-intermediate-a"
+ ('unquote rust-intermediate-a-1))
+ ("rust-intermediate-b"
+ ('unquote rust-intermediate-b-1))
+ ("rust-leaf-alice"
+ ('unquote 'rust-leaf-alice-0.7))
+ ("rust-leaf-bob"
+ ('unquote rust-leaf-bob-3)))
+ #:cargo-development-inputs
+ (("rust-intermediate-c"
+ ('unquote rust-intermediate-c-1))))))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
(license (list license:expat license:asl2.0)))))
#t)
(x
@@ -594,69 +883,209 @@
-(define test-doctool-crate
- "{
- \"crate\": {
- \"max_version\": \"2.2.2\",
- \"name\": \"leaf-bob\",
- \"description\": \"summary\",
- \"homepage\": \"http://example.com\",
- \"repository\": \"http://example.com\",
- \"keywords\": [\"dummy\", \"test\"],
- \"categories\": [\"test\"]
- \"actual_versions\": [
- { \"id\": 234280,
- \"num\": \"2.2.2\",
- \"license\": \"MIT OR Apache-2.0\",
- \"links\": {
- \"dependencies\": \"/api/v1/crates/doctool/2.2.2/dependencies\"
- },
- \"yanked\": false
- }
- ]
- }
-}")
+(define rust-leaf-bob-3
+ (package
+ (name "rust-leaf-bob")
+ (version "3.0.1")
+ (source #f)
+ (build-system #f)
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license #f)))
-;; FIXME: This test depends on some existing packages
-(define test-doctool-dependencies
- "{
- \"dependencies\": [
- {
- \"crate_id\": \"docopt\",
- \"kind\": \"normal\",
- \"req\": \"^0.8.1\"
- }
- ]
-}")
+(define rust-leaf-bob-3.0.2-yanked
+ (package
+ (name "rust-leaf-bob")
+ (version "3.0.2")
+ (source #f)
+ (properties '((crate-version-yanked? . #t)))
+ (build-system #f)
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license #f)))
-
-(test-assert "self-test: rust-docopt 0.8.x is gone, please adjust the test case"
- (not (null? (find-packages-by-name "rust-docopt" "0.8"))))
+(unless have-guile-semver? (test-skip 1))
+(test-assert "crate-recursive-import-honors-existing-packages"
+ (mock
+ ((gnu packages) find-packages-by-name
+ (lambda* (name #:optional version)
+ (match name
+ ("rust-leaf-bob"
+ (list rust-leaf-bob-3 rust-leaf-bob-3.0.2-yanked))
+ (_ '()))))
+ (mock
+ ((guix http-client) http-fetch
+ (lambda (url . rest)
+ (match url
+ ("https://crates.io/api/v1/crates/bar"
+ (open-input-string test-bar-crate))
+ ("https://crates.io/api/v1/crates/bar/1.0.0/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/bar/1.0.0/dependencies"
+ (open-input-string test-bar-dependencies))
+ ("https://crates.io/api/v1/crates/leaf-bob"
+ (open-input-string test-leaf-bob-crate))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.2/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.2/dependencies"
+ (open-input-string test-leaf-bob-dependencies))
+ ("https://crates.io/api/v1/crates/leaf-bob/4.0.0/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/leaf-bob/4.0.0/dependencies"
+ (open-input-string test-leaf-bob-dependencies))
+ (_ (error "Unexpected URL: " url)))))
+ (match (crate-recursive-import "bar"
+ #:allow-yanked? #t)
+ (((define-public 'rust-bar-1
+ (package
+ (name "rust-bar")
+ (version "1.0.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "bar" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (arguments
+ ('quasiquote (#:cargo-inputs
+ (("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-3)))
+ #:cargo-development-inputs
+ (("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-3.0.2-yanked))
+ ("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0)))))
+ #t)
+ (x
+ (pk 'fail x #f))))))
(unless have-guile-semver? (test-skip 1))
-(test-assert "cargo-recursive-import-hoors-existing-packages"
- (mock ((guix http-client) http-fetch
- (lambda (url . rest)
- (match url
- ("https://crates.io/api/v1/crates/doctool"
- (open-input-string test-doctool-crate))
- ("https://crates.io/api/v1/crates/doctool/2.2.2/download"
- (set! test-source-hash
- (bytevector->nix-base32-string
- (sha256 (string->bytevector "empty file\n" "utf-8"))))
- (open-input-string "empty file\n"))
- ("https://crates.io/api/v1/crates/doctool/2.2.2/dependencies"
- (open-input-string test-doctool-dependencies))
- (_ (error "Unexpected URL: " url)))))
- (match (crate-recursive-import "doctool")
- (((define-public 'rust-doctool-2
+(test-assert "crate-import-only-yanked-available"
+ (mock
+ ((guix http-client) http-fetch
+ (lambda (url . rest)
+ (match url
+ ("https://crates.io/api/v1/crates/bar"
+ (open-input-string test-bar-crate))
+ ("https://crates.io/api/v1/crates/bar/1.0.0/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/bar/1.0.0/dependencies"
+ (open-input-string test-bar-dependencies))
+ ("https://crates.io/api/v1/crates/leaf-bob"
+ (open-input-string test-leaf-bob-crate))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/dependencies"
+ (open-input-string test-leaf-bob-dependencies))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.2/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/leaf-bob/3.0.2/dependencies"
+ (open-input-string test-leaf-bob-dependencies))
+ ("https://crates.io/api/v1/crates/leaf-bob/4.0.0/download"
+ (set! test-source-hash
+ (bytevector->nix-base32-string
+ (gcrypt-sha256 (string->bytevector "empty file\n" "utf-8"))))
+ (open-input-string "empty file\n"))
+ ("https://crates.io/api/v1/crates/leaf-bob/4.0.0/dependencies"
+ (open-input-string test-leaf-bob-dependencies))
+ (_ (error "Unexpected URL: " url)))))
+ (match (crate-recursive-import "bar"
+ #:recursive-dev-dependencies? #t
+ #:allow-yanked? #t)
+ (((define-public 'rust-leaf-bob-4.0.0-yanked
+ (package
+ (name "rust-leaf-bob")
+ (version "4.0.0")
+ ($ <comment> "; This version was yanked!\n" #t)
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "leaf-bob" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (properties ('quote (('crate-version-yanked? . #t))))
+ (build-system cargo-build-system)
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-leaf-bob-3.0.2-yanked
(package
- (name "rust-doctool")
- (version "2.2.2")
+ (name "rust-leaf-bob")
+ (version "3.0.2")
+ ($ <comment> "; This version was yanked!\n" #t)
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "leaf-bob" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (properties ('quote (('crate-version-yanked? . #t))))
+ (build-system cargo-build-system)
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-leaf-bob-3
+ (package
+ (name "rust-leaf-bob")
+ (version "3.0.1")
(source
(origin
(method url-fetch)
- (uri (crate-uri "doctool" version))
+ (uri (crate-uri "leaf-bob" version))
+ (file-name
+ (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ (? string? hash)))))
+ (build-system cargo-build-system)
+ (home-page "http://example.com")
+ (synopsis "summary")
+ (description "summary")
+ (license (list license:expat license:asl2.0))))
+ (define-public 'rust-bar-1
+ (package
+ (name "rust-bar")
+ (version "1.0.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (crate-uri "bar" version))
(file-name
(string-append name "-" version ".tar.gz"))
(sha256
@@ -665,14 +1094,19 @@
(build-system cargo-build-system)
(arguments
('quasiquote (#:cargo-inputs
- (("rust-docopt"
- ('unquote 'rust-docopt-0.8))))))
+ (("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-3)))
+ #:cargo-development-inputs
+ (("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-3.0.2-yanked))
+ ("rust-leaf-bob"
+ ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
(license (list license:expat license:asl2.0)))))
#t)
(x
- (pk 'fail x #f)))))
+ (pk 'fail (pretty-print-with-comments (current-output-port) x) #f)))))
(test-end "crate")
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 7a90f8dcbf..001786c13c 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021-2022 Maxime Devos <maximedevos@telenet.be>
;;;
;;; This file is part of GNU Guix.
@@ -393,6 +393,30 @@
(list item))
(null? (lowered-gexp-inputs lexp)))))
+(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)))))
+
(test-assertm "with-parameters for %current-system"
(mlet* %store-monad ((system -> (match (%current-system)
("aarch64-linux" "x86_64-linux")
@@ -826,38 +850,39 @@
(call-with-output-file (string-append #$output "/two")
(lambda (port)
(display "This is the second one." port))))))
- (build-drv #~(begin
- (use-modules (guix build store-copy)
- (guix build utils)
- (srfi srfi-1))
+ (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)))))))
+ (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)
+ (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)))))
+ ;; Check whether 'populate-store' canonicalizes
+ ;; permissions and timestamps.
+ (unless (every canonical-file? (find-files #$output))
+ (error "not canonical!" #$output))))))
(mlet* %store-monad ((one (gexp->derivation "one" build-one))
(two (gexp->derivation "two" (build-two one)))
(drv (gexp->derivation "store-copy" build-drv
#:references-graphs
- `(("graph" ,two))
- #:modules
- '((guix build store-copy)
- (guix progress)
- (guix records)
- (guix sets)
- (guix build utils))))
+ `(("graph" ,two))))
(ok? (built-derivations (list drv)))
(out -> (derivation->output-path drv)))
(let ((one (derivation->output-path one))
@@ -1627,6 +1652,36 @@ importing.* \\(guix config\\) from the host"
read)
refs)))))))
+(test-assertm "references-file, non-default output"
+ (let* ((exp #~(begin
+ (mkdir #$output)
+ (symlink #$%bootstrap-guile #$output:extra)))
+ (computed (computed-file "computed" exp
+ #:guile %bootstrap-guile))
+ (refs1 (references-file computed
+ #:guile %bootstrap-guile))
+ ;; Wrap COMPUTE in 'gexp-input' to get the "extra" output.
+ (refs2 (references-file (gexp-input computed "extra")
+ #:guile %bootstrap-guile)))
+ (mlet* %store-monad ((drv0 (lower-object %bootstrap-guile))
+ (drv1 (lower-object computed))
+ (drv2 (lower-object refs2))
+ (drv3 (lower-object refs1)))
+ (mbegin %store-monad
+ (built-derivations (list drv2 drv3))
+ (mlet %store-monad ((refs ((store-lift requisites)
+ (list (derivation->output-path
+ drv1 "extra")))))
+ (return
+ (and (lset= string=?
+ (call-with-input-file (derivation->output-path drv2)
+ read)
+ refs)
+ (lset= string=?
+ (call-with-input-file (derivation->output-path drv3)
+ read)
+ (list (derivation->output-path drv1))))))))))
+
(test-assert "lower-object & gexp-input-error?"
(guard (c ((gexp-input-error? c)
(gexp-error-invalid-input c)))
diff --git a/tests/go.scm b/tests/go.scm
index a70a0ddbf5..d2e8846b30 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright 2021 Franois Joulaud <francois.joulaud@radiofrance.com>
-;;; Copyright 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2021 François Joulaud <francois.joulaud@radiofrance.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -387,7 +387,7 @@ require github.com/kr/pretty v0.2.1
"0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"))))
(build-system go-build-system)
(arguments
- '(#:import-path "github.com/go-check/check"))
+ (list #:import-path "github.com/go-check/check"))
(propagated-inputs
`(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
(home-page "https://github.com/go-check/check")
diff --git a/tests/guix-locate.sh b/tests/guix-locate.sh
index 43f8ba53b0..de0ea5769d 100755
--- a/tests/guix-locate.sh
+++ b/tests/guix-locate.sh
@@ -70,3 +70,9 @@ then
$cmd_store guile | grep "$(guix build guile-bootstrap)/bin/guile"
$cmd_store boot-9.scm | grep ^guile-bootstrap
fi
+
+# The command below is an error: "no files to search for"...
+guix locate && false
+
+# ... but this one is fine.
+guix locate --clear
diff --git a/tests/guix-shell.sh b/tests/guix-shell.sh
index 2f5fd86809..b2f820bf26 100644
--- a/tests/guix-shell.sh
+++ b/tests/guix-shell.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2021-2023 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -103,6 +103,37 @@ guix shell --bootstrap --pure -D -f "$tmpdir/empty-package.scm" \
guile-bootstrap -- guile --version
rm "$tmpdir/empty-package.scm"
+# Make sure '--development' honors '--system'.
+this_system="$(guile -c '(use-modules (guix utils))
+ (display (%current-system))')"
+other_system="$(guile -c '(use-modules (guix utils))
+ (display (if (string=? "riscv64-linux" (%current-system))
+ "x86_64-linux"
+ "riscv64-linux"))')"
+cat > "$tmpdir/some-package.scm" <<EOF
+(use-modules (guix utils)
+ (guix packages)
+ (gnu packages base))
+
+(define unsupported-dependency
+ (package
+ (inherit grep)
+ (name "unsupported-dependency")
+ (supported-systems '())))
+
+(package
+ (inherit hello)
+ (name "phony-package")
+ (inputs
+ (if (string=? (%current-system) "$this_system")
+ (list unsupported-dependency)
+ '())))
+EOF
+
+guix shell -D -f "$tmpdir/some-package.scm" -n && false
+guix shell -D -f "$tmpdir/some-package.scm" -n -s "$other_system"
+
+
if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
then
# Compute the build environment for the initial GNU Make.
diff --git a/tests/guix-time-machine.sh b/tests/guix-time-machine.sh
index 8b62ef75ea..983f796225 100644
--- a/tests/guix-time-machine.sh
+++ b/tests/guix-time-machine.sh
@@ -1,5 +1,6 @@
# GNU Guix --- Functional package management for GNU
# Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+# Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -20,9 +21,26 @@
# Test the 'guix time-machine' command-line utility.
#
-guix time-machine --version
+if [ -d "$abs_top_srcdir/.git" ] \
+ || guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
+then
+ guix time-machine --version
+else
+ echo "This test requires networking or a local Git checkout; skipping." >&2
+ exit 77
+fi
-# Visiting a commit older than v1.0.0 fails.
-! guix time-machine --commit=v0.15.0
+if [ -d "$abs_top_srcdir/.git" ]
+then
+ # Note: No "file://" prefix because that makes cloning much more expensive
+ # for some reason.
+ EXTRA_OPTIONS="--url=$abs_top_srcdir"
+else
+ EXTRA_OPTIONS=""
+fi
-exit 0
+# Visiting a commit older than v1.0.0 must fail (this test is expensive
+# because it clones the whole repository).
+guix time-machine -q --commit=v0.15.0 $EXTRA_OPTIONS -- describe && false
+
+true
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 8eea818ebd..403f587c41 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -306,8 +306,6 @@ executable cabal
ghc-options: -Wall
")
-;; Fails: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35743
-(test-expect-fail 1)
(test-assert "hackage->guix-package test mixed layout"
(eval-test-with-cabal test-cabal-mixed-layout match-ghc-foo))
@@ -624,4 +622,49 @@ executable cabal
(test-assert "hackage->guix-package test cabal import"
(eval-test-with-cabal test-cabal-import match-ghc-foo-import))
+(define test-cabal-multiple-imports
+ "name: foo
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+common commons
+ build-depends:
+ HTTP >= 4000.2.5 && < 4000.3,
+ mtl >= 2.0 && < 3
+
+common others
+ build-depends:
+ base == 4.16.*,
+ stm-chans == 3.0.*
+
+executable cabal
+ import:
+ commons
+ , others
+")
+
+(define-package-matcher match-ghc-foo-multiple-imports
+ ('package
+ ('name "ghc-foo")
+ ('version "1.0.0")
+ ('source
+ ('origin
+ ('method 'url-fetch)
+ ('uri ('hackage-uri "foo" 'version))
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'haskell-build-system)
+ ('properties '(quote ((upstream-name . "foo"))))
+ ('inputs ('list 'ghc-http 'ghc-stm-chans))
+ ('home-page "http://test.org")
+ ('synopsis (? string?))
+ ('description (? string?))
+ ('license 'license:bsd-3)))
+
+(test-assert "hackage->guix-package test cabal multiple imports"
+ (eval-test-with-cabal test-cabal-multiple-imports match-ghc-foo-multiple-imports))
+
(test-end "hackage")
diff --git a/tests/pack.scm b/tests/pack.scm
index 8fdaed0168..55445ea1e9 100644
--- a/tests/pack.scm
+++ b/tests/pack.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2017-2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,8 +30,9 @@
#:use-module (guix gexp)
#:use-module (guix modules)
#:use-module (guix utils)
+ #:use-module ((guix build utils) #:select (%store-directory))
#:use-module (gnu packages)
- #:use-module ((gnu packages base) #:select (glibc-utf8-locales))
+ #:use-module ((gnu packages base) #:select (libc-utf8-locales-for-target))
#:use-module (gnu packages bootstrap)
#:use-module ((gnu packages package-management) #:select (rpm))
#:use-module ((gnu packages compression) #:select (squashfs-tools))
@@ -197,8 +199,9 @@
;; Make sure non-ASCII file names are properly
;; handled.
(setenv "GUIX_LOCPATH"
- #+(file-append glibc-utf8-locales
- "/lib/locale"))
+ #+(file-append
+ (libc-utf8-locales-for-target)
+ "/lib/locale"))
(setlocale LC_ALL "en_US.utf8")
(mkdir #$output)
@@ -250,6 +253,54 @@
(built-derivations (list check))))
(unless store (test-skip 1))
+ (test-assertm "docker-layered-image + localstatedir"
+ (mlet* %store-monad
+ ((guile (set-guile-for-build (default-guile)))
+ (profile -> (profile
+ (content (packages->manifest (list %bootstrap-guile)))
+ (hooks '())
+ (locales? #f)))
+ (tarball (docker-image "docker-pack" profile
+ #:symlinks '(("/bin/Guile" -> "bin/guile"))
+ #:localstatedir? #t
+ #:max-layers 100))
+ (check (gexp->derivation
+ "check-tarball"
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils)
+ (ice-9 match))
+
+ (define bin
+ (string-append "." #$profile "/bin"))
+
+ (define store
+ (string-append "." #$(%store-directory)))
+
+ (setenv "PATH" (string-append #$%tar-bootstrap "/bin"))
+ (mkdir "base")
+ (with-directory-excursion "base"
+ (invoke "tar" "xvf" #$tarball))
+
+ (match (find-files "base" "layer.tar")
+ ((layers ...)
+ (for-each (lambda (layer)
+ (invoke "tar" "xvf" layer)
+ (invoke "chmod" "--recursive" "u+w" store))
+ layers)))
+
+ (when
+ (and (file-exists? (string-append bin "/guile"))
+ (file-exists? "var/guix/db/db.sqlite")
+ (file-is-directory? "tmp")
+ (string=? (string-append #$%bootstrap-guile "/bin")
+ (readlink bin))
+ (string=? (string-append #$profile "/bin/guile")
+ (readlink "bin/Guile")))
+ (mkdir #$output)))))))
+ (built-derivations (list check))))
+
+ (unless store (test-skip 1))
(test-assertm "squashfs-image + localstatedir"
(mlet* %store-monad
((guile (set-guile-for-build (default-guile)))
diff --git a/tests/profiles.scm b/tests/profiles.scm
index 9c419ada93..ddd6d74f3b 100644
--- a/tests/profiles.scm
+++ b/tests/profiles.scm
@@ -463,7 +463,7 @@
(target -> "arm-linux-gnueabihf")
(grep (package->cross-derivation packages:grep target))
(sed (package->cross-derivation packages:sed target))
- (locales (package->derivation packages:glibc-utf8-locales))
+ (locales (package->derivation (packages:libc-utf8-locales-for-target)))
(drv (profile-derivation manifest
#:hooks '()
#:locales? #t
@@ -482,7 +482,7 @@
(derivation-file-name grep))
(string=? (find-input packages:sed)
(derivation-file-name sed))
- (string=? (find-input packages:glibc-utf8-locales)
+ (string=? (find-input (packages:libc-utf8-locales-for-target))
(derivation-file-name locales))))))
(test-assert "package->manifest-entry defaults to \"out\""
diff --git a/tests/read-print.scm b/tests/read-print.scm
index c8b8eb73fe..c1006a8a68 100644
--- a/tests/read-print.scm
+++ b/tests/read-print.scm
@@ -174,6 +174,11 @@ expressions."
(else #f))")
(test-pretty-print "\
+(parameterize ((a 1)
+ (b 2))
+ (call f g h))")
+
+(test-pretty-print "\
#~(string-append #$coreutils \"/bin/uname\")")
(test-pretty-print "\
diff --git a/tests/store.scm b/tests/store.scm
index 5df28adf0d..45948f4f43 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -105,7 +105,28 @@
"/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile")))
(not (direct-store-path? (%store-prefix)))))
-(test-skip (if %store 0 15))
+(test-skip (if %store 0 18))
+
+(test-equal "substitute-urls, default"
+ (list (getenv "GUIX_BINARY_SUBSTITUTE_URL"))
+ (with-store store
+ (set-build-options store #:use-substitutes? #t)
+ (substitute-urls store)))
+
+(test-equal "substitute-urls, client-specified URLs"
+ '("http://substitutes.example.org"
+ "http://other.example.org")
+ (with-store store
+ (set-build-options store #:use-substitutes? #t
+ #:substitute-urls '("http://substitutes.example.org"
+ "http://other.example.org"))
+ (substitute-urls store)))
+
+(test-equal "substitute-urls, disabled"
+ '()
+ (with-store store
+ (set-build-options store #:use-substitutes? #f)
+ (substitute-urls store)))
(test-equal "profiles/per-user exists and is not writable"
#o755
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 7246ed82d5..33a6d6040a 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -662,28 +662,31 @@ System: mips64el-linux\n")))
(lambda ()
(false-if-exception (delete-file "substitute-retrieved")))))))
-(test-quit "substitute, narinfo is available but nar is missing"
- "failed to find alternative substitute"
- (with-narinfo*
- (string-append %narinfo "Signature: "
- (signature-field
- %narinfo
- #:public-key %wrong-public-key))
- %main-substitute-directory
+(test-equal "substitute, narinfo is available but nar is missing"
+ "not-found\n"
+ (let ((port (open-output-string)))
+ (parameterize ((current-output-port port))
+ (with-narinfo*
+ (string-append %narinfo "Signature: "
+ (signature-field
+ %narinfo
+ #:public-key %wrong-public-key))
+ %main-substitute-directory
- (with-http-server `((200 ,(string-append %narinfo "Signature: "
- (signature-field %narinfo)))
- (404 "Sorry, nar is missing!"))
- (parameterize ((substitute-urls
- (list (%local-url)
- (string-append "file://"
- %main-substitute-directory))))
- (delete-file (string-append %main-substitute-directory
- "/example.nar"))
- (request-substitution (string-append (%store-prefix)
- "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
- "substitute-retrieved")
- (not (file-exists? "substitute-retrieved"))))))
+ (with-http-server `((200 ,(string-append %narinfo "Signature: "
+ (signature-field %narinfo)))
+ (404 "Sorry, nar is missing!"))
+ (parameterize ((substitute-urls
+ (list (%local-url)
+ (string-append "file://"
+ %main-substitute-directory))))
+ (delete-file (string-append %main-substitute-directory
+ "/example.nar"))
+ (request-substitution (string-append (%store-prefix)
+ "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+ "substitute-retrieved")
+ (and (not (file-exists? "substitute-retrieved"))
+ (get-output-string port))))))))
(test-equal "substitute, first narinfo is unsigned and has wrong hash"
"Substitutable data."
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index c9e011f453..340c1147de 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -583,6 +583,14 @@
(test-assert "terminal-rows"
(> (terminal-rows) 0))
+(test-equal "terminal-string-width English"
+ 5
+ (terminal-string-width "hello"))
+
+(test-equal "terminal-string-width Japanese"
+ 6
+ (terminal-string-width "今日は"))
+
(test-assert "openpty"
(let ((head inferior (openpty)))
(and (integer? head) (integer? inferior)
diff --git a/tests/utils.scm b/tests/utils.scm
index 648e91f242..5664165c85 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -329,6 +330,17 @@ skip these tests."
;; However, it isn't 32-bit.
,(format #f "x86_~a-linux-gnu" (expt 2 109)))))
+(test-equal "target-avr?"
+ '(#t #t #t #f #f)
+ (map target-avr?
+ '("avr" "avr-unknown-none"
+ ;; In addition LLVM also uses this form.
+ "avr-unknown-unknown"
+ ;; The AVR32 architecture also was made by Atmel/Microchip but it
+ ;; does not resemble the AVR family, they aren't compatible in any
+ ;; way.
+ "avr32" "avr32-unknown-none")))
+
(test-end)
(false-if-exception (delete-file temp-file))