epiphany w/ gtk4 and webkitgtk 2.38
[jackhill/guix/guix.git] / tests / crate.scm
CommitLineData
3e0c0365
DC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 David Thompson <davet@gnu.org>
3;;; Copyright © 2016 David Craven <david@craven.ch>
61d4f9e8 4;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
269c1db4 5;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
3e0c0365
DC
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (test-crate)
23 #:use-module (guix import crate)
24 #:use-module (guix base32)
25 #:use-module (guix build-system cargo)
ca719424 26 #:use-module (gcrypt hash)
3e0c0365 27 #:use-module (guix tests)
054e308f 28 #:use-module (gnu packages)
3e0c0365
DC
29 #:use-module (ice-9 iconv)
30 #:use-module (ice-9 match)
31 #:use-module (srfi srfi-64))
32
269c1db4
MB
33
34;; crate versions and dependencies used here
35;; foo-0.8.1
36;; foo-1.0.0
37;; foo-1.0.3
38;; leaf-alice 0.7.5
39;;
40;; root-1.0.0
41;; root-1.0.4
42;; intermediate-a 1.0.42
43;; intermeidate-b ^1.0.0
44;; leaf-alice ^0.7
45;; leaf-bob ^3
46;;
47;; intermediate-a-1.0.40
48;; intermediate-a-1.0.42
49;; intermediate-a-1.1.0-alpha.1
50;; intermediate-a 1.2.3
51;; leaf-alice 0.7.5
52;; leaf-bob ^3
53;;
54;; intermediate-b-1.2.3
55;; leaf-bob 3.0.1
56;;
57;; leaf-alice-0.7.3
58;; leaf-alice-0.7.5
59;;
60;; leaf-bob-3.0.1
61
62
4982de4c 63(define test-foo-crate
3e0c0365
DC
64 "{
65 \"crate\": {
269c1db4 66 \"max_version\": \"1.0.3\",
3e0c0365 67 \"name\": \"foo\",
3e0c0365
DC
68 \"description\": \"summary\",
69 \"homepage\": \"http://example.com\",
f53a5514 70 \"repository\": \"http://example.com\",
269c1db4
MB
71 \"keywords\": [\"dummy\", \"test\"],
72 \"categories\": [\"test\"],
2791870d 73 \"actual_versions\": [
269c1db4
MB
74 { \"id\": 234210,
75 \"num\": \"0.8.1\",
76 \"license\": \"MIT OR Apache-2.0\",
77 \"links\": {
78 \"dependencies\": \"/api/v1/crates/foo/0.8.1/dependencies\"
79 }
80 },
81 { \"id\": 234212,
2791870d 82 \"num\": \"1.0.0\",
191668bc 83 \"license\": \"MIT OR Apache-2.0\",
2791870d
LC
84 \"links\": {
85 \"dependencies\": \"/api/v1/crates/foo/1.0.0/dependencies\"
86 }
269c1db4
MB
87 },
88 { \"id\": 234214,
89 \"num\": \"1.0.3\",
90 \"license\": \"MIT OR Apache-2.0\",
91 \"links\": {
92 \"dependencies\": \"/api/v1/crates/foo/1.0.3/dependencies\"
93 }
2791870d
LC
94 }
95 ]
3e0c0365
DC
96 }
97}")
98
4982de4c 99(define test-foo-dependencies
3e0c0365
DC
100 "{
101 \"dependencies\": [
102 {
269c1db4
MB
103 \"crate_id\": \"leaf-alice\",
104 \"kind\": \"normal\",
105 \"req\": \"0.7.5\"
3e0c0365
DC
106 }
107 ]
108}")
109
4982de4c
BL
110(define test-root-crate
111 "{
112 \"crate\": {
269c1db4 113 \"max_version\": \"1.0.4\",
4982de4c
BL
114 \"name\": \"root\",
115 \"description\": \"summary\",
116 \"homepage\": \"http://example.com\",
117 \"repository\": \"http://example.com\",
269c1db4
MB
118 \"keywords\": [\"dummy\", \"test\"],
119 \"categories\": [\"test\"],
4982de4c 120 \"actual_versions\": [
269c1db4 121 { \"id\": 234240,
4982de4c
BL
122 \"num\": \"1.0.0\",
123 \"license\": \"MIT OR Apache-2.0\",
124 \"links\": {
125 \"dependencies\": \"/api/v1/crates/root/1.0.0/dependencies\"
126 }
269c1db4
MB
127 },
128 { \"id\": 234242,
129 \"num\": \"1.0.4\",
130 \"license\": \"MIT OR Apache-2.0\",
131 \"links\": {
132 \"dependencies\": \"/api/v1/crates/root/1.0.4/dependencies\"
133 }
4982de4c
BL
134 }
135 ]
136 }
137}")
138
139(define test-root-dependencies
140 "{
141 \"dependencies\": [
142 {
269c1db4
MB
143 \"crate_id\": \"intermediate-a\",
144 \"kind\": \"normal\",
145 \"req\": \"1.0.42\"
4982de4c
BL
146 },
147 {
269c1db4
MB
148 \"crate_id\": \"intermediate-b\",
149 \"kind\": \"normal\",
150 \"req\": \"^1.0.0\"
23862011 151 },
4982de4c
BL
152 {
153 \"crate_id\": \"leaf-alice\",
269c1db4
MB
154 \"kind\": \"normal\",
155 \"req\": \"^0.7\"
4982de4c
BL
156 },
157 {
158 \"crate_id\": \"leaf-bob\",
269c1db4
MB
159 \"kind\": \"normal\",
160 \"req\": \"^3\"
5dfe02c6 161 }
4982de4c
BL
162 ]
163}")
164
269c1db4 165(define test-intermediate-a-crate
4982de4c
BL
166 "{
167 \"crate\": {
269c1db4
MB
168 \"max_version\": \"1.1.0-alpha.1\",
169 \"name\": \"intermediate-a\",
4982de4c
BL
170 \"description\": \"summary\",
171 \"homepage\": \"http://example.com\",
172 \"repository\": \"http://example.com\",
269c1db4
MB
173 \"keywords\": [\"dummy\", \"test\"],
174 \"categories\": [\"test\"],
4982de4c 175 \"actual_versions\": [
269c1db4
MB
176 { \"id\": 234251,
177 \"num\": \"1.0.40\",
178 \"license\": \"MIT OR Apache-2.0\",
179 \"links\": {
180 \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.40/dependencies\"
181 }
182 },
183 { \"id\": 234250,
184 \"num\": \"1.0.42\",
185 \"license\": \"MIT OR Apache-2.0\",
186 \"links\": {
187 \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.42/dependencies\"
188 }
189 },
190 { \"id\": 234252,
191 \"num\": \"1.1.0-alpha.1\",
4982de4c
BL
192 \"license\": \"MIT OR Apache-2.0\",
193 \"links\": {
269c1db4 194 \"dependencies\": \"/api/v1/crates/intermediate-a/1.1.0-alpha.1/dependencies\"
4982de4c
BL
195 }
196 }
197 ]
198 }
199}")
200
269c1db4 201(define test-intermediate-a-dependencies
4982de4c
BL
202 "{
203 \"dependencies\": [
204 {
269c1db4
MB
205 \"crate_id\": \"intermediate-b\",
206 \"kind\": \"normal\",
207 \"req\": \"1.2.3\"
4982de4c
BL
208 },
209 {
210 \"crate_id\": \"leaf-alice\",
269c1db4
MB
211 \"kind\": \"normal\",
212 \"req\": \"0.7.5\"
4982de4c
BL
213 },
214 {
215 \"crate_id\": \"leaf-bob\",
269c1db4
MB
216 \"kind\": \"normal\",
217 \"req\": \"^3\"
4982de4c
BL
218 }
219 ]
220}")
221
269c1db4 222(define test-intermediate-b-crate
4982de4c
BL
223 "{
224 \"crate\": {
269c1db4
MB
225 \"max_version\": \"1.2.3\",
226 \"name\": \"intermediate-b\",
4982de4c
BL
227 \"description\": \"summary\",
228 \"homepage\": \"http://example.com\",
229 \"repository\": \"http://example.com\",
269c1db4
MB
230 \"keywords\": [\"dummy\", \"test\"],
231 \"categories\": [\"test\"],
4982de4c 232 \"actual_versions\": [
269c1db4
MB
233 { \"id\": 234260,
234 \"num\": \"1.2.3\",
4982de4c
BL
235 \"license\": \"MIT OR Apache-2.0\",
236 \"links\": {
269c1db4 237 \"dependencies\": \"/api/v1/crates/intermediate-b/1.2.3/dependencies\"
4982de4c
BL
238 }
239 }
240 ]
241 }
242}")
243
269c1db4 244(define test-intermediate-b-dependencies
4982de4c
BL
245 "{
246 \"dependencies\": [
247 {
248 \"crate_id\": \"leaf-bob\",
269c1db4
MB
249 \"kind\": \"normal\",
250 \"req\": \"3.0.1\"
5dfe02c6 251 }
4982de4c
BL
252 ]
253}")
254
255(define test-leaf-alice-crate
256 "{
257 \"crate\": {
269c1db4 258 \"max_version\": \"0.7.5\",
4982de4c
BL
259 \"name\": \"leaf-alice\",
260 \"description\": \"summary\",
261 \"homepage\": \"http://example.com\",
262 \"repository\": \"http://example.com\",
269c1db4
MB
263 \"keywords\": [\"dummy\", \"test\"],
264 \"categories\": [\"test\"],
4982de4c 265 \"actual_versions\": [
269c1db4
MB
266 { \"id\": 234270,
267 \"num\": \"0.7.3\",
4982de4c
BL
268 \"license\": \"MIT OR Apache-2.0\",
269 \"links\": {
269c1db4
MB
270 \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.3/dependencies\"
271 }
272 },
273 { \"id\": 234272,
274 \"num\": \"0.7.5\",
275 \"license\": \"MIT OR Apache-2.0\",
276 \"links\": {
277 \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.5/dependencies\"
4982de4c
BL
278 }
279 }
280 ]
281 }
282}")
283
284(define test-leaf-alice-dependencies
285 "{
286 \"dependencies\": []
287}")
288
289(define test-leaf-bob-crate
290 "{
291 \"crate\": {
269c1db4 292 \"max_version\": \"3.0.1\",
4982de4c
BL
293 \"name\": \"leaf-bob\",
294 \"description\": \"summary\",
295 \"homepage\": \"http://example.com\",
296 \"repository\": \"http://example.com\",
269c1db4 297 \"keywords\": [\"dummy\", \"test\"],
4982de4c
BL
298 \"categories\": [\"test\"]
299 \"actual_versions\": [
269c1db4
MB
300 { \"id\": 234280,
301 \"num\": \"3.0.1\",
4982de4c
BL
302 \"license\": \"MIT OR Apache-2.0\",
303 \"links\": {
269c1db4 304 \"dependencies\": \"/api/v1/crates/leaf-bob/3.0.1/dependencies\"
4982de4c
BL
305 }
306 }
307 ]
308 }
309}")
310
311(define test-leaf-bob-dependencies
312 "{
313 \"dependencies\": []
314}")
315
054e308f 316
3e0c0365
DC
317(define test-source-hash
318 "")
319
e3065ec1
LC
320(define have-guile-semver?
321 (false-if-exception (resolve-interface '(semver))))
322
5dfe02c6 323\f
3e0c0365
DC
324(test-begin "crate")
325
326(test-equal "guix-package->crate-name"
327 "rustc-serialize"
328 (guix-package->crate-name
329 (dummy-package
330 "rust-rustc-serialize"
331 (source (dummy-origin
e3065ec1 332 (uri (crate-uri "rustc-serialize" "1.0")))))))
3e0c0365 333
e3065ec1 334(unless have-guile-semver? (test-skip 1))
3e0c0365
DC
335(test-assert "crate->guix-package"
336 ;; Replace network resources with sample data.
337 (mock ((guix http-client) http-fetch
ce8963c5 338 (lambda (url . rest)
3e0c0365
DC
339 (match url
340 ("https://crates.io/api/v1/crates/foo"
4982de4c 341 (open-input-string test-foo-crate))
269c1db4 342 ("https://crates.io/api/v1/crates/foo/1.0.3/download"
3e0c0365 343 (set! test-source-hash
269c1db4
MB
344 (bytevector->nix-base32-string
345 (sha256 (string->bytevector "empty file\n" "utf-8"))))
3e0c0365 346 (open-input-string "empty file\n"))
269c1db4 347 ("https://crates.io/api/v1/crates/foo/1.0.3/dependencies"
4982de4c 348 (open-input-string test-foo-dependencies))
269c1db4
MB
349 ("https://crates.io/api/v1/crates/leaf-alice"
350 (open-input-string test-leaf-alice-crate))
351 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download"
352 (set! test-source-hash
353 (bytevector->nix-base32-string
354 (sha256 (string->bytevector "empty file\n" "utf-8"))))
355 (open-input-string "empty file\n"))
356 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies"
357 (open-input-string test-leaf-alice-dependencies))
3e0c0365 358 (_ (error "Unexpected URL: " url)))))
269c1db4
MB
359
360 (match (crate->guix-package "foo")
45584061 361 ((define-public 'rust-foo-1
269c1db4
MB
362 (package (name "rust-foo")
363 (version "1.0.3")
364 (source
365 (origin
366 (method url-fetch)
367 (uri (crate-uri "foo" 'version))
368 (file-name (string-append name "-" version ".tar.gz"))
369 (sha256
370 (base32
371 (? string? hash)))))
372 (build-system 'cargo-build-system)
373 (arguments
374 ('quasiquote
375 (#:skip-build? #t
376 #:cargo-inputs
45584061 377 (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
269c1db4
MB
378 (home-page "http://example.com")
379 (synopsis "summary")
380 (description "summary")
381 (license (list license:expat license:asl2.0))))
382
383 (string=? test-source-hash hash))
384 (x
385 (pk 'fail x #f)))))
3e0c0365 386
e3065ec1 387(unless have-guile-semver? (test-skip 1))
4982de4c
BL
388(test-assert "cargo-recursive-import"
389 ;; Replace network resources with sample data.
390 (mock ((guix http-client) http-fetch
391 (lambda (url . rest)
392 (match url
393 ("https://crates.io/api/v1/crates/root"
394 (open-input-string test-root-crate))
269c1db4 395 ("https://crates.io/api/v1/crates/root/1.0.4/download"
4982de4c
BL
396 (set! test-source-hash
397 (bytevector->nix-base32-string
398 (sha256 (string->bytevector "empty file\n" "utf-8"))))
399 (open-input-string "empty file\n"))
269c1db4 400 ("https://crates.io/api/v1/crates/root/1.0.4/dependencies"
4982de4c 401 (open-input-string test-root-dependencies))
269c1db4
MB
402 ("https://crates.io/api/v1/crates/intermediate-a"
403 (open-input-string test-intermediate-a-crate))
404 ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/download"
4982de4c
BL
405 (set! test-source-hash
406 (bytevector->nix-base32-string
407 (sha256 (string->bytevector "empty file\n" "utf-8"))))
408 (open-input-string "empty file\n"))
269c1db4
MB
409 ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/dependencies"
410 (open-input-string test-intermediate-a-dependencies))
411 ("https://crates.io/api/v1/crates/intermediate-b"
412 (open-input-string test-intermediate-b-crate))
413 ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/download"
4982de4c
BL
414 (set! test-source-hash
415 (bytevector->nix-base32-string
416 (sha256 (string->bytevector "empty file\n" "utf-8"))))
417 (open-input-string "empty file\n"))
269c1db4
MB
418 ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies"
419 (open-input-string test-intermediate-b-dependencies))
4982de4c
BL
420 ("https://crates.io/api/v1/crates/leaf-alice"
421 (open-input-string test-leaf-alice-crate))
269c1db4 422 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download"
4982de4c
BL
423 (set! test-source-hash
424 (bytevector->nix-base32-string
425 (sha256 (string->bytevector "empty file\n" "utf-8"))))
426 (open-input-string "empty file\n"))
269c1db4 427 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies"
4982de4c
BL
428 (open-input-string test-leaf-alice-dependencies))
429 ("https://crates.io/api/v1/crates/leaf-bob"
430 (open-input-string test-leaf-bob-crate))
269c1db4 431 ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/download"
4982de4c
BL
432 (set! test-source-hash
433 (bytevector->nix-base32-string
434 (sha256 (string->bytevector "empty file\n" "utf-8"))))
435 (open-input-string "empty file\n"))
269c1db4 436 ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/dependencies"
4982de4c
BL
437 (open-input-string test-leaf-bob-dependencies))
438 (_ (error "Unexpected URL: " url)))))
439 (match (crate-recursive-import "root")
269c1db4
MB
440 ;; rust-intermediate-b has no dependency on the rust-leaf-alice
441 ;; package, so this is a valid ordering
9a48e35b 442 (((define-public 'rust-leaf-alice-0.7
269c1db4
MB
443 (package
444 (name "rust-leaf-alice")
445 (version "0.7.5")
446 (source
447 (origin
448 (method url-fetch)
449 (uri (crate-uri "leaf-alice" version))
450 (file-name
451 (string-append name "-" version ".tar.gz"))
452 (sha256
453 (base32
454 (? string? hash)))))
455 (build-system cargo-build-system)
456 (arguments ('quasiquote (#:skip-build? #t)))
457 (home-page "http://example.com")
458 (synopsis "summary")
459 (description "summary")
460 (license (list license:expat license:asl2.0))))
45584061 461 (define-public 'rust-leaf-bob-3
269c1db4
MB
462 (package
463 (name "rust-leaf-bob")
464 (version "3.0.1")
465 (source
466 (origin
467 (method url-fetch)
468 (uri (crate-uri "leaf-bob" version))
469 (file-name
470 (string-append name "-" version ".tar.gz"))
471 (sha256
472 (base32
473 (? string? hash)))))
474 (build-system cargo-build-system)
475 (arguments ('quasiquote (#:skip-build? #t)))
476 (home-page "http://example.com")
477 (synopsis "summary")
478 (description "summary")
479 (license (list license:expat license:asl2.0))))
45584061 480 (define-public 'rust-intermediate-b-1
269c1db4
MB
481 (package
482 (name "rust-intermediate-b")
483 (version "1.2.3")
484 (source
485 (origin
486 (method url-fetch)
487 (uri (crate-uri "intermediate-b" version))
488 (file-name
489 (string-append name "-" version ".tar.gz"))
490 (sha256
491 (base32
492 (? string? hash)))))
493 (build-system cargo-build-system)
494 (arguments
495 ('quasiquote (#:skip-build? #t
496 #:cargo-inputs
497 (("rust-leaf-bob"
45584061 498 ('unquote rust-leaf-bob-3))))))
269c1db4
MB
499 (home-page "http://example.com")
500 (synopsis "summary")
501 (description "summary")
502 (license (list license:expat license:asl2.0))))
45584061 503 (define-public 'rust-intermediate-a-1
269c1db4
MB
504 (package
505 (name "rust-intermediate-a")
506 (version "1.0.42")
507 (source
508 (origin
509 (method url-fetch)
510 (uri (crate-uri "intermediate-a" version))
511 (file-name
512 (string-append name "-" version ".tar.gz"))
513 (sha256
514 (base32
515 (? string? hash)))))
516 (build-system cargo-build-system)
517 (arguments
518 ('quasiquote (#:skip-build? #t
519 #:cargo-inputs
520 (("rust-intermediate-b"
45584061 521 ('unquote rust-intermediate-b-1))
269c1db4 522 ("rust-leaf-alice"
9a48e35b 523 ('unquote 'rust-leaf-alice-0.7))
269c1db4 524 ("rust-leaf-bob"
45584061 525 ('unquote rust-leaf-bob-3))))))
269c1db4
MB
526 (home-page "http://example.com")
527 (synopsis "summary")
528 (description "summary")
529 (license (list license:expat license:asl2.0))))
45584061 530 (define-public 'rust-root-1
269c1db4
MB
531 (package
532 (name "rust-root")
533 (version "1.0.4")
534 (source
535 (origin
536 (method url-fetch)
537 (uri (crate-uri "root" version))
538 (file-name
539 (string-append name "-" version ".tar.gz"))
540 (sha256
541 (base32
542 (? string? hash)))))
543 (build-system cargo-build-system)
544 (arguments
50fbb3f0 545 ('quasiquote (#:cargo-inputs
269c1db4 546 (("rust-intermediate-a"
45584061 547 ('unquote rust-intermediate-a-1))
269c1db4 548 ("rust-intermediate-b"
45584061 549 ('unquote rust-intermediate-b-1))
269c1db4 550 ("rust-leaf-alice"
9a48e35b 551 ('unquote 'rust-leaf-alice-0.7))
269c1db4 552 ("rust-leaf-bob"
45584061 553 ('unquote rust-leaf-bob-3))))))
269c1db4
MB
554 (home-page "http://example.com")
555 (synopsis "summary")
556 (description "summary")
557 (license (list license:expat license:asl2.0)))))
4982de4c
BL
558 #t)
559 (x
560 (pk 'fail x #f)))))
561
263a267b
BW
562(test-equal "licenses: MIT OR Apache-2.0"
563 '(license:expat license:asl2.0)
564 (string->license "MIT OR Apache-2.0"))
565
566(test-equal "licenses: Apache-2.0 / MIT"
567 '(license:asl2.0 license:expat)
568 (string->license "Apache-2.0 / MIT"))
569
570(test-equal "licenses: Apache-2.0 WITH LLVM-exception"
571 '(license:asl2.0 unknown-license!)
572 (string->license "Apache-2.0 WITH LLVM-exception"))
573
574(test-equal "licenses: MIT/Apache-2.0 AND BSD-2-Clause"
61d4f9e8 575 '(license:expat license:asl2.0 license:bsd-2)
263a267b
BW
576 (string->license "MIT/Apache-2.0 AND BSD-2-Clause"))
577
578(test-equal "licenses: MIT/Apache-2.0"
579 '(license:expat license:asl2.0)
580 (string->license "MIT/Apache-2.0"))
581
054e308f
HG
582
583\f
584(define test-doctool-crate
585 "{
586 \"crate\": {
587 \"max_version\": \"2.2.2\",
588 \"name\": \"leaf-bob\",
589 \"description\": \"summary\",
590 \"homepage\": \"http://example.com\",
591 \"repository\": \"http://example.com\",
592 \"keywords\": [\"dummy\", \"test\"],
593 \"categories\": [\"test\"]
594 \"actual_versions\": [
595 { \"id\": 234280,
596 \"num\": \"2.2.2\",
597 \"license\": \"MIT OR Apache-2.0\",
598 \"links\": {
599 \"dependencies\": \"/api/v1/crates/doctool/2.2.2/dependencies\"
600 }
601 }
602 ]
603 }
604}")
605
606;; FIXME: This test depends on some existing packages
607(define test-doctool-dependencies
608 "{
609 \"dependencies\": [
610 {
611 \"crate_id\": \"docopt\",
612 \"kind\": \"normal\",
613 \"req\": \"^0.8.1\"
614 }
615 ]
616}")
617
618
619(test-assert "self-test: rust-docopt 0.8.x is gone, please adjust the test case"
620 (not (null? (find-packages-by-name "rust-docopt" "0.8"))))
621
e3065ec1 622(unless have-guile-semver? (test-skip 1))
054e308f
HG
623(test-assert "cargo-recursive-import-hoors-existing-packages"
624 (mock ((guix http-client) http-fetch
625 (lambda (url . rest)
626 (match url
627 ("https://crates.io/api/v1/crates/doctool"
628 (open-input-string test-doctool-crate))
629 ("https://crates.io/api/v1/crates/doctool/2.2.2/download"
630 (set! test-source-hash
631 (bytevector->nix-base32-string
632 (sha256 (string->bytevector "empty file\n" "utf-8"))))
633 (open-input-string "empty file\n"))
634 ("https://crates.io/api/v1/crates/doctool/2.2.2/dependencies"
635 (open-input-string test-doctool-dependencies))
636 (_ (error "Unexpected URL: " url)))))
637 (match (crate-recursive-import "doctool")
638 (((define-public 'rust-doctool-2
639 (package
640 (name "rust-doctool")
641 (version "2.2.2")
642 (source
643 (origin
644 (method url-fetch)
645 (uri (crate-uri "doctool" version))
646 (file-name
647 (string-append name "-" version ".tar.gz"))
648 (sha256
649 (base32
650 (? string? hash)))))
651 (build-system cargo-build-system)
652 (arguments
653 ('quasiquote (#:cargo-inputs
654 (("rust-docopt"
655 ('unquote 'rust-docopt-0.8))))))
656 (home-page "http://example.com")
657 (synopsis "summary")
658 (description "summary")
659 (license (list license:expat license:asl2.0)))))
660 #t)
661 (x
662 (pk 'fail x #f)))))
663
3e0c0365 664(test-end "crate")