From 5acb808b9f32e3b5703855d2cd2f5f5608f7c0fe Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Fri, 6 Nov 2020 18:25:03 -0800 Subject: [PATCH 02/29] tests: Only run tests requiring bootstrap binaries when network is available. --- tests/derivations.scm | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) Index: guix-debian/tests/derivations.scm =================================================================== --- guix-debian.orig/tests/derivations.scm +++ guix-debian/tests/derivations.scm @@ -114,6 +114,7 @@ (equal? (directory-contents dir) (directory-contents drv))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation with no inputs" (let* ((builder (add-text-to-store %store "my-builder.sh" "echo hello, world\n" @@ -124,6 +125,7 @@ (and (store-path? (derivation-file-name drv)) (valid-path? %store (derivation-file-name drv))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "build derivation with 1 source" (let* ((builder (add-text-to-store %store "my-builder.sh" "echo hello, world > \"$out\"\n" @@ -142,6 +144,7 @@ (string=? (call-with-input-file path read-line) "hello, world")))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation fails but keep going" ;; In keep-going mode, 'build-derivations' should fail because of D1, but it ;; must return only after D2 has succeeded. @@ -169,6 +172,7 @@ (build-derivations %store (list d1 d2)) #f)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "identical files are deduplicated" ;; Note: DATA must be longer than %DEDUPLICATION-MINIMUM-SIZE. (let* ((data (make-string 9000 #\a)) @@ -276,11 +280,13 @@ get-string-all) text)))))) +(unless (network-reachable?) (test-skip 1)) (test-equal "derivation-name" "foo-0.0" (let ((drv (derivation %store "foo-0.0" %bash '()))) (derivation-name drv))) +(unless (network-reachable?) (test-skip 1)) (test-equal "derivation-output-names" '(("out") ("bar" "chbouib")) (let ((drv1 (derivation %store "foo-0.0" %bash '())) @@ -289,6 +295,7 @@ (list (derivation-output-names drv1) (derivation-output-names drv2)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "offloadable-derivation?" (and (offloadable-derivation? (derivation %store "foo" %bash '())) (offloadable-derivation? ;see @@ -298,6 +305,7 @@ (derivation %store "foo" %bash '() #:local-build? #t))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "substitutable-derivation?" (and (substitutable-derivation? (derivation %store "foo" %bash '())) (substitutable-derivation? ;see @@ -307,6 +315,7 @@ (derivation %store "foo" %bash '() #:substitutable? #f))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "fixed-output-derivation?" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" '())) @@ -317,6 +326,7 @@ #:hash hash #:hash-algo 'sha256))) (fixed-output-derivation? drv))) +(unless (network-reachable?) (test-skip 1)) (test-equal "fixed-output derivation" '(sha1 sha256 sha512) (map (lambda (hash-algorithm) @@ -341,6 +351,7 @@ hash-algorithm)))) '(sha1 sha256 sha512))) +(unless (network-reachable?) (test-skip 1)) (test-assert "fixed-output derivation: output paths are equal" (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh" "echo -n hello > $out" '())) @@ -358,6 +369,7 @@ (equal? (derivation->output-path drv1) (derivation->output-path drv2))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "fixed-output derivation, recursive" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" '())) @@ -375,6 +387,7 @@ (call-with-input-file p get-bytevector-all)) (bytevector? (query-path-hash %store p))))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation with a fixed-output input" ;; A derivation D using a fixed-output derivation F doesn't has the same ;; output path when passed F or F', as long as F and F' have the same output @@ -411,6 +424,7 @@ (equal? (derivation->output-path final1) (derivation->output-path final2))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation with duplicate fixed-output inputs" ;; Here we create a derivation that has two inputs, both of which are ;; fixed-output leading to the same result. This test ensures the hash of @@ -479,6 +493,7 @@ (lset= string=? (derivation-input-sub-derivations input) '("one" "two"))))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "multiple-output derivation" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo one > $out ; echo two > $second" @@ -500,6 +515,7 @@ (eq? 'one (call-with-input-file one read)) (eq? 'two (call-with-input-file two read))))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "multiple-output derivation, non-alphabetic order" ;; Here, the outputs are not listed in alphabetic order. Yet, the store ;; path computation must reorder them first. @@ -517,6 +533,7 @@ (and (eq? 'one (call-with-input-file one read)) (eq? 'two (call-with-input-file two read))))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "read-derivation vs. derivation" ;; Make sure 'derivation' and 'read-derivation' return objects that are ;; identical. @@ -544,6 +561,7 @@ read-derivation))) (equal? drv* drv))) +(unless (network-reachable?) (test-skip 1)) (test-assert "multiple-output derivation, derivation-path->output-path" (let* ((builder (add-text-to-store %store "builder.sh" "echo one > $out ; echo two > $second" @@ -561,6 +579,7 @@ (string=? first one) (string=? second two)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "user of multiple-output derivation" ;; Check whether specifying several inputs coming from the same ;; multiple-output derivation works. @@ -594,6 +613,7 @@ (and (valid-path? %store p) (equal? '(one two) (call-with-input-file p read))))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation with #:references-graphs" (let* ((input1 (add-text-to-store %store "foo" "hello" (list %bash))) @@ -644,6 +664,7 @@ ((p2 . _) (string $out") @@ -651,6 +672,7 @@ #:allowed-references '()))) (build-derivations %store (list drv)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation #:allowed-references, not allowed" (let* ((txt (add-text-to-store %store "foo" "Hello, world.")) (drv (derivation %store "disallowed" %bash @@ -663,6 +685,7 @@ (build-derivations %store (list drv)) #f))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation #:allowed-references, self allowed" (let ((drv (derivation %store "allowed" %bash '("-c" "echo $out > $out") @@ -670,6 +693,7 @@ #:allowed-references '("out")))) (build-derivations %store (list drv)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation #:allowed-references, self not allowed" (let ((drv (derivation %store "disallowed" %bash `("-c" ,"echo $out > $out") @@ -681,6 +705,7 @@ (build-derivations %store (list drv)) #f))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation #:disallowed-references, ok" (let ((drv (derivation %store "disallowed" %bash '("-c" "echo hello > $out") @@ -688,6 +713,7 @@ #:disallowed-references '("out")))) (build-derivations %store (list drv)))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation #:disallowed-references, not ok" (let* ((txt (add-text-to-store %store "foo" "Hello, world.")) (drv (derivation %store "disdisallowed" %bash @@ -704,6 +730,7 @@ ;; which is a unique value for each test process; this value is the same as ;; the one we see in the process executing this file since it is set by ;; 'test-env'. +(unless (network-reachable?) (test-skip 1)) (test-equal "derivation #:leaked-env-vars" (getenv "GUIX_STATE_DIRECTORY") (let* ((value (getenv "GUIX_STATE_DIRECTORY")) @@ -724,7 +751,7 @@ (package-derivation %store %bootstrap-coreutils&co)))) (test-skip (if %coreutils 0 1)) - +(unless (network-reachable?) (test-skip 1)) (test-assert "build derivation with coreutils" (let* ((builder (add-text-to-store %store "build-with-coreutils.sh" @@ -747,7 +774,7 @@ (file-exists? (string-append p "/good"))))))) (test-skip (if (%guile-for-build) 0 8)) - +(unless (network-reachable?) (test-skip 1)) (test-equal "build-expression->derivation and invalid module name" '(file-search-error "guix/module/that/does/not/exist.scm") (guard (c ((file-search-error? c) @@ -1016,6 +1043,7 @@ #:mode (build-mode check)) (list drv dep)))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "derivation-input-fold" (let* ((builder (add-text-to-store %store "my-builder.sh" "echo hello, world > \"$out\"\n" @@ -1228,6 +1256,7 @@ (let ((out (derivation->output-path drv))) (string=? (readlink (string-append out "/symlink")) in))))) +(unless (network-reachable?) (test-skip 1)) (test-assert "build-expression->derivation with #:references-graphs" (let* ((input (add-text-to-store %store "foo" "hello" (list %bash %mkdir))) @@ -1269,6 +1298,7 @@ (list (derivation-properties drv1) (derivation-properties drv2)))) +(unless (network-reachable?) (test-skip 1)) (test-equal "map-derivation" "hello" (let* ((joke (package-derivation %store guile-1.8)) @@ -1292,6 +1322,7 @@ (and (build-derivations %store (list (pk 'remapped drv4))) (call-with-input-file out get-string-all)))) +(unless (network-reachable?) (test-skip 1)) (test-equal "map-derivation, sources" "hello" (let* ((script1 (add-text-to-store %store "fail.sh" "exit 1"))