From 12d720fd1a9c43019f2d5afa051b45c7633b3ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 23 Feb 2015 23:41:26 +0100 Subject: 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 +++++ 1 file changed, 5 insertions(+) (limited to 'guix/tests.scm') diff --git a/guix/tests.scm b/guix/tests.scm index 1171bb4dfb..d004a50a36 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." -- cgit v1.2.3