summary refs log tree commit diff
path: root/tests/scripts-build.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-03-23 22:32:44 +0100
committerLudovic Courtès <ludo@gnu.org>2016-03-23 23:43:50 +0100
commit9a2a20052a1a9c384a1b877d7c71d2d239f9467e (patch)
treee63fda1b5dac94a569372d67b0a9ed986f9959c0 /tests/scripts-build.scm
parent7b150a24feb96bb803d4caf50846c6ac8b2c4ad0 (diff)
downloadguix-9a2a20052a1a9c384a1b877d7c71d2d239f9467e.tar.gz
guix build: '--with-source' correctly matches versioned file names.
* guix/scripts/build.scm: Use the right 'package-name->name+version'
procedure.  Fixes a regression introduced in
1b846da8c372bee78851439fd9e72b2499115e5a.
* tests/scripts-build.scm ("options->transformation, with-source, with
version"): New test.
Diffstat (limited to 'tests/scripts-build.scm')
-rw-r--r--tests/scripts-build.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm
index 94ddaf447b..cf9770e952 100644
--- a/tests/scripts-build.scm
+++ b/tests/scripts-build.scm
@@ -22,6 +22,7 @@
   #:use-module (guix packages)
   #:use-module (guix scripts build)
   #:use-module (guix ui)
+  #:use-module (guix utils)
   #:use-module (gnu packages base)
   #:use-module (gnu packages busybox)
   #:use-module (ice-9 match)
@@ -49,6 +50,25 @@
                        (add-to-store store "guix.scm" #t
                                      "sha256" s)))))))
 
+(test-assert "options->transformation, with-source, with version"
+  ;; Our pseudo-package is called 'guix.scm' so the 'guix.scm-2.0' source
+  ;; should be applicable, and its version should be extracted.
+  (let ((p (dummy-package "foo"))
+        (s (search-path %load-path "guix.scm")))
+    (call-with-temporary-directory
+     (lambda (directory)
+       (let* ((f (string-append directory "/foo-42.0.tar.gz"))
+              (t (options->transformation `((with-source . ,f)))))
+         (copy-file s f)
+         (with-store store
+           (let ((new (t store p)))
+             (and (not (eq? new p))
+                  (string=? (package-name new) (package-name p))
+                  (string=? (package-version new) "42.0")
+                  (string=? (package-source new)
+                            (add-to-store store (basename f) #t
+                                          "sha256" f))))))))))
+
 (test-assert "options->transformation, with-source, no matches"
   ;; When a transformation in not applicable, a warning must be raised.
   (let* ((p (dummy-package "foobar"))