[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/08: tests: Allow opam test to run without networking.
From: |
guix-commits |
Subject: |
01/08: tests: Allow opam test to run without networking. |
Date: |
Sat, 18 Sep 2021 13:43:26 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 358ad74f41a59b177c9961abf49753a7ce3f41a0
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Sep 18 18:24:05 2021 +0200
tests: Allow opam test to run without networking.
Fixes a regression introduced in
fc29c80b9635ff490bcc768c774442043cb1e231, where, since
'get-opam-repository' was no longer mocked, the test would try to access
the actual OPAM repository through a call to 'http-fetch/cached'; this
would lead to a test failure when networking is unavailable.
* tests/opam.scm ("opam->guix-package"): Mock 'get-opam-repository'
again.
---
tests/opam.scm | 90 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/tests/opam.scm b/tests/opam.scm
index 1536b74..31b4ea4 100644
--- a/tests/opam.scm
+++ b/tests/opam.scm
@@ -71,50 +71,52 @@ url {
(test-begin "opam")
(test-assert "opam->guix-package"
- (mock ((guix import utils) url-fetch
- (lambda (url file-name)
- (match url
- ("https://example.org/foo-1.0.0.tar.gz"
- (begin
- (mkdir-p "foo-1.0.0")
- (system* "tar" "czvf" file-name "foo-1.0.0/")
- (delete-file-recursively "foo-1.0.0")
- (set! test-source-hash
- (call-with-input-file file-name port-sha256))))
- (_ (error "Unexpected URL: " url)))))
- (let ((my-package (string-append test-repo
- "/packages/foo/foo.1.0.0")))
- (mkdir-p my-package)
- (with-output-to-file (string-append my-package "/opam")
- (lambda _
- (format #t "~a" test-opam-file))))
- (match (opam->guix-package "foo" #:repo (list test-repo))
- (('package
- ('name "ocaml-foo")
- ('version "1.0.0")
- ('source ('origin
- ('method 'url-fetch)
- ('uri "https://example.org/foo-1.0.0.tar.gz")
- ('sha256
- ('base32
- (? string? hash)))))
- ('build-system 'ocaml-build-system)
- ('propagated-inputs
- ('quasiquote
- (("ocaml-zarith" ('unquote 'ocaml-zarith)))))
- ('native-inputs
- ('quasiquote
- (("ocaml-alcotest" ('unquote 'ocaml-alcotest))
- ("ocamlbuild" ('unquote 'ocamlbuild)))))
- ('home-page "https://example.org/")
- ('synopsis "Some example package")
- ('description "This package is just an example.")
- ('license 'license:bsd-3))
- (string=? (bytevector->nix-base32-string
- test-source-hash)
- hash))
- (x
- (pk 'fail x #f)))))
+ (mock ((guix import opam) get-opam-repository
+ (const test-repo))
+ (mock ((guix import utils) url-fetch
+ (lambda (url file-name)
+ (match url
+ ("https://example.org/foo-1.0.0.tar.gz"
+ (begin
+ (mkdir-p "foo-1.0.0")
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ (_ (error "Unexpected URL: " url)))))
+ (let ((my-package (string-append test-repo
+ "/packages/foo/foo.1.0.0")))
+ (mkdir-p my-package)
+ (with-output-to-file (string-append my-package "/opam")
+ (lambda _
+ (format #t "~a" test-opam-file))))
+ (match (opam->guix-package "foo" #:repo (list test-repo))
+ (('package
+ ('name "ocaml-foo")
+ ('version "1.0.0")
+ ('source ('origin
+ ('method 'url-fetch)
+ ('uri "https://example.org/foo-1.0.0.tar.gz")
+ ('sha256
+ ('base32
+ (? string? hash)))))
+ ('build-system 'ocaml-build-system)
+ ('propagated-inputs
+ ('quasiquote
+ (("ocaml-zarith" ('unquote 'ocaml-zarith)))))
+ ('native-inputs
+ ('quasiquote
+ (("ocaml-alcotest" ('unquote 'ocaml-alcotest))
+ ("ocamlbuild" ('unquote 'ocamlbuild)))))
+ ('home-page "https://example.org/")
+ ('synopsis "Some example package")
+ ('description "This package is just an example.")
+ ('license 'license:bsd-3))
+ (string=? (bytevector->nix-base32-string
+ test-source-hash)
+ hash))
+ (x
+ (pk 'fail x #f))))))
;; Test the opam file parser
;; We fold over some test cases. Each case is a pair of the string to parse
and the
- branch master updated (511dc68 -> 808f9ff), guix-commits, 2021/09/18
- 01/08: tests: Allow opam test to run without networking.,
guix-commits <=
- 02/08: tests: git: Don't read from the users global Git config file., guix-commits, 2021/09/18
- 07/08: import: minetest: Delete duplicate dependencies., guix-commits, 2021/09/18
- 03/08: tests: git: Make 'tag' directive non-interactive., guix-commits, 2021/09/18
- 04/08: import: Add 'generic-git' updater., guix-commits, 2021/09/18
- 05/08: channels: 'channel-news-entry-commit' correctly resolves annotated tags., guix-commits, 2021/09/18
- 06/08: tests/minetest: Fix 'test-package*' indenting., guix-commits, 2021/09/18
- 08/08: import: minetest: Strip "v" prefixes from the version number., guix-commits, 2021/09/18