On 14/01/16 22:15, Ben Woodcroft wrote:
On 14/01/16 21:30, Ricardo Wurmus wrote:
Ben Woodcroft <b.woodcr...@uq.edu.au> writes:
On 14/01/16 20:31, Ricardo Wurmus wrote:
This breaks two of the cran importer tests:

(test-equal "beautify-description: use double spacing"
    "This is a package.  It is great.  Trust me Mr. Hendrix."
    ((@@ (guix import cran) beautify-description)
     "This is a package. It is great. Trust me Mr. Hendrix."))

(test-equal "beautify-description: transform fragment into sentence"
    "This package provides a function to establish world peace"
    ((@@ (guix import cran) beautify-description)
     "A function to establish world peace"))
I just tested these with "make check" and also by ./pre-inst-env guile tests/cran.scm, and they seem to pass. Am I doing something incorrectly?

However, ironically tests/gem fails.
Turns out there was an actual bug here - the description was being used for the synopsis to so the synopsis was being inappropriately beautified.
How about moving these tests elsewhere?  (Or should they be removed?)
Ah, sorry. Should they be moved to a new file tests/import-utils? Why do
you suggest that they should be removed?
I don’t have any preference for a name.  “tests/import-utils” sounds
good to me.  If we can keep (and later enhance) the tests it would
obviously be better.  (I just meant that I wouldn’t be too sad if they
were removed for whatever reasons.)

Would you like to submit a patch to add tests/import-utils (including
adding it to SCM_TESTS in Makefile.am) and move these two test cases
there?
Happy to provide a patch fixing the gem test, and moving the (failing?) cran tests to this new file since even if they pass that is a more appropriate place for them. It'll be the weekend before I have time for this though, apologies for leaving master broken.
Attached patches, make check now passes. Do they look OK? Possibly I messed up the commit messages.

Thanks,
ben
>From 06f3c311ccab7013b030bb919a1cf40054fe9263 Mon Sep 17 00:00:00 2001
From: Ben Woodcroft <donttrust...@gmail.com>
Date: Sun, 17 Jan 2016 10:20:59 +1000
Subject: [PATCH 2/2] tests: Move beatify-description tests to import-tests.

* tests/cran.scm (beautify-description: use double spacing,
beautify-description: transform fragment into sentence). Move
from here ...
* tests/import-utils.scm: ... to here. New file.
* Makefile.am (SCM_TESTS): Add import-utils.
---
 Makefile.am            |  3 ++-
 tests/cran.scm         | 10 ----------
 tests/import-utils.scm | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 11 deletions(-)
 create mode 100644 tests/import-utils.scm

diff --git a/Makefile.am b/Makefile.am
index 6e9deeb..4fead80 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,7 +246,8 @@ SCM_TESTS =					\
   tests/cve.scm					\
   tests/file-systems.scm			\
   tests/services.scm				\
-  tests/containers.scm
+  tests/containers.scm				\
+  tests/import-utils.scm
 
 if HAVE_GUILE_JSON
 
diff --git a/tests/cran.scm b/tests/cran.scm
index 0a4a2fd..206c045 100644
--- a/tests/cran.scm
+++ b/tests/cran.scm
@@ -86,16 +86,6 @@ Date/Publication: 2015-07-14 14:15:16
   '()
   ((@@ (guix import cran) listify) simple-alist "BadList"))
 
-(test-equal "beautify-description: use double spacing"
-  "This is a package.  It is great.  Trust me Mr.  Hendrix."
-  ((@@ (guix import cran) beautify-description)
-   "This is a package. It is great. Trust me Mr. Hendrix."))
-
-(test-equal "beautify-description: transform fragment into sentence"
-  "This package provides a function to establish world peace"
-  ((@@ (guix import cran) beautify-description)
-   "A function to establish world peace"))
-
 (test-assert "description->package"
   ;; Replace network resources with sample data.
   (mock ((guix build download) url-fetch
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
new file mode 100644
index 0000000..a365847
--- /dev/null
+++ b/tests/import-utils.scm
@@ -0,0 +1,38 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Ben Woodcroft <donttrust...@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-import-utils)
+  #:use-module (guix tests)
+  #:use-module (srfi srfi-64))
+
+(test-begin "import-utils")
+
+(test-equal "beautify-description: use double spacing"
+  "This is a package.  It is great.  Trust me Mr.  Hendrix."
+  ((@@ (guix import utils) beautify-description)
+   "This is a package. It is great. Trust me Mr. Hendrix."))
+
+(test-equal "beautify-description: transform fragment into sentence"
+  "This package provides a function to establish world peace"
+  ((@@ (guix import utils) beautify-description)
+   "A function to establish world peace"))
+
+(test-end "import-utils")
+
+
+(exit (= (test-runner-fail-count (test-runner-current)) 0))
-- 
2.6.3

>From 999bbb38b868a0ae018e631debf5a3ca6e91f065 Mon Sep 17 00:00:00 2001
From: Ben Woodcroft <donttrust...@gmail.com>
Date: Sun, 17 Jan 2016 09:12:14 +1000
Subject: [PATCH 1/2] import: gem: Beautify only the description, not the
 synopsis.

* guix/import/gem.scm (make-gem-sexp): Add synopsis argument.
(gem->guix-package): Pass unbeautified synopsis to make-gem-sexp.
* tests/gem.scm: Adapt it.
---
 guix/import/gem.scm | 7 ++++---
 tests/gem.scm       | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index 3c42052..4b2a253 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -77,7 +77,7 @@ the package."
             (bytevector-u8-set! bv i (read-byte i))
             (loop (1+ i)))))))
 
-(define (make-gem-sexp name version hash home-page description
+(define (make-gem-sexp name version hash home-page synopsis description
                        dependencies licenses)
   "Return the `package' s-expression for a Ruby package with the given NAME,
 VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
@@ -101,7 +101,7 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
                          (,'unquote
                           ,(string->symbol name))))
                      dependencies)))))
-     (synopsis ,description)    ; nothing better to use
+     (synopsis ,synopsis)
      (description ,description)
      (home-page ,home-page)
      (license ,(match licenses
@@ -117,6 +117,7 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
          (let ((name         (assoc-ref package "name"))
                (version      (assoc-ref package "version"))
                (hash         (assoc-ref package "sha"))
+               (synopsis     (assoc-ref package "info")) ; nothing better to use
                (description  (beautify-description
                               (assoc-ref package "info")))
                (home-page    (assoc-ref package "homepage_uri"))
@@ -129,5 +130,5 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
                                               "runtime")))
                (licenses     (map string->license
                                   (assoc-ref package "licenses"))))
-           (make-gem-sexp name version hash home-page
+           (make-gem-sexp name version hash home-page synopsis
                           description dependencies licenses)))))
diff --git a/tests/gem.scm b/tests/gem.scm
index 9efbda3..ebce809 100644
--- a/tests/gem.scm
+++ b/tests/gem.scm
@@ -69,7 +69,7 @@
            (("bundler" ('unquote 'bundler))
             ("ruby-bar" ('unquote 'ruby-bar)))))
          ('synopsis "A cool gem")
-         ('description "A cool gem")
+         ('description "This package provides a cool gem")
          ('home-page "https://example.com";)
          ('license ('list 'expat 'asl2.0)))
        #t)
-- 
2.6.3

Reply via email to