summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-01-20 10:17:24 +0100
committerLudovic Courtès <ludo@gnu.org>2015-01-20 10:17:24 +0100
commitdbab5150f83543f0c8a424dfddb698d7812370b7 (patch)
tree8e6e4194a1b734885eb60cc6a7075906519994e7
parent6b1f9721a83f343315ae4b936ec9b9542ba8523e (diff)
gnu: 'search-patch' raises an error when a patch is not found.
* gnu/packages.scm (search-patch): Raise an error condition when 'search-path' returns #f. * tests/packages.scm ("patch not found yields a run-time error"): New test.
-rw-r--r--gnu/packages.scm9
-rw-r--r--tests/packages.scm20
2 files changed, 27 insertions, 2 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm
index 7f0b58b971a..263addb8beb 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -30,6 +30,8 @@
30 #:use-module (srfi srfi-1) 30 #:use-module (srfi srfi-1)
31 #:use-module (srfi srfi-11) 31 #:use-module (srfi srfi-11)
32 #:use-module (srfi srfi-26) 32 #:use-module (srfi srfi-26)
33 #:use-module (srfi srfi-34)
34 #:use-module (srfi srfi-35)
33 #:use-module (srfi srfi-39) 35 #:use-module (srfi srfi-39)
34 #:export (search-patch 36 #:export (search-patch
35 search-bootstrap-binary 37 search-bootstrap-binary
@@ -70,8 +72,11 @@
70 %load-path))) 72 %load-path)))
71 73
72(define (search-patch file-name) 74(define (search-patch file-name)
73 "Search the patch FILE-NAME." 75 "Search the patch FILE-NAME. Raise an error if not found."
74 (search-path (%patch-path) file-name)) 76 (or (search-path (%patch-path) file-name)
77 (raise (condition
78 (&message (message (format #f (_ "~a: patch not found")
79 file-name)))))))
75 80
76(define (search-bootstrap-binary file-name system) 81(define (search-bootstrap-binary file-name system)
77 "Search the bootstrap binary FILE-NAME for SYSTEM." 82 "Search the bootstrap binary FILE-NAME for SYSTEM."
diff --git a/tests/packages.scm b/tests/packages.scm
index bd5ba3ee92c..ef34e763808 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -42,6 +42,7 @@
42 #:use-module (srfi srfi-1) 42 #:use-module (srfi srfi-1)
43 #:use-module (srfi srfi-26) 43 #:use-module (srfi srfi-26)
44 #:use-module (srfi srfi-34) 44 #:use-module (srfi srfi-34)
45 #:use-module (srfi srfi-35)
45 #:use-module (srfi srfi-64) 46 #:use-module (srfi srfi-64)
46 #:use-module (rnrs io ports) 47 #:use-module (rnrs io ports)
47 #:use-module (ice-9 regex) 48 #:use-module (ice-9 regex)
@@ -248,6 +249,25 @@
248 (string=? (derivation->output-path drv) 249 (string=? (derivation->output-path drv)
249 (package-output %store package "out"))))) 250 (package-output %store package "out")))))
250 251
252(test-assert "patch not found yields a run-time error"
253 (guard (c ((condition-has-type? c &message)
254 (and (string-contains (condition-message c)
255 "does-not-exist.patch")
256 (string-contains (condition-message c)
257 "not found"))))
258 (let ((p (package
259 (inherit (dummy-package "p"))
260 (source (origin
261 (method (const #f))
262 (uri "http://whatever")
263 (patches
264 (list (search-patch "does-not-exist.patch")))
265 (sha256
266 (base32
267 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks4")))))))
268 (package-derivation %store p)
269 #f)))
270
251(test-assert "trivial" 271(test-assert "trivial"
252 (let* ((p (package (inherit (dummy-package "trivial")) 272 (let* ((p (package (inherit (dummy-package "trivial"))
253 (build-system trivial-build-system) 273 (build-system trivial-build-system)