me
/
guix
Archived
1
0
Fork 0

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

This is a followup to a8dccd4bdc, which
broke the test.

* guix/import/opam.scm (get-opam-repository): Prevent inlining.
* tests/opam.scm ("opam->guix-package"): Mock 'get-opam-repository'.
master
Ludovic Courtès 2020-12-08 22:58:37 +01:00
parent bfe4cdf88e
commit 799f066768
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 38 additions and 32 deletions

View File

@ -141,6 +141,9 @@ path to the repository."
(string-append location "/" (substring (symbol->string repo) 4))) (string-append location "/" (substring (symbol->string repo) 4)))
(else location))))) (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) (define (latest-version versions)
"Find the most recent version from a list of versions." "Find the most recent version from a list of versions."
(fold (lambda (a b) (if (version>? a b) a b)) (car versions) versions)) (fold (lambda (a b) (if (version>? a b) a b)) (car versions) versions))

View File

@ -80,38 +80,41 @@ url {
(set! test-source-hash (set! test-source-hash
(call-with-input-file file-name port-sha256)))) (call-with-input-file file-name port-sha256))))
(_ (error "Unexpected URL: " url))))) (_ (error "Unexpected URL: " url)))))
(let ((my-package (string-append test-repo "/packages/foo/foo.1.0.0"))) (mock ((guix import opam) get-opam-repository
(mkdir-p my-package) (const test-repo))
(with-output-to-file (string-append my-package "/opam") (let ((my-package (string-append test-repo
(lambda _ "/packages/foo/foo.1.0.0")))
(format #t "~a" test-opam-file)))) (mkdir-p my-package)
(match (opam->guix-package "foo" #:repo test-repo) (with-output-to-file (string-append my-package "/opam")
(('package (lambda _
('name "ocaml-foo") (format #t "~a" test-opam-file))))
('version "1.0.0") (match (opam->guix-package "foo" #:repo test-repo)
('source ('origin (('package
('method 'url-fetch) ('name "ocaml-foo")
('uri "https://example.org/foo-1.0.0.tar.gz") ('version "1.0.0")
('sha256 ('source ('origin
('base32 ('method 'url-fetch)
(? string? hash))))) ('uri "https://example.org/foo-1.0.0.tar.gz")
('build-system 'ocaml-build-system) ('sha256
('propagated-inputs ('base32
('quasiquote (? string? hash)))))
(("ocaml-zarith" ('unquote 'ocaml-zarith))))) ('build-system 'ocaml-build-system)
('native-inputs ('propagated-inputs
('quasiquote ('quasiquote
(("ocaml-alcotest" ('unquote 'ocaml-alcotest)) (("ocaml-zarith" ('unquote 'ocaml-zarith)))))
("ocamlbuild" ('unquote 'ocamlbuild))))) ('native-inputs
('home-page "https://example.org/") ('quasiquote
('synopsis "Some example package") (("ocaml-alcotest" ('unquote 'ocaml-alcotest))
('description "This package is just an example.") ("ocamlbuild" ('unquote 'ocamlbuild)))))
('license #f)) ('home-page "https://example.org/")
(string=? (bytevector->nix-base32-string ('synopsis "Some example package")
test-source-hash) ('description "This package is just an example.")
hash)) ('license #f))
(x (string=? (bytevector->nix-base32-string
(pk 'fail x #f))))) test-source-hash)
hash))
(x
(pk 'fail x #f))))))
;; Test the opam file parser ;; Test the opam file parser
;; We fold over some test cases. Each case is a pair of the string to parse and the ;; We fold over some test cases. Each case is a pair of the string to parse and the