On Thu, 20 Apr 2017 15:15:46 -0400
Leo Famulari <l...@famulari.name> wrote:

> On Tue, May 19, 2015 at 01:34:10AM +0200, Cyril Roelandt wrote:
> > * list-useless-patches.sh: New file.
> > * Makefile.am (check-for-useless-patches): New target.  
> 
> We should make use of this somehow!

Attached is my own shot at this.  It does not make use of git, so
should be fine as a regular test.  It doesn't check whether the files
listed in dist_patch_DATA actually exist, because `make dist` already
checks that.  I suppose it might be nice, if git a git checkout, to
check whether the used patches are all known to git...

Anyhow, currently the test fails with the following log output:

-----------BEGIN test-suite.log----------------
FAIL: tests/patches
===================

test-name: distributed patches are used
location: /home/bavier/projects/guix/tests/patches.scm:50
source:
+ (test-equal
+   "distributed patches are used"
+   '()
+   (lset-difference
+     string=?
+     distributed-patches
+     used-patches))
expected-value: ()
actual-value: 
("/home/bavier/projects/guix/gnu/packages/patches/ath9k-htc-firmware-binutils.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/ath9k-htc-firmware-gcc.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/coreutils-cut-huge-range-test.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/gawk-shell.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/gcc-libiberty-printf-decl.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/gcj-arm-mode.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/glibc-bootstrap-system.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/grub-CVE-2015-8370.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/grub-gets-undeclared.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/grub-freetype.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/guile-arm-fixes.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/icu4c-CVE-2017-7867-CVE-2017-7868.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/icu4c-reset-keyword-list-iterator.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/ldc-disable-tests.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/ldc-1.1.0-disable-dmd-tests.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/ldc-1.1.0-disable-phobos-tests.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/libgit2-use-after-free.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/libxslt-CVE-2016-4738.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/mplayer2-theora-fix.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/patchelf-rework-for-arm.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/pcre-CVE-2017-7186.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/perl-net-ssleay-disable-ede-test.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/readline-7.0-mingw.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/soprano-find-clucene.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/texlive-texmf-CVE-2016-10243.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/util-linux-CVE-2017-2616.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/xf86-video-ast-remove-mibstore.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/xf86-video-intel-compat-api.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/xf86-video-intel-glibc-2.20.patch")
result: FAIL

test-name: used patches are distributed
location: /home/bavier/projects/guix/tests/patches.scm:54
source:
+ (test-equal
+   "used patches are distributed"
+   '()
+   (lset-difference
+     string=?
+     used-patches
+     distributed-patches))
expected-value: ()
actual-value: 
("/home/bavier/projects/guix/gnu/packages/patches/python-pbr-fix-man-page-support.patch"
 "/home/bavier/projects/guix/gnu/packages/patches/jacal-fix-texinfo.patch" 
"/home/bavier/projects/guix/gnu/packages/patches/vsearch-unbundle-cityhash.patch"
 
"/home/bavier/projects/guix/gnu/packages/patches/hmmer-remove-cpu-specificity.patch")
result: FAIL
--------------END test-suite.log-----------------
From 751f10e180994db6c0df722c2b226e174d3b7a28 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bav...@member.fsf.org>
Date: Thu, 20 Apr 2017 23:17:14 -0500
Subject: [PATCH] tests: Add patch use test.

* tests/patches.scm: New test.
* Makefile.am (SCM_TESTS): Add it.
(AM_TESTS_ENVIRONMENT): Export dist_patch_DATA.
---
 Makefile.am       |  8 ++++++--
 tests/patches.scm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 tests/patches.scm

diff --git a/Makefile.am b/Makefile.am
index a997ed8b9..5cd9be814 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -307,7 +307,8 @@ SCM_TESTS =					\
   tests/scripts-build.scm			\
   tests/containers.scm				\
   tests/pack.scm				\
-  tests/import-utils.scm
+  tests/import-utils.scm			\
+  tests/patches.scm
 
 if HAVE_GUILE_JSON
 
@@ -343,7 +344,10 @@ endif BUILD_DAEMON
 
 TESTS = $(SCM_TESTS) $(SH_TESTS)
 
-AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" GUILE_AUTO_COMPILE=0
+AM_TESTS_ENVIRONMENT = \
+  abs_top_srcdir="$(abs_top_srcdir)" \
+  dist_patch_DATA="$(dist_patch_DATA)" \ #for tests/patches.scm
+  GUILE_AUTO_COMPILE=0
 
 SCM_LOG_DRIVER =				\
   $(top_builddir)/test-env --quiet-stderr	\
diff --git a/tests/patches.scm b/tests/patches.scm
new file mode 100644
index 000000000..4c5a0c44a
--- /dev/null
+++ b/tests/patches.scm
@@ -0,0 +1,54 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Eric Bavier <bav...@member.fsf.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-patches)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-64)
+  #:use-module (gnu packages)
+  #:use-module (guix packages)
+  #:use-module (guix sets)) 
+
+
+(define used-patches
+  (set->list
+   (fold-packages 
+    (lambda (package result) 
+      (set-union result 
+                 (list->set 
+                  (or (and=> (package-source package) 
+                             (lambda (o) 
+                               (filter string? ;ignore origin patches
+                                       (origin-patches o)))) 
+                      (list))))) 
+    (set))))
+
+(define distributed-patches
+  (map (λ (s) (string-append (getenv "abs_top_srcdir") "/" s))
+       (remove string-null? (string-split (getenv "dist_patch_DATA") #\space))))
+
+(test-begin "patches")
+
+(test-equal "distributed patches are used"
+  '()
+  (lset-difference string=? distributed-patches used-patches))
+
+(test-equal "used patches are distributed"
+  '()
+  (lset-difference string=? used-patches distributed-patches))
+
+(test-end)
-- 
2.12.2

Attachment: pgpGKNcXX8fdv.pgp
Description: OpenPGP digital signature

Reply via email to