aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-03 11:02:11 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-03 18:03:09 +0200
commit882383a9aa5fbeef6f29d359a786a6db7c9e03db (patch)
tree323b5cffbe95c01b070064f1c89f3f968ba95ba2 /tests
parentb497a85be8490f0f91279119904fd76ae13cbea5 (diff)
downloadguix-882383a9aa5fbeef6f29d359a786a6db7c9e03db.tar
guix-882383a9aa5fbeef6f29d359a786a6db7c9e03db.tar.gz
download: Allow raw file names or file:// URLs.
* guix/download.scm (url-fetch): When URL is a string, if it's not a URI or if it's a URI with 'file' or #f scheme, use 'add-to-store'. * tests/builders.scm ("url-fetch, file", "url-fetch, file URI"): New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/builders.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/builders.scm b/tests/builders.scm
index ce1f3852d7..a2f500a94d 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -25,6 +25,7 @@
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module (guix derivations)
+ #:use-module (guix hash)
#:use-module (guix tests)
#:use-module ((guix packages)
#:select (package-derivation package-native-search-paths))
@@ -74,6 +75,22 @@
(file-exists? out-path)
(valid-path? %store out-path))))
+(test-assert "url-fetch, file"
+ (let* ((file (search-path %load-path "guix.scm"))
+ (hash (call-with-input-file file port-sha256))
+ (out (url-fetch %store file 'sha256 hash)))
+ (and (file-exists? out)
+ (valid-path? %store out))))
+
+(test-assert "url-fetch, file URI"
+ (let* ((file (search-path %load-path "guix.scm"))
+ (hash (call-with-input-file file port-sha256))
+ (out (url-fetch %store
+ (string-append "file://" (canonicalize-path file))
+ 'sha256 hash)))
+ (and (file-exists? out)
+ (valid-path? %store out))))
+
(test-assert "gnu-build-system"
(and (build-system? gnu-build-system)
(eq? gnu-build (build-system-builder gnu-build-system))))