guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

09/09: import: opam: Adjust test to latest 'opam->guix-package' changes.


From: guix-commits
Subject: 09/09: import: opam: Adjust test to latest 'opam->guix-package' changes.
Date: Tue, 8 Dec 2020 17:00:15 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 799f066768bacb321ebad84c75b2bbfd269e7cd8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Dec 8 22:58:37 2020 +0100

    import: opam: Adjust test to latest 'opam->guix-package' changes.
    
    This is a followup to a8dccd4bdc1e58219d4ba08fe1649bf0b8325f44, which
    broke the test.
    
    * guix/import/opam.scm (get-opam-repository): Prevent inlining.
    * tests/opam.scm ("opam->guix-package"): Mock 'get-opam-repository'.
---
 guix/import/opam.scm |  3 +++
 tests/opam.scm       | 67 +++++++++++++++++++++++++++-------------------------
 2 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index 54143f8..670973b 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -141,6 +141,9 @@ path to the repository."
          (string-append location "/" (substring (symbol->string repo) 4)))
         (else location)))))
 
+;; Prevent Guile 3 from inlining this procedure so we can mock it in tests.
+(set! get-opam-repository get-opam-repository)
+
 (define (latest-version versions)
   "Find the most recent version from a list of versions."
   (fold (lambda (a b) (if (version>? a b) a b)) (car versions) versions))
diff --git a/tests/opam.scm b/tests/opam.scm
index 8d43e2c..11984b5 100644
--- a/tests/opam.scm
+++ b/tests/opam.scm
@@ -80,38 +80,41 @@ url {
                 (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 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 #f))
-         (string=? (bytevector->nix-base32-string
-                    test-source-hash)
-                   hash))
-        (x
-         (pk 'fail x #f)))))
+        (mock ((guix import opam) get-opam-repository
+               (const test-repo))
+              (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 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 #f))
+                 (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]