From 751f10e180994db6c0df722c2b226e174d3b7a28 Mon Sep 17 00:00:00 2001 From: Eric Bavier 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 +;;; +;;; 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 . + +(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