From c10526672e515f07c92dc447bbc592808f67238e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 12 Jul 2020 22:41:09 +0200 Subject: lint: source: Validate URLs of Git references. Until now the 'source' checker would look at URL for 'url-fetch' origins but not for 'git-fetch' origins. * guix/lint.scm (check-source): Add case for 'git-reference?'. * tests/lint.scm ("source, git-reference: 301 -> 200"): New test. --- tests/lint.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/lint.scm b/tests/lint.scm index ac174f9f23..83becb655a 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -697,6 +697,26 @@ (and (? lint-warning?) second-warning)) (lint-warning-message second-warning))))))))) +(test-skip (if (http-server-can-listen?) 0 1)) +(test-equal "source, git-reference: 301 -> 200" + "permanent redirect from http://localhost:10000/foo/bar to http://localhost:9999/foo/bar" + (with-http-server `((200 ,%long-string)) + (let* ((initial-url (%local-url)) + (redirect (build-response #:code 301 + #:headers + `((location + . ,(string->uri initial-url)))))) + (parameterize ((%http-server-port (+ 1 (%http-server-port)))) + (with-http-server `((,redirect "")) + (let ((pkg (dummy-package + "x" + (source (origin + (method git-fetch) + (uri (git-reference (url (%local-url)) + (commit "v1.0.0"))) + (sha256 %null-sha256)))))) + (single-lint-warning-message (check-source pkg)))))))) + (test-skip (if (http-server-can-listen?) 0 1)) (test-equal "source: 301 -> 404" "URI http://localhost:10000/foo/bar not reachable: 404 (\"Such is life\")" -- cgit v1.2.3