summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyril Roelandt <tipecaml@gmail.com>2015-02-26 02:07:53 +0100
committerCyril Roelandt <tipecaml@gmail.com>2015-06-24 22:47:59 +0200
commitff986890ece06b0623a7c8b3048dea1206f076ea (patch)
treec9bd5d004be8d46f4fae9d44617ac8c413d43d94 /tests
parenteae5b3fff54e6f0a38d03d01187142accbed1eb8 (diff)
import: pypi: Detect inputs.
* guix/import/pypi.scm (python->package-name, maybe-inputs, compute-inputs, guess-requirements): New procedures. * guix/import/pypi.scm (guix-hash-url): Now takes a filename instead of an URL as input. * guix/import/pypi.scm (make-pypi-sexp): Now tries to generate the inputs automagically. * tests/pypi.scm: Update the test.
Diffstat (limited to 'tests')
-rw-r--r--tests/pypi.scm42
1 files changed, 29 insertions, 13 deletions
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 45cf7cac4f..c772474b82 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -21,6 +21,7 @@
#:use-module (guix base32)
#:use-module (guix hash)
#:use-module (guix tests)
+ #:use-module ((guix build utils) #:select (delete-file-recursively))
#:use-module (srfi srfi-64)
#:use-module (ice-9 match))
@@ -46,8 +47,14 @@
}
}")
-(define test-source
- "foobar")
+(define test-source-hash
+ "")
+
+(define test-requirements
+"# A comment
+ # A comment after a space
+bar
+baz > 13.37")
(test-begin "pypi")
@@ -55,15 +62,22 @@
;; Replace network resources with sample data.
(mock ((guix import utils) url-fetch
(lambda (url file-name)
- (with-output-to-file file-name
- (lambda ()
- (display
- (match url
- ("https://pypi.python.org/pypi/foo/json"
- test-json)
- ("https://example.com/foo-1.0.0.tar.gz"
- test-source)
- (_ (error "Unexpected URL: " url))))))))
+ (match url
+ ("https://pypi.python.org/pypi/foo/json"
+ (with-output-to-file file-name
+ (lambda ()
+ (display test-json))))
+ ("https://example.com/foo-1.0.0.tar.gz"
+ (begin
+ (mkdir "foo-1.0.0")
+ (with-output-to-file "foo-1.0.0/requirements.txt"
+ (lambda ()
+ (display test-requirements)))
+ (system* "tar" "czvf" file-name "foo-1.0.0/")
+ (delete-file-recursively "foo-1.0.0")
+ (set! test-source-hash
+ (call-with-input-file file-name port-sha256))))
+ (_ (error "Unexpected URL: " url)))))
(match (pypi->guix-package "foo")
(('package
('name "python-foo")
@@ -78,13 +92,15 @@
('build-system 'python-build-system)
('inputs
('quasiquote
- (("python-setuptools" ('unquote 'python-setuptools)))))
+ (("python-bar" ('unquote 'python-bar))
+ ("python-baz" ('unquote 'python-baz))
+ ("python-setuptools" ('unquote 'python-setuptools)))))
('home-page "http://example.com")
('synopsis "summary")
('description "summary")
('license 'lgpl2.0))
(string=? (bytevector->nix-base32-string
- (call-with-input-string test-source port-sha256))
+ test-source-hash)
hash))
(x
(pk 'fail x #f)))))