summaryrefslogtreecommitdiff
path: root/tests/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-06-27 23:33:48 +0200
committerLudovic Courtès <ludo@gnu.org>2019-06-27 23:33:48 +0200
commit5cc1075a76392666d3d733837f5c6252b1e48002 (patch)
treeaff2a303881a6fe53021a6e78a767958e608719b /tests/derivations.scm
parent9c2563a80b6f1d8fb8677f5314e6180ea9916aa5 (diff)
parentc30d117822a8ca26cd8c06c0a3974955bef68eac (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/derivations.scm')
-rw-r--r--tests/derivations.scm80
1 files changed, 46 insertions, 34 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index b0175d9fc5b..98018a45e3d 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -86,9 +86,11 @@
86(test-assert "parse & export" 86(test-assert "parse & export"
87 (let* ((f (search-path %load-path "tests/test.drv")) 87 (let* ((f (search-path %load-path "tests/test.drv"))
88 (b1 (call-with-input-file f get-bytevector-all)) 88 (b1 (call-with-input-file f get-bytevector-all))
89 (d1 (read-derivation (open-bytevector-input-port b1))) 89 (d1 (read-derivation (open-bytevector-input-port b1)
90 identity))
90 (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>))) 91 (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>)))
91 (d2 (read-derivation (open-bytevector-input-port b2)))) 92 (d2 (read-derivation (open-bytevector-input-port b2)
93 identity)))
92 (and (equal? b1 b2) 94 (and (equal? b1 b2)
93 (equal? d1 d2)))) 95 (equal? d1 d2))))
94 96
@@ -723,7 +725,7 @@
723(test-assert "build-expression->derivation and derivation-prerequisites" 725(test-assert "build-expression->derivation and derivation-prerequisites"
724 (let ((drv (build-expression->derivation %store "fail" #f))) 726 (let ((drv (build-expression->derivation %store "fail" #f)))
725 (any (match-lambda 727 (any (match-lambda
726 (($ <derivation-input> path) 728 (($ <derivation-input> (= derivation-file-name path))
727 (string=? path (derivation-file-name (%guile-for-build))))) 729 (string=? path (derivation-file-name (%guile-for-build)))))
728 (derivation-prerequisites drv)))) 730 (derivation-prerequisites drv))))
729 731
@@ -740,7 +742,7 @@
740 (match (derivation-prerequisites c 742 (match (derivation-prerequisites c
741 (cut valid-derivation-input? %store 743 (cut valid-derivation-input? %store
742 <>)) 744 <>))
743 ((($ <derivation-input> file ("out"))) 745 ((($ <derivation-input> (= derivation-file-name file) ("out")))
744 (string=? file (derivation-file-name b))) 746 (string=? file (derivation-file-name b)))
745 (x 747 (x
746 (pk 'fail x #f))))) 748 (pk 'fail x #f)))))
@@ -804,17 +806,20 @@
804 ;; Ask for nothing but the "out" output of DRV. 806 ;; Ask for nothing but the "out" output of DRV.
805 (build-derivations store `((,drv . "out"))) 807 (build-derivations store `((,drv . "out")))
806 808
809 ;; Synonymous:
810 (build-derivations store (list (derivation-input drv '("out"))))
811
807 (valid-path? store out) 812 (valid-path? store out)
808 (equal? (pk 'x content) (pk 'y (call-with-input-file out get-string-all))) 813 (equal? (pk 'x content)
809 ))))) 814 (pk 'y (call-with-input-file out get-string-all))))))))
810 815
811(test-assert "build-expression->derivation and derivation-prerequisites-to-build" 816(test-assert "build-expression->derivation and derivation-build-plan"
812 (let ((drv (build-expression->derivation %store "fail" #f))) 817 (let ((drv (build-expression->derivation %store "fail" #f)))
813 ;; The only direct dependency is (%guile-for-build) and it's already 818 ;; The only direct dependency is (%guile-for-build) and it's already
814 ;; built. 819 ;; built.
815 (null? (derivation-prerequisites-to-build %store drv)))) 820 (null? (derivation-build-plan %store (derivation-inputs drv)))))
816 821
817(test-assert "derivation-prerequisites-to-build when outputs already present" 822(test-assert "derivation-build-plan when outputs already present"
818 (let* ((builder `(begin ,(random-text) (mkdir %output) #t)) 823 (let* ((builder `(begin ,(random-text) (mkdir %output) #t))
819 (input-drv (build-expression->derivation %store "input" builder)) 824 (input-drv (build-expression->derivation %store "input" builder))
820 (input-path (derivation->output-path input-drv)) 825 (input-path (derivation->output-path input-drv))
@@ -827,9 +832,12 @@
827 (valid-path? %store output)) 832 (valid-path? %store output))
828 (error "things already built" input-drv)) 833 (error "things already built" input-drv))
829 834
830 (and (equal? (map derivation-input-path 835 (and (lset= equal?
831 (derivation-prerequisites-to-build %store drv)) 836 (map derivation-file-name
832 (list (derivation-file-name input-drv))) 837 (derivation-build-plan %store
838 (list (derivation-input drv))))
839 (list (derivation-file-name input-drv)
840 (derivation-file-name drv)))
833 841
834 ;; Build DRV and delete its input. 842 ;; Build DRV and delete its input.
835 (build-derivations %store (list drv)) 843 (build-derivations %store (list drv))
@@ -838,9 +846,10 @@
838 846
839 ;; Now INPUT-PATH is missing, yet it shouldn't be listed as a 847 ;; Now INPUT-PATH is missing, yet it shouldn't be listed as a
840 ;; prerequisite to build because DRV itself is already built. 848 ;; prerequisite to build because DRV itself is already built.
841 (null? (derivation-prerequisites-to-build %store drv))))) 849 (null? (derivation-build-plan %store
850 (list (derivation-input drv)))))))
842 851
843(test-assert "derivation-prerequisites-to-build and substitutes" 852(test-assert "derivation-build-plan and substitutes"
844 (let* ((store (open-connection)) 853 (let* ((store (open-connection))
845 (drv (build-expression->derivation store "prereq-subst" 854 (drv (build-expression->derivation store "prereq-subst"
846 (random 1000))) 855 (random 1000)))
@@ -852,17 +861,19 @@
852 861
853 (with-derivation-narinfo drv 862 (with-derivation-narinfo drv
854 (let-values (((build download) 863 (let-values (((build download)
855 (derivation-prerequisites-to-build store drv)) 864 (derivation-build-plan store
865 (list (derivation-input drv))))
856 ((build* download*) 866 ((build* download*)
857 (derivation-prerequisites-to-build store drv 867 (derivation-build-plan store
858 #:substitutable-info 868 (list (derivation-input drv))
859 (const #f)))) 869 #:substitutable-info
870 (const #f))))
860 (and (null? build) 871 (and (null? build)
861 (equal? (map substitutable-path download) (list output)) 872 (equal? (map substitutable-path download) (list output))
862 (null? download*) 873 (null? download*)
863 (null? build*)))))) 874 (equal? (list drv) build*))))))
864 875
865(test-assert "derivation-prerequisites-to-build and substitutes, non-substitutable build" 876(test-assert "derivation-build-plan and substitutes, non-substitutable build"
866 (let* ((store (open-connection)) 877 (let* ((store (open-connection))
867 (drv (build-expression->derivation store "prereq-no-subst" 878 (drv (build-expression->derivation store "prereq-no-subst"
868 (random 1000) 879 (random 1000)
@@ -875,16 +886,16 @@
875 886
876 (with-derivation-narinfo drv 887 (with-derivation-narinfo drv
877 (let-values (((build download) 888 (let-values (((build download)
878 (derivation-prerequisites-to-build store drv))) 889 (derivation-build-plan store
890 (list (derivation-input drv)))))
879 ;; Despite being available as a substitute, DRV will be built locally 891 ;; Despite being available as a substitute, DRV will be built locally
880 ;; due to #:substitutable? #f. 892 ;; due to #:substitutable? #f.
881 (and (null? download) 893 (and (null? download)
882 (match build 894 (match build
883 (((? derivation-input? input)) 895 (((= derivation-file-name build))
884 (string=? (derivation-input-path input) 896 (string=? build (derivation-file-name drv)))))))))
885 (derivation-file-name drv)))))))))
886 897
887(test-assert "derivation-prerequisites-to-build and substitutes, local build" 898(test-assert "derivation-build-plan and substitutes, local build"
888 (with-store store 899 (with-store store
889 (let* ((drv (build-expression->derivation store "prereq-subst-local" 900 (let* ((drv (build-expression->derivation store "prereq-subst-local"
890 (random 1000) 901 (random 1000)
@@ -897,7 +908,8 @@
897 908
898 (with-derivation-narinfo drv 909 (with-derivation-narinfo drv
899 (let-values (((build download) 910 (let-values (((build download)
900 (derivation-prerequisites-to-build store drv))) 911 (derivation-build-plan store
912 (list (derivation-input drv)))))
901 ;; #:local-build? is *not* synonymous with #:substitutable?, so we 913 ;; #:local-build? is *not* synonymous with #:substitutable?, so we
902 ;; must be able to substitute DRV's output. 914 ;; must be able to substitute DRV's output.
903 ;; See <http://bugs.gnu.org/18747>. 915 ;; See <http://bugs.gnu.org/18747>.
@@ -906,7 +918,7 @@
906 (((= substitutable-path item)) 918 (((= substitutable-path item))
907 (string=? item (derivation->output-path drv)))))))))) 919 (string=? item (derivation->output-path drv))))))))))
908 920
909(test-assert "derivation-prerequisites-to-build in 'check' mode" 921(test-assert "derivation-build-plan in 'check' mode"
910 (with-store store 922 (with-store store
911 (let* ((dep (build-expression->derivation store "dep" 923 (let* ((dep (build-expression->derivation store "dep"
912 `(begin ,(random-text) 924 `(begin ,(random-text)
@@ -918,13 +930,13 @@
918 (delete-paths store (list (derivation->output-path dep))) 930 (delete-paths store (list (derivation->output-path dep)))
919 931
920 ;; In 'check' mode, DEP must be rebuilt. 932 ;; In 'check' mode, DEP must be rebuilt.
921 (and (null? (derivation-prerequisites-to-build store drv)) 933 (and (null? (derivation-build-plan store
922 (match (derivation-prerequisites-to-build store drv 934 (list (derivation-input drv))))
923 #:mode (build-mode 935 (lset= equal?
924 check)) 936 (derivation-build-plan store
925 ((input) 937 (list (derivation-input drv))
926 (string=? (derivation-input-path input) 938 #:mode (build-mode check))
927 (derivation-file-name dep)))))))) 939 (list drv dep))))))
928 940
929(test-assert "substitution-oracle and #:substitute? #f" 941(test-assert "substitution-oracle and #:substitute? #f"
930 (with-store store 942 (with-store store