diff options
| author | Phillip Davis <phdavis1027@gmail.com> | 2026-03-18 17:40:55 -0400 |
|---|---|---|
| committer | Nguyễn Gia Phong <cnx@loang.net> | 2026-05-26 00:08:11 +0900 |
| commit | abbf03a2efb4a8f3863ba5860e25657a557ea743 (patch) | |
| tree | ae314615e45a03cb0c5de9c35d54c3f40a46c36b /tests | |
| parent | 5bad9d084c195c46407d123e8e71a316d743445d (diff) | |
import: gem: Fix null at home-page.
The RubyGems API returns "homepage_uri": null for gems with no homepage.
guile-json parses JSON null as the Guile symbol 'null', which passes
through into the generated package sexp as (home-page null)—an unbound
variable error at evaluation time.
* tests/import/gem.scm (test-no-homepage-json): New fixture.
("gem->guix-package, bald homepage_uri"): New test.
* guix/import/gem.scm (non-empty-string-or-false): New procedure.
(<gem>)[home-page]: Use it.
* guix/import/utils.scm (non-empty-string-or-false):
New exported procedure, moved to here...
* guix/import/gem.scm (non-empty-string-or-false): ...from here...
* guix/import/pypi.scm (non-empty-string-or-false): ...and here.
Change-Id: If8f2ca32834d762c753797067ef87937503ff9f9
Reviewed-by: Carlo Zancanaro <carlo@zancanaro.id.au>
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/import/gem.scm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/import/gem.scm b/tests/import/gem.scm index beee1508756..dfa33d40366 100644 --- a/tests/import/gem.scm +++ b/tests/import/gem.scm | |||
| @@ -112,6 +112,19 @@ | |||
| 112 | \"licenses\": [\"MIT\"] | 112 | \"licenses\": [\"MIT\"] |
| 113 | }") | 113 | }") |
| 114 | 114 | ||
| 115 | (define test-no-homepage-json | ||
| 116 | "{ | ||
| 117 | \"name\": \"no-homepage\", | ||
| 118 | \"version\": \"1.0.0\", | ||
| 119 | \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\", | ||
| 120 | \"info\": \"A gem with no homepage\", | ||
| 121 | \"homepage_uri\": null, | ||
| 122 | \"dependencies\": { | ||
| 123 | \"runtime\": [] | ||
| 124 | }, | ||
| 125 | \"licenses\": [\"MIT\"] | ||
| 126 | }") | ||
| 127 | |||
| 115 | (test-begin "gem") | 128 | (test-begin "gem") |
| 116 | 129 | ||
| 117 | (test-assert "gem->guix-package" | 130 | (test-assert "gem->guix-package" |
| @@ -306,4 +319,31 @@ | |||
| 306 | (list (upstream-source-urls source) | 319 | (list (upstream-source-urls source) |
| 307 | (upstream-source-inputs source))))) | 320 | (upstream-source-inputs source))))) |
| 308 | 321 | ||
| 322 | (test-assert "gem->guix-package, bald homepage_uri" | ||
| 323 | (mock ((guix http-client) http-fetch | ||
| 324 | (lambda (url . rest) | ||
| 325 | (match url | ||
| 326 | ("https://rubygems.org/api/v1/gems/no-homepage.json" | ||
| 327 | (values (open-input-string test-no-homepage-json) | ||
| 328 | (string-length test-no-homepage-json))) | ||
| 329 | (_ (error "Unexpected URL: " url))))) | ||
| 330 | (match (gem->guix-package "no-homepage") | ||
| 331 | (`(package | ||
| 332 | (name "ruby-no-homepage") | ||
| 333 | (version "1.0.0") | ||
| 334 | (source (origin | ||
| 335 | (method url-fetch) | ||
| 336 | (uri (rubygems-uri "no-homepage" version)) | ||
| 337 | (sha256 | ||
| 338 | (base32 | ||
| 339 | "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk")))) | ||
| 340 | (build-system ruby-build-system) | ||
| 341 | (synopsis "A gem with no homepage") | ||
| 342 | (description "This package provides a gem with no homepage.") | ||
| 343 | (home-page #f) | ||
| 344 | (license license:expat)) | ||
| 345 | #t) | ||
| 346 | (x | ||
| 347 | (pk 'fail x #f))))) | ||
| 348 | |||
| 309 | (test-end "gem") | 349 | (test-end "gem") |
