summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Elsing <david.elsing@posteo.net>2023-12-21 22:01:50 +0000
committerEfraim Flashner <efraim@flashner.co.il>2024-01-09 09:38:38 +0200
commit9f44ff2bb47c964d53905cea17c4bda758cce509 (patch)
treef902e562dc7fedb465d4cc3fec710664921450dd /tests
parent4b0aa65c0a9301a70c798ea76a493f67ef8371f4 (diff)
import: crate: Optionally import dev-dependencies recursively.
If --recursive-dev-dependencies is specified, development dependencies are also included for all recursively imported packages. * doc/guix.texi (Invoking guix import): Mention --recursive-dev-dependencies. * guix/import/crate.scm (crate-recursive-import): Add recursive-dev-dependencies? argument. * guix/scripts/import/crate.scm (show-help, guix-import-crate): Add "--recursive-dev-dependencies". * tests/crate.scm: Test both #f and #t for #:recursive-dev-dependencies? in the 'cargo-recursive-import' test. (test-root-dependencies): Add intermediate-c as dev-dependency. (test-intermediate-c-crate, test-intermediate-c-dependencies): New variables. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Change-Id: Iae89794681155d77f128733120e60f03bc297717
Diffstat (limited to 'tests')
-rw-r--r--tests/crate.scm228
1 files changed, 224 insertions, 4 deletions
diff --git a/tests/crate.scm b/tests/crate.scm
index 5aea5efaf3e..1b9ad88358a 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -4,6 +4,7 @@
4;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org> 4;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
5;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> 5;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
6;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il> 6;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
7;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
7;;; 8;;;
8;;; This file is part of GNU Guix. 9;;; This file is part of GNU Guix.
9;;; 10;;;
@@ -40,10 +41,11 @@
40;; 41;;
41;; root-1.0.0 42;; root-1.0.0
42;; root-1.0.4 43;; root-1.0.4
43;; intermediate-a 1.0.42 44;; intermediate-a 1.0.42
44;; intermeidate-b ^1.0.0 45;; intermediate-b ^1.0.0
45;; leaf-alice ^0.7 46;; leaf-alice ^0.7
46;; leaf-bob ^3 47;; leaf-bob ^3
48;; intermediate-c 1 (dev-dependency)
47;; 49;;
48;; intermediate-a-1.0.40 50;; intermediate-a-1.0.40
49;; intermediate-a-1.0.42 51;; intermediate-a-1.0.42
@@ -55,6 +57,9 @@
55;; intermediate-b-1.2.3 57;; intermediate-b-1.2.3
56;; leaf-bob 3.0.1 58;; leaf-bob 3.0.1
57;; 59;;
60;; intermediate-c-1.0.1
61;; leaf-alice 0.7.5 (dev-dependency)
62;;
58;; leaf-alice-0.7.3 63;; leaf-alice-0.7.3
59;; leaf-alice-0.7.5 64;; leaf-alice-0.7.5
60;; 65;;
@@ -164,6 +169,11 @@
164 \"crate_id\": \"leaf-bob\", 169 \"crate_id\": \"leaf-bob\",
165 \"kind\": \"normal\", 170 \"kind\": \"normal\",
166 \"req\": \"^3\" 171 \"req\": \"^3\"
172 },
173 {
174 \"crate_id\": \"intermediate-c\",
175 \"kind\": \"dev\",
176 \"req\": \"1\"
167 } 177 }
168 ] 178 ]
169}") 179}")
@@ -262,6 +272,40 @@
262 ] 272 ]
263}") 273}")
264 274
275(define test-intermediate-c-crate
276 "{
277 \"crate\": {
278 \"max_version\": \"1.0.1\",
279 \"name\": \"intermediate-c\",
280 \"description\": \"summary\",
281 \"homepage\": \"http://example.com\",
282 \"repository\": \"http://example.com\",
283 \"keywords\": [\"dummy\", \"test\"],
284 \"categories\": [\"test\"],
285 \"actual_versions\": [
286 { \"id\": 234290,
287 \"num\": \"1.0.1\",
288 \"license\": \"MIT OR Apache-2.0\",
289 \"links\": {
290 \"dependencies\": \"/api/v1/crates/intermediate-c/1.0.1/dependencies\"
291 },
292 \"yanked\": false
293 }
294 ]
295 }
296}")
297
298(define test-intermediate-c-dependencies
299 "{
300 \"dependencies\": [
301 {
302 \"crate_id\": \"leaf-alice\",
303 \"kind\": \"dev\",
304 \"req\": \"0.7.5\"
305 }
306 ]
307}")
308
265(define test-leaf-alice-crate 309(define test-leaf-alice-crate
266 "{ 310 "{
267 \"crate\": { 311 \"crate\": {
@@ -430,6 +474,15 @@
430 (open-input-string "empty file\n")) 474 (open-input-string "empty file\n"))
431 ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies" 475 ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies"
432 (open-input-string test-intermediate-b-dependencies)) 476 (open-input-string test-intermediate-b-dependencies))
477 ("https://crates.io/api/v1/crates/intermediate-c"
478 (open-input-string test-intermediate-c-crate))
479 ("https://crates.io/api/v1/crates/intermediate-c/1.0.1/download"
480 (set! test-source-hash
481 (bytevector->nix-base32-string
482 (sha256 (string->bytevector "empty file\n" "utf-8"))))
483 (open-input-string "empty file\n"))
484 ("https://crates.io/api/v1/crates/intermediate-c/1.0.1/dependencies"
485 (open-input-string test-intermediate-c-dependencies))
433 ("https://crates.io/api/v1/crates/leaf-alice" 486 ("https://crates.io/api/v1/crates/leaf-alice"
434 (open-input-string test-leaf-alice-crate)) 487 (open-input-string test-leaf-alice-crate))
435 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download" 488 ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download"
@@ -452,7 +505,27 @@
452 (match (crate-recursive-import "root") 505 (match (crate-recursive-import "root")
453 ;; rust-intermediate-b has no dependency on the rust-leaf-alice 506 ;; rust-intermediate-b has no dependency on the rust-leaf-alice
454 ;; package, so this is a valid ordering 507 ;; package, so this is a valid ordering
455 (((define-public 'rust-leaf-alice-0.7 508 (((define-public 'rust-intermediate-c-1
509 (package
510 (name "rust-intermediate-c")
511 (version "1.0.1")
512 (source
513 (origin
514 (method url-fetch)
515 (uri (crate-uri "intermediate-c" version))
516 (file-name
517 (string-append name "-" version ".tar.gz"))
518 (sha256
519 (base32
520 (? string? hash)))))
521 (build-system cargo-build-system)
522 (arguments
523 ('quasiquote (#:skip-build? #t)))
524 (home-page "http://example.com")
525 (synopsis "summary")
526 (description "summary")
527 (license (list license:expat license:asl2.0))))
528 (define-public 'rust-leaf-alice-0.7
456 (package 529 (package
457 (name "rust-leaf-alice") 530 (name "rust-leaf-alice")
458 (version "0.7.5") 531 (version "0.7.5")
@@ -563,10 +636,157 @@
563 ("rust-leaf-alice" 636 ("rust-leaf-alice"
564 ('unquote 'rust-leaf-alice-0.7)) 637 ('unquote 'rust-leaf-alice-0.7))
565 ("rust-leaf-bob" 638 ("rust-leaf-bob"
639 ('unquote rust-leaf-bob-3)))
640 #:cargo-development-inputs
641 (("rust-intermediate-c"
642 ('unquote rust-intermediate-c-1))))))
643 (home-page "http://example.com")
644 (synopsis "summary")
645 (description "summary")
646 (license (list license:expat license:asl2.0)))))
647 #t)
648 (x
649 (pk 'fail x #f)))
650 (match (crate-recursive-import "root"
651 #:recursive-dev-dependencies? #t)
652 ;; rust-intermediate-b has no dependency on the rust-leaf-alice
653 ;; package, so this is a valid ordering
654 (((define-public 'rust-intermediate-c-1
655 (package
656 (name "rust-intermediate-c")
657 (version "1.0.1")
658 (source
659 (origin
660 (method url-fetch)
661 (uri (crate-uri "intermediate-c" version))
662 (file-name
663 (string-append name "-" version ".tar.gz"))
664 (sha256
665 (base32
666 (? string? hash)))))
667 (build-system cargo-build-system)
668 (arguments
669 ('quasiquote (#:cargo-development-inputs
670 (("rust-leaf-alice"
671 ('unquote rust-leaf-alice-0.7))))))
672 (home-page "http://example.com")
673 (synopsis "summary")
674 (description "summary")
675 (license (list license:expat license:asl2.0))))
676 (define-public 'rust-leaf-alice-0.7
677 (package
678 (name "rust-leaf-alice")
679 (version "0.7.5")
680 (source
681 (origin
682 (method url-fetch)
683 (uri (crate-uri "leaf-alice" version))
684 (file-name
685 (string-append name "-" version ".tar.gz"))
686 (sha256
687 (base32
688 (? string? hash)))))
689 (build-system cargo-build-system)
690 (home-page "http://example.com")
691 (synopsis "summary")
692 (description "summary")
693 (license (list license:expat license:asl2.0))))
694 (define-public 'rust-leaf-bob-3
695 (package
696 (name "rust-leaf-bob")
697 (version "3.0.1")
698 (source
699 (origin
700 (method url-fetch)
701 (uri (crate-uri "leaf-bob" version))
702 (file-name
703 (string-append name "-" version ".tar.gz"))
704 (sha256
705 (base32
706 (? string? hash)))))
707 (build-system cargo-build-system)
708 (home-page "http://example.com")
709 (synopsis "summary")
710 (description "summary")
711 (license (list license:expat license:asl2.0))))
712 (define-public 'rust-intermediate-b-1
713 (package
714 (name "rust-intermediate-b")
715 (version "1.2.3")
716 (source
717 (origin
718 (method url-fetch)
719 (uri (crate-uri "intermediate-b" version))
720 (file-name
721 (string-append name "-" version ".tar.gz"))
722 (sha256
723 (base32
724 (? string? hash)))))
725 (build-system cargo-build-system)
726 (arguments
727 ('quasiquote (#:cargo-inputs
728 (("rust-leaf-bob"
729 ('unquote rust-leaf-bob-3))))))
730 (home-page "http://example.com")
731 (synopsis "summary")
732 (description "summary")
733 (license (list license:expat license:asl2.0))))
734 (define-public 'rust-intermediate-a-1
735 (package
736 (name "rust-intermediate-a")
737 (version "1.0.42")
738 (source
739 (origin
740 (method url-fetch)
741 (uri (crate-uri "intermediate-a" version))
742 (file-name
743 (string-append name "-" version ".tar.gz"))
744 (sha256
745 (base32
746 (? string? hash)))))
747 (build-system cargo-build-system)
748 (arguments
749 ('quasiquote (#:cargo-inputs
750 (("rust-intermediate-b"
751 ('unquote rust-intermediate-b-1))
752 ("rust-leaf-alice"
753 ('unquote 'rust-leaf-alice-0.7))
754 ("rust-leaf-bob"
566 ('unquote rust-leaf-bob-3)))))) 755 ('unquote rust-leaf-bob-3))))))
567 (home-page "http://example.com") 756 (home-page "http://example.com")
568 (synopsis "summary") 757 (synopsis "summary")
569 (description "summary") 758 (description "summary")
759 (license (list license:expat license:asl2.0))))
760 (define-public 'rust-root-1
761 (package
762 (name "rust-root")
763 (version "1.0.4")
764 (source
765 (origin
766 (method url-fetch)
767 (uri (crate-uri "root" version))
768 (file-name
769 (string-append name "-" version ".tar.gz"))
770 (sha256
771 (base32
772 (? string? hash)))))
773 (build-system cargo-build-system)
774 (arguments
775 ('quasiquote (#:cargo-inputs
776 (("rust-intermediate-a"
777 ('unquote rust-intermediate-a-1))
778 ("rust-intermediate-b"
779 ('unquote rust-intermediate-b-1))
780 ("rust-leaf-alice"
781 ('unquote 'rust-leaf-alice-0.7))
782 ("rust-leaf-bob"
783 ('unquote rust-leaf-bob-3)))
784 #:cargo-development-inputs
785 (("rust-intermediate-c"
786 ('unquote rust-intermediate-c-1))))))
787 (home-page "http://example.com")
788 (synopsis "summary")
789 (description "summary")
570 (license (list license:expat license:asl2.0))))) 790 (license (list license:expat license:asl2.0)))))
571 #t) 791 #t)
572 (x 792 (x