diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-06-27 23:33:48 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-06-27 23:33:48 +0200 |
| commit | 5cc1075a76392666d3d733837f5c6252b1e48002 (patch) | |
| tree | aff2a303881a6fe53021a6e78a767958e608719b /tests | |
| parent | 9c2563a80b6f1d8fb8677f5314e6180ea9916aa5 (diff) | |
| parent | c30d117822a8ca26cd8c06c0a3974955bef68eac (diff) | |
Merge branch 'master' into core-updates
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/derivations.scm | 80 | ||||
| -rw-r--r-- | tests/grafts.scm | 14 | ||||
| -rw-r--r-- | tests/guix-daemon.sh | 2 | ||||
| -rw-r--r-- | tests/packages.scm | 32 | ||||
| -rw-r--r-- | tests/syscalls.scm | 5 | ||||
| -rw-r--r-- | tests/ui.scm | 27 |
6 files changed, 112 insertions, 48 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 |
diff --git a/tests/grafts.scm b/tests/grafts.scm index e5356decc5e..a12c6a5911b 100644 --- a/tests/grafts.scm +++ b/tests/grafts.scm | |||
| @@ -44,9 +44,6 @@ | |||
| 44 | (define %mkdir | 44 | (define %mkdir |
| 45 | (bootstrap-binary "mkdir")) | 45 | (bootstrap-binary "mkdir")) |
| 46 | 46 | ||
| 47 | (define make-derivation-input | ||
| 48 | (@@ (guix derivations) make-derivation-input)) | ||
| 49 | |||
| 50 | 47 | ||
| 51 | (test-begin "grafts") | 48 | (test-begin "grafts") |
| 52 | 49 | ||
| @@ -355,16 +352,11 @@ | |||
| 355 | (p1r-inputs (filter (match-input p1r) inputs)) | 352 | (p1r-inputs (filter (match-input p1r) inputs)) |
| 356 | (p2-inputs (filter (match-input p2) inputs))) | 353 | (p2-inputs (filter (match-input p2) inputs))) |
| 357 | (and (equal? p1-inputs | 354 | (and (equal? p1-inputs |
| 358 | (list (make-derivation-input (derivation-file-name p1) | 355 | (list (derivation-input p1 '("one")))) |
| 359 | '("one")))) | ||
| 360 | (equal? p1r-inputs | 356 | (equal? p1r-inputs |
| 361 | (list | 357 | (list (derivation-input p1r '("ONE")))) |
| 362 | (make-derivation-input (derivation-file-name p1r) | ||
| 363 | '("ONE")))) | ||
| 364 | (equal? p2-inputs | 358 | (equal? p2-inputs |
| 365 | (list | 359 | (list (derivation-input p2 '("aaa")))) |
| 366 | (make-derivation-input (derivation-file-name p2) | ||
| 367 | '("aaa")))) | ||
| 368 | (derivation-output-names p2g)))))) | 360 | (derivation-output-names p2g)))))) |
| 369 | 361 | ||
| 370 | (test-assert "graft-derivation, renaming" ;<http://bugs.gnu.org/23132> | 362 | (test-assert "graft-derivation, renaming" ;<http://bugs.gnu.org/23132> |
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh index ca46e34ce96..758f18cc368 100644 --- a/tests/guix-daemon.sh +++ b/tests/guix-daemon.sh | |||
| @@ -196,7 +196,7 @@ done | |||
| 196 | 196 | ||
| 197 | # Make sure garbage collection from a TCP connection does not work. | 197 | # Make sure garbage collection from a TCP connection does not work. |
| 198 | 198 | ||
| 199 | tcp_socket="127.0.0.1:9999" | 199 | tcp_socket="127.0.0.1:9998" |
| 200 | guix-daemon --listen="$tcp_socket" & | 200 | guix-daemon --listen="$tcp_socket" & |
| 201 | daemon_pid=$! | 201 | daemon_pid=$! |
| 202 | 202 | ||
diff --git a/tests/packages.scm b/tests/packages.scm index bd100bea5be..0478fff237e 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -1244,6 +1244,38 @@ | |||
| 1244 | (lambda (key . args) | 1244 | (lambda (key . args) |
| 1245 | key))) | 1245 | key))) |
| 1246 | 1246 | ||
| 1247 | (test-equal "specification->package+output" | ||
| 1248 | `((,coreutils "out") (,coreutils "debug")) | ||
| 1249 | (list (call-with-values (lambda () | ||
| 1250 | (specification->package+output "coreutils")) | ||
| 1251 | list) | ||
| 1252 | (call-with-values (lambda () | ||
| 1253 | (specification->package+output "coreutils:debug")) | ||
| 1254 | list))) | ||
| 1255 | |||
| 1256 | (test-equal "specification->package+output invalid output" | ||
| 1257 | 'error | ||
| 1258 | (catch 'quit | ||
| 1259 | (lambda () | ||
| 1260 | (specification->package+output "coreutils:does-not-exist")) | ||
| 1261 | (lambda _ | ||
| 1262 | 'error))) | ||
| 1263 | |||
| 1264 | (test-equal "specification->package+output no default output" | ||
| 1265 | `(,coreutils #f) | ||
| 1266 | (call-with-values | ||
| 1267 | (lambda () | ||
| 1268 | (specification->package+output "coreutils" #f)) | ||
| 1269 | list)) | ||
| 1270 | |||
| 1271 | (test-equal "specification->package+output invalid output, no default" | ||
| 1272 | 'error | ||
| 1273 | (catch 'quit | ||
| 1274 | (lambda () | ||
| 1275 | (specification->package+output "coreutils:does-not-exist" #f)) | ||
| 1276 | (lambda _ | ||
| 1277 | 'error))) | ||
| 1278 | |||
| 1247 | (test-equal "find-package-locations" | 1279 | (test-equal "find-package-locations" |
| 1248 | (map (lambda (package) | 1280 | (map (lambda (package) |
| 1249 | (cons (package-version package) | 1281 | (cons (package-version package) |
diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 3e267c9f011..eeb223b9504 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> | 3 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| @@ -538,6 +538,9 @@ | |||
| 538 | (> (terminal-columns (open-input-string "Join us now, share the software!")) | 538 | (> (terminal-columns (open-input-string "Join us now, share the software!")) |
| 539 | 0)) | 539 | 0)) |
| 540 | 540 | ||
| 541 | (test-assert "terminal-rows" | ||
| 542 | (> (terminal-rows) 0)) | ||
| 543 | |||
| 541 | (test-assert "utmpx-entries" | 544 | (test-assert "utmpx-entries" |
| 542 | (match (utmpx-entries) | 545 | (match (utmpx-entries) |
| 543 | (((? utmpx? entries) ...) | 546 | (((? utmpx? entries) ...) |
diff --git a/tests/ui.scm b/tests/ui.scm index 1e98e3534be..2138e23369b 100644 --- a/tests/ui.scm +++ b/tests/ui.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -22,10 +22,12 @@ | |||
| 22 | #:use-module (guix profiles) | 22 | #:use-module (guix profiles) |
| 23 | #:use-module (guix store) | 23 | #:use-module (guix store) |
| 24 | #:use-module (guix derivations) | 24 | #:use-module (guix derivations) |
| 25 | #:use-module ((gnu packages) #:select (specification->package)) | ||
| 25 | #:use-module (guix tests) | 26 | #:use-module (guix tests) |
| 26 | #:use-module (srfi srfi-1) | 27 | #:use-module (srfi srfi-1) |
| 27 | #:use-module (srfi srfi-11) | 28 | #:use-module (srfi srfi-11) |
| 28 | #:use-module (srfi srfi-19) | 29 | #:use-module (srfi srfi-19) |
| 30 | #:use-module (srfi srfi-26) | ||
| 29 | #:use-module (srfi srfi-64) | 31 | #:use-module (srfi srfi-64) |
| 30 | #:use-module (ice-9 regex)) | 32 | #:use-module (ice-9 regex)) |
| 31 | 33 | ||
| @@ -260,4 +262,27 @@ Second line" 24)) | |||
| 260 | "ISO-8859-1") | 262 | "ISO-8859-1") |
| 261 | (show-manifest-transaction store m t)))))))) | 263 | (show-manifest-transaction store m t)))))))) |
| 262 | 264 | ||
| 265 | (test-assert "package-relevance" | ||
| 266 | (let ((guile (specification->package "guile")) | ||
| 267 | (gcrypt (specification->package "guile-gcrypt")) | ||
| 268 | (go (specification->package "go")) | ||
| 269 | (gnugo (specification->package "gnugo")) | ||
| 270 | (rx (cut make-regexp <> regexp/icase)) | ||
| 271 | (>0 (cut > <> 0)) | ||
| 272 | (=0 zero?)) | ||
| 273 | (and (>0 (package-relevance guile | ||
| 274 | (map rx '("scheme")))) | ||
| 275 | (>0 (package-relevance guile | ||
| 276 | (map rx '("scheme" "implementation")))) | ||
| 277 | (>0 (package-relevance gcrypt | ||
| 278 | (map rx '("guile" "crypto")))) | ||
| 279 | (=0 (package-relevance guile | ||
| 280 | (map rx '("guile" "crypto")))) | ||
| 281 | (>0 (package-relevance go | ||
| 282 | (map rx '("go")))) | ||
| 283 | (=0 (package-relevance go | ||
| 284 | (map rx '("go" "game")))) | ||
| 285 | (>0 (package-relevance gnugo | ||
| 286 | (map rx '("go" "game"))))))) | ||
| 287 | |||
| 263 | (test-end "ui") | 288 | (test-end "ui") |
