guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: tests: Factorize the network reachability test.


From: Ludovic Courtès
Subject: 01/02: tests: Factorize the network reachability test.
Date: Mon, 23 Feb 2015 23:01:54 +0000

civodul pushed a commit to branch master
in repository guix.

commit 12d720fd1a9c43019f2d5afa051b45c7633b3ab0
Author: Ludovic Courtès <address@hidden>
Date:   Mon Feb 23 23:41:26 2015 +0100

    tests: Factorize the network reachability test.
    
    * guix/tests.scm (network-reachable?): New procedure.
    * tests/builders.scm (network-reachable?): Remove.
      Replace references to it with calls to the new 'network-reachable?'
      procedure.
    * tests/derivations.scm (%coreutils): Use 'network-reachable?' instead
      of 'getaddrinfo'.
    * tests/packages.scm: Likewise.
    * tests/union.scm: Likewise.
---
 guix/tests.scm        |    5 +++++
 tests/builders.scm    |    7 ++-----
 tests/derivations.scm |    2 +-
 tests/packages.scm    |    6 ++----
 tests/union.scm       |    6 ++----
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/guix/tests.scm b/guix/tests.scm
index 1171bb4..d004a50 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -31,6 +31,7 @@
   #:export (open-connection-for-tests
             random-text
             random-bytevector
+            network-reachable?
             mock
             %substitute-directory
             with-derivation-narinfo
@@ -77,6 +78,10 @@
             (loop (1+ i)))
           bv))))
 
+(define (network-reachable?)
+  "Return true if we can reach the Internet."
+  (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
+
 (define-syntax-rule (mock (module proc replacement) body ...)
   "Within BODY, replace the definition of PROC from MODULE with the definition
 given by REPLACEMENT."
diff --git a/tests/builders.scm b/tests/builders.scm
index e5acc3e..3c2a3ed 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -56,16 +56,13 @@
                 (package-native-search-paths package)))
               (@@ (gnu packages commencement) %boot0-inputs)))
 
-(define network-reachable?
-  (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
-
 (define url-fetch*
   (store-lower url-fetch))
 
 
 (test-begin "builders")
 
-(unless network-reachable? (test-skip 1))
+(unless (network-reachable?) (test-skip 1))
 (test-assert "url-fetch"
   (let* ((url      '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz";
                      "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz";))
@@ -97,7 +94,7 @@
 (test-assert "gnu-build-system"
   (build-system? gnu-build-system))
 
-(unless network-reachable? (test-skip 1))
+(unless (network-reachable?) (test-skip 1))
 (test-assert "gnu-build"
   (let* ((url      "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz";)
          (hash     (nix-base32-string->bytevector
diff --git a/tests/derivations.scm b/tests/derivations.scm
index e23bdee..72d253c 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -463,7 +463,7 @@
 
 (define %coreutils
   (false-if-exception
-   (and (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)
+   (and (network-reachable?)
         (or (package-derivation %store %bootstrap-coreutils&co)
             (nixpkgs-derivation "coreutils")))))
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 851520b..5725b0a 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -176,8 +176,7 @@
     (and (direct-store-path? source)
          (string-suffix? "utils.scm" source))))
 
-(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
-  (test-skip 1))
+(unless (network-reachable?) (test-skip 1))
 (test-equal "package-source-derivation, snippet"
   "OK"
   (let* ((file   (search-bootstrap-binary "guile-2.0.9.tar.xz"
@@ -532,8 +531,7 @@
                      (%current-target-system "foo64-linux-gnu"))
         (equal? drv (bag->derivation %store bag))))))
 
-(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
-  (test-skip 1))
+(unless (network-reachable?) (test-skip 1))
 (test-assert "GNU Make, bootstrap"
   ;; GNU Make is the first program built during bootstrap; we choose it
   ;; here so that the test doesn't last for too long.
diff --git a/tests/union.scm b/tests/union.scm
index 7e55670..22ba67c 100644
--- a/tests/union.scm
+++ b/tests/union.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -84,9 +84,7 @@
                           (call-with-input-file "bar/two" get-string-all))
                 (not (file-exists? "bar/one")))))))
 
-(test-skip (if (and %store
-                    (false-if-exception
-                     (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
+(test-skip (if (and %store (network-reachable?))
                0
                1))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]