~ruther/guix-local

a00ffdaa17c7ac96bb86734bac08a90c7785c98a — Cyril Roelandt 11 years ago 8202a51
guix lint: Make sure a synopsis cannot start with a lower-case article.

* guix/scripts/lint.scm (check-start-article): use "string-ci=?" instead of
  "string=?".
* tests/lint.scm ("synopsis: starts with 'a'",
  "synopsis: starts with 'an'"): New tests.
2 files changed, 20 insertions(+), 2 deletions(-)

M guix/scripts/lint.scm
M tests/lint.scm
M guix/scripts/lint.scm => guix/scripts/lint.scm +2 -2
@@ 148,8 148,8 @@ Run a set of checkers on the specified package; if none is specified, run the ch
                      'synopsis)))

  (define (check-start-article synopsis)
   (if (or (string=? (string-take synopsis 2) "A ")
           (string=? (string-take synopsis 3) "An "))
   (if (or (string-ci=? (string-take synopsis 2) "A ")
           (string-ci=? (string-take synopsis 3) "An "))
       (emit-warning package
                     "no article allowed at the beginning of the synopsis"
                     'synopsis)))

M tests/lint.scm => tests/lint.scm +18 -0
@@ 97,6 97,24 @@
                        (check-synopsis-style pkg))))
                    "no article allowed at the beginning of the synopsis")))

(test-assert "synopsis: starts with 'a'"
  (->bool
   (string-contains (call-with-warnings
                      (lambda ()
                        (let ((pkg (dummy-package "x"
                                     (synopsis "a bad synopsis"))))
                        (check-synopsis-style pkg))))
                    "no article allowed at the beginning of the synopsis")))

(test-assert "synopsis: starts with 'an'"
  (->bool
   (string-contains (call-with-warnings
                      (lambda ()
                        (let ((pkg (dummy-package "x"
                                     (synopsis "an awful synopsis"))))
                        (check-synopsis-style pkg))))
                    "no article allowed at the beginning of the synopsis")))

(test-assert "synopsis: too long"
  (->bool
   (string-contains (call-with-warnings