Commit | Line | Data |
---|---|---|
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> | |
72c678af | 4 | ;;; Copyright © 2019, 2020 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 DC |
27 | #:use-module (guix tests) |
28 | #:use-module (ice-9 iconv) | |
29 | #:use-module (ice-9 match) | |
30 | #:use-module (srfi srfi-64)) | |
31 | ||
269c1db4 MB |
32 | |
33 | ;; crate versions and dependencies used here | |
34 | ;; foo-0.8.1 | |
35 | ;; foo-1.0.0 | |
36 | ;; foo-1.0.3 | |
37 | ;; leaf-alice 0.7.5 | |
38 | ;; | |
39 | ;; root-1.0.0 | |
40 | ;; root-1.0.4 | |
41 | ;; intermediate-a 1.0.42 | |
42 | ;; intermeidate-b ^1.0.0 | |
43 | ;; leaf-alice ^0.7 | |
44 | ;; leaf-bob ^3 | |
45 | ;; | |
46 | ;; intermediate-a-1.0.40 | |
47 | ;; intermediate-a-1.0.42 | |
48 | ;; intermediate-a-1.1.0-alpha.1 | |
49 | ;; intermediate-a 1.2.3 | |
50 | ;; leaf-alice 0.7.5 | |
51 | ;; leaf-bob ^3 | |
52 | ;; | |
53 | ;; intermediate-b-1.2.3 | |
54 | ;; leaf-bob 3.0.1 | |
55 | ;; | |
56 | ;; leaf-alice-0.7.3 | |
57 | ;; leaf-alice-0.7.5 | |
58 | ;; | |
59 | ;; leaf-bob-3.0.1 | |
60 | ||
61 | ||
4982de4c | 62 | (define test-foo-crate |
3e0c0365 DC |
63 | "{ |
64 | \"crate\": { | |
269c1db4 | 65 | \"max_version\": \"1.0.3\", |
3e0c0365 | 66 | \"name\": \"foo\", |
3e0c0365 DC |
67 | \"description\": \"summary\", |
68 | \"homepage\": \"http://example.com\", | |
f53a5514 | 69 | \"repository\": \"http://example.com\", |
269c1db4 MB |
70 | \"keywords\": [\"dummy\", \"test\"], |
71 | \"categories\": [\"test\"], | |
2791870d | 72 | \"actual_versions\": [ |
269c1db4 MB |
73 | { \"id\": 234210, |
74 | \"num\": \"0.8.1\", | |
75 | \"license\": \"MIT OR Apache-2.0\", | |
76 | \"links\": { | |
77 | \"dependencies\": \"/api/v1/crates/foo/0.8.1/dependencies\" | |
78 | } | |
79 | }, | |
80 | { \"id\": 234212, | |
2791870d | 81 | \"num\": \"1.0.0\", |
191668bc | 82 | \"license\": \"MIT OR Apache-2.0\", |
2791870d LC |
83 | \"links\": { |
84 | \"dependencies\": \"/api/v1/crates/foo/1.0.0/dependencies\" | |
85 | } | |
269c1db4 MB |
86 | }, |
87 | { \"id\": 234214, | |
88 | \"num\": \"1.0.3\", | |
89 | \"license\": \"MIT OR Apache-2.0\", | |
90 | \"links\": { | |
91 | \"dependencies\": \"/api/v1/crates/foo/1.0.3/dependencies\" | |
92 | } | |
2791870d LC |
93 | } |
94 | ] | |
3e0c0365 DC |
95 | } |
96 | }") | |
97 | ||
4982de4c | 98 | (define test-foo-dependencies |
3e0c0365 DC |
99 | "{ |
100 | \"dependencies\": [ | |
101 | { | |
269c1db4 MB |
102 | \"crate_id\": \"leaf-alice\", |
103 | \"kind\": \"normal\", | |
104 | \"req\": \"0.7.5\" | |
3e0c0365 DC |
105 | } |
106 | ] | |
107 | }") | |
108 | ||
4982de4c BL |
109 | (define test-root-crate |
110 | "{ | |
111 | \"crate\": { | |
269c1db4 | 112 | \"max_version\": \"1.0.4\", |
4982de4c BL |
113 | \"name\": \"root\", |
114 | \"description\": \"summary\", | |
115 | \"homepage\": \"http://example.com\", | |
116 | \"repository\": \"http://example.com\", | |
269c1db4 MB |
117 | \"keywords\": [\"dummy\", \"test\"], |
118 | \"categories\": [\"test\"], | |
4982de4c | 119 | \"actual_versions\": [ |
269c1db4 | 120 | { \"id\": 234240, |
4982de4c BL |
121 | \"num\": \"1.0.0\", |
122 | \"license\": \"MIT OR Apache-2.0\", | |
123 | \"links\": { | |
124 | \"dependencies\": \"/api/v1/crates/root/1.0.0/dependencies\" | |
125 | } | |
269c1db4 MB |
126 | }, |
127 | { \"id\": 234242, | |
128 | \"num\": \"1.0.4\", | |
129 | \"license\": \"MIT OR Apache-2.0\", | |
130 | \"links\": { | |
131 | \"dependencies\": \"/api/v1/crates/root/1.0.4/dependencies\" | |
132 | } | |
4982de4c BL |
133 | } |
134 | ] | |
135 | } | |
136 | }") | |
137 | ||
138 | (define test-root-dependencies | |
139 | "{ | |
140 | \"dependencies\": [ | |
141 | { | |
269c1db4 MB |
142 | \"crate_id\": \"intermediate-a\", |
143 | \"kind\": \"normal\", | |
144 | \"req\": \"1.0.42\" | |
4982de4c BL |
145 | }, |
146 | { | |
269c1db4 MB |
147 | \"crate_id\": \"intermediate-b\", |
148 | \"kind\": \"normal\", | |
149 | \"req\": \"^1.0.0\" | |
4982de4c BL |
150 | } |
151 | { | |
152 | \"crate_id\": \"leaf-alice\", | |
269c1db4 MB |
153 | \"kind\": \"normal\", |
154 | \"req\": \"^0.7\" | |
4982de4c BL |
155 | }, |
156 | { | |
157 | \"crate_id\": \"leaf-bob\", | |
269c1db4 MB |
158 | \"kind\": \"normal\", |
159 | \"req\": \"^3\" | |
5dfe02c6 | 160 | } |
4982de4c BL |
161 | ] |
162 | }") | |
163 | ||
269c1db4 | 164 | (define test-intermediate-a-crate |
4982de4c BL |
165 | "{ |
166 | \"crate\": { | |
269c1db4 MB |
167 | \"max_version\": \"1.1.0-alpha.1\", |
168 | \"name\": \"intermediate-a\", | |
4982de4c BL |
169 | \"description\": \"summary\", |
170 | \"homepage\": \"http://example.com\", | |
171 | \"repository\": \"http://example.com\", | |
269c1db4 MB |
172 | \"keywords\": [\"dummy\", \"test\"], |
173 | \"categories\": [\"test\"], | |
4982de4c | 174 | \"actual_versions\": [ |
269c1db4 MB |
175 | { \"id\": 234251, |
176 | \"num\": \"1.0.40\", | |
177 | \"license\": \"MIT OR Apache-2.0\", | |
178 | \"links\": { | |
179 | \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.40/dependencies\" | |
180 | } | |
181 | }, | |
182 | { \"id\": 234250, | |
183 | \"num\": \"1.0.42\", | |
184 | \"license\": \"MIT OR Apache-2.0\", | |
185 | \"links\": { | |
186 | \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.42/dependencies\" | |
187 | } | |
188 | }, | |
189 | { \"id\": 234252, | |
190 | \"num\": \"1.1.0-alpha.1\", | |
4982de4c BL |
191 | \"license\": \"MIT OR Apache-2.0\", |
192 | \"links\": { | |
269c1db4 | 193 | \"dependencies\": \"/api/v1/crates/intermediate-a/1.1.0-alpha.1/dependencies\" |
4982de4c BL |
194 | } |
195 | } | |
196 | ] | |
197 | } | |
198 | }") | |
199 | ||
269c1db4 | 200 | (define test-intermediate-a-dependencies |
4982de4c BL |
201 | "{ |
202 | \"dependencies\": [ | |
203 | { | |
269c1db4 MB |
204 | \"crate_id\": \"intermediate-b\", |
205 | \"kind\": \"normal\", | |
206 | \"req\": \"1.2.3\" | |
4982de4c BL |
207 | }, |
208 | { | |
209 | \"crate_id\": \"leaf-alice\", | |
269c1db4 MB |
210 | \"kind\": \"normal\", |
211 | \"req\": \"0.7.5\" | |
4982de4c BL |
212 | }, |
213 | { | |
214 | \"crate_id\": \"leaf-bob\", | |
269c1db4 MB |
215 | \"kind\": \"normal\", |
216 | \"req\": \"^3\" | |
4982de4c BL |
217 | } |
218 | ] | |
219 | }") | |
220 | ||
269c1db4 | 221 | (define test-intermediate-b-crate |
4982de4c BL |
222 | "{ |
223 | \"crate\": { | |
269c1db4 MB |
224 | \"max_version\": \"1.2.3\", |
225 | \"name\": \"intermediate-b\", | |
4982de4c BL |
226 | \"description\": \"summary\", |
227 | \"homepage\": \"http://example.com\", | |
228 | \"repository\": \"http://example.com\", | |
269c1db4 MB |
229 | \"keywords\": [\"dummy\", \"test\"], |
230 | \"categories\": [\"test\"], | |
4982de4c | 231 | \"actual_versions\": [ |
269c1db4 MB |
232 | { \"id\": 234260, |
233 | \"num\": \"1.2.3\", | |
4982de4c BL |
234 | \"license\": \"MIT OR Apache-2.0\", |
235 | \"links\": { | |
269c1db4 | 236 | \"dependencies\": \"/api/v1/crates/intermediate-b/1.2.3/dependencies\" |
4982de4c BL |
237 | } |
238 | } | |
239 | ] | |
240 | } | |
241 | }") | |
242 | ||
269c1db4 | 243 | (define test-intermediate-b-dependencies |
4982de4c BL |
244 | "{ |
245 | \"dependencies\": [ | |
246 | { | |
247 | \"crate_id\": \"leaf-bob\", | |
269c1db4 MB |
248 | \"kind\": \"normal\", |
249 | \"req\": \"3.0.1\" | |
5dfe02c6 | 250 | } |
4982de4c BL |
251 | ] |
252 | }") | |
253 | ||
254 | (define test-leaf-alice-crate | |
255 | "{ | |
256 | \"crate\": { | |
269c1db4 | 257 | \"max_version\": \"0.7.5\", |
4982de4c BL |
258 | \"name\": \"leaf-alice\", |
259 | \"description\": \"summary\", | |
260 | \"homepage\": \"http://example.com\", | |
261 | \"repository\": \"http://example.com\", | |
269c1db4 MB |
262 | \"keywords\": [\"dummy\", \"test\"], |
263 | \"categories\": [\"test\"], | |
4982de4c | 264 | \"actual_versions\": [ |
269c1db4 MB |
265 | { \"id\": 234270, |
266 | \"num\": \"0.7.3\", | |
4982de4c BL |
267 | \"license\": \"MIT OR Apache-2.0\", |
268 | \"links\": { | |
269c1db4 MB |
269 | \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.3/dependencies\" |
270 | } | |
271 | }, | |
272 | { \"id\": 234272, | |
273 | \"num\": \"0.7.5\", | |
274 | \"license\": \"MIT OR Apache-2.0\", | |
275 | \"links\": { | |
276 | \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.5/dependencies\" | |
4982de4c BL |
277 | } |
278 | } | |
279 | ] | |
280 | } | |
281 | }") | |
282 | ||
283 | (define test-leaf-alice-dependencies | |
284 | "{ | |
285 | \"dependencies\": [] | |
286 | }") | |
287 | ||
288 | (define test-leaf-bob-crate | |
289 | "{ | |
290 | \"crate\": { | |
269c1db4 | 291 | \"max_version\": \"3.0.1\", |
4982de4c BL |
292 | \"name\": \"leaf-bob\", |
293 | \"description\": \"summary\", | |
294 | \"homepage\": \"http://example.com\", | |
295 | \"repository\": \"http://example.com\", | |
269c1db4 | 296 | \"keywords\": [\"dummy\", \"test\"], |
4982de4c BL |
297 | \"categories\": [\"test\"] |
298 | \"actual_versions\": [ | |
269c1db4 MB |
299 | { \"id\": 234280, |
300 | \"num\": \"3.0.1\", | |
4982de4c BL |
301 | \"license\": \"MIT OR Apache-2.0\", |
302 | \"links\": { | |
269c1db4 | 303 | \"dependencies\": \"/api/v1/crates/leaf-bob/3.0.1/dependencies\" |
4982de4c BL |
304 | } |
305 | } | |
306 | ] | |
307 | } | |
308 | }") | |
309 | ||
310 | (define test-leaf-bob-dependencies | |
311 | "{ | |
312 | \"dependencies\": [] | |
313 | }") | |
314 | ||
3e0c0365 DC |
315 | (define test-source-hash |
316 | "") | |
317 | ||
5dfe02c6 | 318 | \f |
3e0c0365 DC |
319 | (test-begin "crate") |
320 | ||
321 | (test-equal "guix-package->crate-name" | |
322 | "rustc-serialize" | |
323 | (guix-package->crate-name | |
324 | (dummy-package | |
325 | "rust-rustc-serialize" | |
326 | (source (dummy-origin | |
327 | (uri (crate-uri "rustc-serialize" "1.0"))))))) | |
328 | ||
329 | (test-assert "crate->guix-package" | |
330 | ;; Replace network resources with sample data. | |
331 | (mock ((guix http-client) http-fetch | |
ce8963c5 | 332 | (lambda (url . rest) |
3e0c0365 DC |
333 | (match url |
334 | ("https://crates.io/api/v1/crates/foo" | |
4982de4c | 335 | (open-input-string test-foo-crate)) |
269c1db4 | 336 | ("https://crates.io/api/v1/crates/foo/1.0.3/download" |
3e0c0365 | 337 | (set! test-source-hash |
269c1db4 MB |
338 | (bytevector->nix-base32-string |
339 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
3e0c0365 | 340 | (open-input-string "empty file\n")) |
269c1db4 | 341 | ("https://crates.io/api/v1/crates/foo/1.0.3/dependencies" |
4982de4c | 342 | (open-input-string test-foo-dependencies)) |
269c1db4 MB |
343 | ("https://crates.io/api/v1/crates/leaf-alice" |
344 | (open-input-string test-leaf-alice-crate)) | |
345 | ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download" | |
346 | (set! test-source-hash | |
347 | (bytevector->nix-base32-string | |
348 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
349 | (open-input-string "empty file\n")) | |
350 | ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies" | |
351 | (open-input-string test-leaf-alice-dependencies)) | |
3e0c0365 | 352 | (_ (error "Unexpected URL: " url))))) |
269c1db4 MB |
353 | |
354 | (match (crate->guix-package "foo") | |
9a48e35b | 355 | ((define-public 'rust-foo-1.0 |
269c1db4 MB |
356 | (package (name "rust-foo") |
357 | (version "1.0.3") | |
358 | (source | |
359 | (origin | |
360 | (method url-fetch) | |
361 | (uri (crate-uri "foo" 'version)) | |
362 | (file-name (string-append name "-" version ".tar.gz")) | |
363 | (sha256 | |
364 | (base32 | |
365 | (? string? hash))))) | |
366 | (build-system 'cargo-build-system) | |
367 | (arguments | |
368 | ('quasiquote | |
369 | (#:skip-build? #t | |
370 | #:cargo-inputs | |
371 | (("rust-leaf-alice" | |
9a48e35b | 372 | ('unquote 'rust-leaf-alice-0.7)))))) |
269c1db4 MB |
373 | (home-page "http://example.com") |
374 | (synopsis "summary") | |
375 | (description "summary") | |
376 | (license (list license:expat license:asl2.0)))) | |
377 | ||
378 | (string=? test-source-hash hash)) | |
379 | (x | |
380 | (pk 'fail x #f))))) | |
3e0c0365 | 381 | |
4982de4c BL |
382 | (test-assert "cargo-recursive-import" |
383 | ;; Replace network resources with sample data. | |
384 | (mock ((guix http-client) http-fetch | |
385 | (lambda (url . rest) | |
386 | (match url | |
387 | ("https://crates.io/api/v1/crates/root" | |
388 | (open-input-string test-root-crate)) | |
269c1db4 | 389 | ("https://crates.io/api/v1/crates/root/1.0.4/download" |
4982de4c BL |
390 | (set! test-source-hash |
391 | (bytevector->nix-base32-string | |
392 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
393 | (open-input-string "empty file\n")) | |
269c1db4 | 394 | ("https://crates.io/api/v1/crates/root/1.0.4/dependencies" |
4982de4c | 395 | (open-input-string test-root-dependencies)) |
269c1db4 MB |
396 | ("https://crates.io/api/v1/crates/intermediate-a" |
397 | (open-input-string test-intermediate-a-crate)) | |
398 | ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/download" | |
4982de4c BL |
399 | (set! test-source-hash |
400 | (bytevector->nix-base32-string | |
401 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
402 | (open-input-string "empty file\n")) | |
269c1db4 MB |
403 | ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/dependencies" |
404 | (open-input-string test-intermediate-a-dependencies)) | |
405 | ("https://crates.io/api/v1/crates/intermediate-b" | |
406 | (open-input-string test-intermediate-b-crate)) | |
407 | ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/download" | |
4982de4c BL |
408 | (set! test-source-hash |
409 | (bytevector->nix-base32-string | |
410 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
411 | (open-input-string "empty file\n")) | |
269c1db4 MB |
412 | ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies" |
413 | (open-input-string test-intermediate-b-dependencies)) | |
4982de4c BL |
414 | ("https://crates.io/api/v1/crates/leaf-alice" |
415 | (open-input-string test-leaf-alice-crate)) | |
269c1db4 | 416 | ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download" |
4982de4c BL |
417 | (set! test-source-hash |
418 | (bytevector->nix-base32-string | |
419 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
420 | (open-input-string "empty file\n")) | |
269c1db4 | 421 | ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies" |
4982de4c BL |
422 | (open-input-string test-leaf-alice-dependencies)) |
423 | ("https://crates.io/api/v1/crates/leaf-bob" | |
424 | (open-input-string test-leaf-bob-crate)) | |
269c1db4 | 425 | ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/download" |
4982de4c BL |
426 | (set! test-source-hash |
427 | (bytevector->nix-base32-string | |
428 | (sha256 (string->bytevector "empty file\n" "utf-8")))) | |
429 | (open-input-string "empty file\n")) | |
269c1db4 | 430 | ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/dependencies" |
4982de4c BL |
431 | (open-input-string test-leaf-bob-dependencies)) |
432 | (_ (error "Unexpected URL: " url))))) | |
433 | (match (crate-recursive-import "root") | |
269c1db4 MB |
434 | ;; rust-intermediate-b has no dependency on the rust-leaf-alice |
435 | ;; package, so this is a valid ordering | |
9a48e35b | 436 | (((define-public 'rust-leaf-alice-0.7 |
269c1db4 MB |
437 | (package |
438 | (name "rust-leaf-alice") | |
439 | (version "0.7.5") | |
440 | (source | |
441 | (origin | |
442 | (method url-fetch) | |
443 | (uri (crate-uri "leaf-alice" version)) | |
444 | (file-name | |
445 | (string-append name "-" version ".tar.gz")) | |
446 | (sha256 | |
447 | (base32 | |
448 | (? string? hash))))) | |
449 | (build-system cargo-build-system) | |
450 | (arguments ('quasiquote (#:skip-build? #t))) | |
451 | (home-page "http://example.com") | |
452 | (synopsis "summary") | |
453 | (description "summary") | |
454 | (license (list license:expat license:asl2.0)))) | |
9a48e35b | 455 | (define-public 'rust-leaf-bob-3.0 |
269c1db4 MB |
456 | (package |
457 | (name "rust-leaf-bob") | |
458 | (version "3.0.1") | |
459 | (source | |
460 | (origin | |
461 | (method url-fetch) | |
462 | (uri (crate-uri "leaf-bob" version)) | |
463 | (file-name | |
464 | (string-append name "-" version ".tar.gz")) | |
465 | (sha256 | |
466 | (base32 | |
467 | (? string? hash))))) | |
468 | (build-system cargo-build-system) | |
469 | (arguments ('quasiquote (#:skip-build? #t))) | |
470 | (home-page "http://example.com") | |
471 | (synopsis "summary") | |
472 | (description "summary") | |
473 | (license (list license:expat license:asl2.0)))) | |
9a48e35b | 474 | (define-public 'rust-intermediate-b-1.2 |
269c1db4 MB |
475 | (package |
476 | (name "rust-intermediate-b") | |
477 | (version "1.2.3") | |
478 | (source | |
479 | (origin | |
480 | (method url-fetch) | |
481 | (uri (crate-uri "intermediate-b" version)) | |
482 | (file-name | |
483 | (string-append name "-" version ".tar.gz")) | |
484 | (sha256 | |
485 | (base32 | |
486 | (? string? hash))))) | |
487 | (build-system cargo-build-system) | |
488 | (arguments | |
489 | ('quasiquote (#:skip-build? #t | |
490 | #:cargo-inputs | |
491 | (("rust-leaf-bob" | |
9a48e35b | 492 | ('unquote 'rust-leaf-bob-3.0)))))) |
269c1db4 MB |
493 | (home-page "http://example.com") |
494 | (synopsis "summary") | |
495 | (description "summary") | |
496 | (license (list license:expat license:asl2.0)))) | |
9a48e35b | 497 | (define-public 'rust-intermediate-a-1.0 |
269c1db4 MB |
498 | (package |
499 | (name "rust-intermediate-a") | |
500 | (version "1.0.42") | |
501 | (source | |
502 | (origin | |
503 | (method url-fetch) | |
504 | (uri (crate-uri "intermediate-a" version)) | |
505 | (file-name | |
506 | (string-append name "-" version ".tar.gz")) | |
507 | (sha256 | |
508 | (base32 | |
509 | (? string? hash))))) | |
510 | (build-system cargo-build-system) | |
511 | (arguments | |
512 | ('quasiquote (#:skip-build? #t | |
513 | #:cargo-inputs | |
514 | (("rust-intermediate-b" | |
9a48e35b | 515 | ('unquote 'rust-intermediate-b-1.2)) |
269c1db4 | 516 | ("rust-leaf-alice" |
9a48e35b | 517 | ('unquote 'rust-leaf-alice-0.7)) |
269c1db4 | 518 | ("rust-leaf-bob" |
9a48e35b | 519 | ('unquote 'rust-leaf-bob-3.0)))))) |
269c1db4 MB |
520 | (home-page "http://example.com") |
521 | (synopsis "summary") | |
522 | (description "summary") | |
523 | (license (list license:expat license:asl2.0)))) | |
9a48e35b | 524 | (define-public 'rust-root-1.0 |
269c1db4 MB |
525 | (package |
526 | (name "rust-root") | |
527 | (version "1.0.4") | |
528 | (source | |
529 | (origin | |
530 | (method url-fetch) | |
531 | (uri (crate-uri "root" version)) | |
532 | (file-name | |
533 | (string-append name "-" version ".tar.gz")) | |
534 | (sha256 | |
535 | (base32 | |
536 | (? string? hash))))) | |
537 | (build-system cargo-build-system) | |
538 | (arguments | |
50fbb3f0 | 539 | ('quasiquote (#:cargo-inputs |
269c1db4 | 540 | (("rust-intermediate-a" |
9a48e35b | 541 | ('unquote 'rust-intermediate-a-1.0)) |
269c1db4 | 542 | ("rust-intermediate-b" |
9a48e35b | 543 | ('unquote 'rust-intermediate-b-1.2)) |
269c1db4 | 544 | ("rust-leaf-alice" |
9a48e35b | 545 | ('unquote 'rust-leaf-alice-0.7)) |
269c1db4 | 546 | ("rust-leaf-bob" |
9a48e35b | 547 | ('unquote 'rust-leaf-bob-3.0)))))) |
269c1db4 MB |
548 | (home-page "http://example.com") |
549 | (synopsis "summary") | |
550 | (description "summary") | |
551 | (license (list license:expat license:asl2.0))))) | |
4982de4c BL |
552 | #t) |
553 | (x | |
554 | (pk 'fail x #f))))) | |
555 | ||
263a267b BW |
556 | (test-equal "licenses: MIT OR Apache-2.0" |
557 | '(license:expat license:asl2.0) | |
558 | (string->license "MIT OR Apache-2.0")) | |
559 | ||
560 | (test-equal "licenses: Apache-2.0 / MIT" | |
561 | '(license:asl2.0 license:expat) | |
562 | (string->license "Apache-2.0 / MIT")) | |
563 | ||
564 | (test-equal "licenses: Apache-2.0 WITH LLVM-exception" | |
565 | '(license:asl2.0 unknown-license!) | |
566 | (string->license "Apache-2.0 WITH LLVM-exception")) | |
567 | ||
568 | (test-equal "licenses: MIT/Apache-2.0 AND BSD-2-Clause" | |
569 | '(license:expat license:asl2.0 unknown-license!) | |
570 | (string->license "MIT/Apache-2.0 AND BSD-2-Clause")) | |
571 | ||
572 | (test-equal "licenses: MIT/Apache-2.0" | |
573 | '(license:expat license:asl2.0) | |
574 | (string->license "MIT/Apache-2.0")) | |
575 | ||
3e0c0365 | 576 | (test-end "crate") |