import: crate: Trim version for names after left-most non-zero part.
[jackhill/guix/guix.git] / tests / build-utils.scm
index 61e6c44..654b480 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2015, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -151,11 +151,12 @@ echo hello world"))
   (test-equal "wrap-script, simple case"
     (string-append
      (format #f "\
-#!GUILE --no-auto-compile
+#!~a --no-auto-compile
 #!#; Guix wrapper
 #\\-~s
 #\\-~s
 "
+             (which "guile")
              '(begin (let ((current (getenv "GUIX_FOO")))
                        (setenv "GUIX_FOO"
                                (if current
@@ -173,13 +174,11 @@ echo hello world"))
        (let ((script-file-name (string-append directory "/foo")))
          (call-with-output-file script-file-name
            (lambda (port)
-             (format port script-contents)))
+             (display script-contents port)))
          (chmod script-file-name #o777)
-
-         (mock ((guix build utils) which (const "GUILE"))
-               (wrap-script script-file-name
-                            `("GUIX_FOO" prefix ("/some/path"
-                                                 "/some/other/path"))))
+         (wrap-script script-file-name
+                      `("GUIX_FOO" prefix ("/some/path"
+                                           "/some/other/path")))
          (let ((str (call-with-input-file script-file-name get-string-all)))
            (with-directory-excursion directory
              (delete-file "foo"))
@@ -235,13 +234,11 @@ print('hello world')"))
          (lambda (port)
            (format port "This is not a script")))
        (chmod script-file-name #o777)
-       (catch 'srfi-34
-         (lambda ()
-           (wrap-script script-file-name
-                        #:guile "MYGUILE"
-                        `("GUIX_FOO" prefix ("/some/path"
-                                             "/some/other/path"))))
-         (lambda (type obj)
-           (wrap-error? obj)))))))
+       (guard (c ((wrap-error? c) #t))
+         (wrap-script script-file-name
+                      #:guile "MYGUILE"
+                      `("GUIX_FOO" prefix ("/some/path"
+                                           "/some/other/path")))
+         #f)))))
 
 (test-end)