summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2018-12-21 17:48:55 +0530
committerArun Isaac <arunisaac@systemreboot.net>2018-12-24 08:15:17 +0530
commit0865d8a8f6c229fef5bcba647cc7b37c2f3d3dae (patch)
tree25d8096d41012cb8395a10eb72ead08cdc455f2f /tests
parent450226ebc1b2611ff62469d314e7ca2973bbf131 (diff)
downloadpatches-0865d8a8f6c229fef5bcba647cc7b37c2f3d3dae.tar
patches-0865d8a8f6c229fef5bcba647cc7b37c2f3d3dae.tar.gz
guix: lint: Check for source URIs redirecting to GitHub.
* guix/scripts/lint.scm (check-github-uri): New procedure. (%checkers): Add it. * doc/guix.texi (Invoking guix lint): Document it. * tests/lint.scm ("github-url", "github-url: one suggestion"): New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/lint.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/lint.scm b/tests/lint.scm
index 300153e24e..d4aa7c0e8e 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2017 Alex Kost <alezost@gmail.com>
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -669,6 +670,33 @@
(check-mirror-url (dummy-package "x" (source source)))))
"mirror://gnu/foo/foo.tar.gz"))
+(test-assert "github-url"
+ (string-null?
+ (with-warnings
+ (with-http-server 200 %long-string
+ (check-github-url
+ (dummy-package "x" (source
+ (origin
+ (method url-fetch)
+ (uri (%local-url))
+ (sha256 %null-sha256)))))))))
+
+(let ((github-url "https://github.com/foo/bar/bar-1.0.tar.gz"))
+ (test-assert "github-url: one suggestion"
+ (string-contains
+ (with-warnings
+ (with-http-server (301 `((location . ,(string->uri github-url)))) ""
+ (let ((initial-uri (%local-url)))
+ (parameterize ((%http-server-port (+ 1 (%http-server-port))))
+ (with-http-server (302 `((location . ,(string->uri initial-uri)))) ""
+ (check-github-url
+ (dummy-package "x" (source
+ (origin
+ (method url-fetch)
+ (uri (%local-url))
+ (sha256 %null-sha256))))))))))
+ github-url)))
+
(test-assert "cve"
(mock ((guix scripts lint) package-vulnerabilities (const '()))
(string-null?