From 50f5c46d0674eb68201c56bef17b2a41c7744404 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Thu, 10 Sep 2015 15:34:58 -0500 Subject: guix: lint: Check for meaningful origin file names. * guix/scripts/lint.scm (check-source-file-name): New procedure. (%checkers): Add 'source-file-name' checker. * tests/lint.scm ("source-file-name", "source-file-name: v prefix") ("source-file-name: valid", "source-file-name: bad checkout") ("source-file-name: good checkout"): New tests. * doc/guix.texi (Invoking guix lint): Mention file name check. --- tests/lint.scm | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) (limited to 'tests/lint.scm') diff --git a/tests/lint.scm b/tests/lint.scm index ac47dbb768..76040c1f3e 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013 Cyril Roelandt -;;; Copyright © 2014 Eric Bavier +;;; Copyright © 2014, 2015 Eric Bavier ;;; Copyright © 2014, 2015 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. @@ -21,6 +21,7 @@ (define-module (test-lint) #:use-module (guix tests) #:use-module (guix download) + #:use-module (guix git-download) #:use-module (guix build-system gnu) #:use-module (guix packages) #:use-module (guix scripts lint) @@ -398,6 +399,83 @@ requests." (check-home-page pkg)))) "not reachable: 404"))) +(test-assert "source-file-name" + (->bool + (string-contains + (with-warnings + (let ((pkg (dummy-package "x" + (version "3.2.1") + (source + (origin + (method url-fetch) + (uri "http://www.example.com/3.2.1.tar.gz") + (sha256 %null-sha256)))))) + (check-source-file-name pkg))) + "file name should contain the package name"))) + +(test-assert "source-file-name: v prefix" + (->bool + (string-contains + (with-warnings + (let ((pkg (dummy-package "x" + (version "3.2.1") + (source + (origin + (method url-fetch) + (uri "http://www.example.com/v3.2.1.tar.gz") + (sha256 %null-sha256)))))) + (check-source-file-name pkg))) + "file name should contain the package name"))) + +(test-assert "source-file-name: bad checkout" + (->bool + (string-contains + (with-warnings + (let ((pkg (dummy-package "x" + (version "3.2.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "http://www.example.com/x.git") + (commit "0"))) + (sha256 %null-sha256)))))) + (check-source-file-name pkg))) + "file name should contain the package name"))) + +(test-assert "source-file-name: good checkout" + (not + (->bool + (string-contains + (with-warnings + (let ((pkg (dummy-package "x" + (version "3.2.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "http://git.example.com/x.git") + (commit "0"))) + (file-name (string-append "x-" version)) + (sha256 %null-sha256)))))) + (check-source-file-name pkg))) + "file name should contain the package name")))) + +(test-assert "source-file-name: valid" + (not + (->bool + (string-contains + (with-warnings + (let ((pkg (dummy-package "x" + (version "3.2.1") + (source + (origin + (method url-fetch) + (uri "http://www.example.com/x-3.2.1.tar.gz") + (sha256 %null-sha256)))))) + (check-source-file-name pkg))) + "file name should contain the package name")))) + (test-skip (if %http-server-socket 0 1)) (test-equal "source: 200" "" -- cgit v1.2.3