[bug#75151,v2] import/utils: beautify-description: Validate argument
Commit Message
* guix/import/utils.scm (beautify-description): Fix broken check for
non-strings. Add a check for empty strings.
* tests/import-utils.scm: Add two tests.
Change-Id: Idf86df02aeb850fcc8808b7c9251082c1f816656
---
Resending after rebasing this.
guix/import/utils.scm | 8 ++++----
tests/import-utils.scm | 10 ++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
base-commit: 666a6cfd88b3e5106a9180e06ea128db8084be0e
Comments
Morgan Smith <Morgan.J.Smith@outlook.com> writes:
> * guix/import/utils.scm (beautify-description): Fix broken check for
> non-strings. Add a check for empty strings.
> * tests/import-utils.scm: Add two tests.
>
> Change-Id: Idf86df02aeb850fcc8808b7c9251082c1f816656
Applied, thanks!
@@ -331,9 +331,9 @@ (define* (beautify-description description #:optional (length 80))
"Improve the package DESCRIPTION by turning a beginning sentence fragment into
a proper sentence and by using two spaces between sentences, and wrap lines at
LENGTH characters."
- (unless (string? description)
- (G_ "This package lacks a description. Run \
-\"info '(guix) Synopses and Descriptions'\" for more information."))
+ (if (or (not (string? description)) (string=? (string-trim-both description) ""))
+ (G_ "This package lacks a description. Run \
+\"info '(guix) Synopses and Descriptions'\" for more information.")
(let* ((fix-word
(lambda (word)
@@ -410,7 +410,7 @@ (define* (beautify-description description #:optional (length 80))
". "
". ")))
'post)
- length)))
+ length))))
(define (beautify-synopsis synopsis)
"Improve the package SYNOPSIS."
@@ -31,6 +31,16 @@ (define-module (test-import-utils)
(test-begin "import-utils")
+(test-equal "beautify-description: empty string"
+ "This package lacks a description. Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."
+ (beautify-description ""))
+
+(test-equal "beautify-description: not a string"
+ "This package lacks a description. Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."
+ (beautify-description '()))
+
(test-equal "beautify-description: use double spacing"
"\
Trust me Mr. Hendrix, M. Night Shyamalan et al. \