summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/composer.scm88
-rw-r--r--tests/go.scm6
-rw-r--r--tests/guix-shell.sh33
-rw-r--r--tests/hackage.scm47
-rw-r--r--tests/store.scm25
-rw-r--r--tests/substitute.scm47
-rw-r--r--tests/utils.scm12
7 files changed, 228 insertions, 30 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 <[email protected]>
+;;; Copyright © 2023 Nicolas Graves <[email protected]>
+;;;
+;;; 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/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 Fran�ois Joulaud <[email protected]>
-;;; Copyright � 2021 Sarah Morgensen <[email protected]>
+;;; Copyright © 2021 François Joulaud <[email protected]>
+;;; Copyright © 2021 Sarah Morgensen <[email protected]>
;;;
;;; 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-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 <[email protected]>
+# Copyright © 2021-2023 Ludovic Courtès <[email protected]>
#
# 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/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/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 <[email protected]>
+;;; Copyright © 2012-2021, 2023 Ludovic Courtès <[email protected]>
;;;
;;; 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
-
- (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"))))))
+(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")
+ (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/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 <[email protected]>
;;; Copyright © 2021 Simon Tournier <[email protected]>
;;; Copyright © 2021 Maxime Devos <[email protected]>
+;;; Copyright © 2023 Foundation Devices, Inc. <[email protected]>
;;;
;;; 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))