;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Ludovic Courtès ;;; Copyright © 2020 Giacomo Leidi ;;; ;;; 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-glob) #:use-module (guix glob) #:use-module (srfi srfi-64)) (test-begin "glob") (define-syntax test-string->sglob (syntax-rules (=>) ((_ pattern => result rest ...) (begin (test-equal (format #f "string->sglob, ~s" pattern) result (string->sglob pattern)) (test-string->sglob rest ...))) ((_) #t))) (define-syntax test-glob-match (syntax-rules (matches and not) ((_ (pattern-string matches strings ... (and not others ...)) rest ...) (begin (test-assert (format #f "glob-match? ~s" pattern-string) (let ((pattern (string->compiled-sglob pattern-string))) (and (glob-match? pattern strings) ... (not (glob-match? pattern others)) ...))) (test-glob-match rest ...))) ((_) #t))) (test-string->sglob "foo" => "foo" "?foo*" => '(? "foo" *) "foo[1-5]" => '("foo" (range #\1 #\5)) "foo[abc]bar" => '("foo" (set #\a #\b #\c) "bar") "foo[a[b]c]bar" => '("foo" (set #\a #\[ #\b #\] #\c) "bar") "[123]x" => '((set #\1 #\2 #\3) "x") "[a-z]" => '((range #\a #\z)) "**/*.scm" => '(**/ * ".scm")) (test-glob-match ("foo" matches "foo" (and not "foobar" "barfoo")) ("foo*" matches "foo" "foobar" (and not "xfoo")) ("foo??bar" matches "fooxxbar" "fooZZbar" (and not "foobar" "fooxxxbar" "fooxxbarzz")) ("foo?" matches "foox" (and not "fooxx")) ("ab[0-9]c" matches "ab0c" "ab7c" "ab9c" (and not "ab-c" "ab00c" "ab3")) ("ab[cdefg]" matches "abc" "abd" "abg" (and not "abh" "abcd" "ab[")) ("foo/**/*.scm" matches "foo/bar/baz.scm" "foo/bar.scm" "foo/bar/baz/zab.scm" (and not "foo/bar/baz.java" "foo/bar.smc"))) (test-end "glob") (Expand)Author 2018-07-22gnu: pcre: Update to 8.42....Marius Bakke 2018-07-19gnu: pcre: Install static libraries to separate output....Marius Bakke 2018-02-28gnu: pcre2: Update to 10.31....Tobias Geerinckx-Rice 2018-01-19Merge branch 'master' into core-updatesMark H Weaver 2018-01-13gnu: pcre: Use HTTPS for home pages....Tobias Geerinckx-Rice 2017-10-01gnu: pcre: Update to 8.41....Efraim Flashner 2017-07-23Merge branch 'master' into core-updatesLeo Famulari 2017-07-20gnu: pcre: Update replacement to 8.41 [fixes CVE-2017-{7244,7245,7246}]....Leo Famulari 2017-07-03packages: Mark 'replacement' as an "innate" field....Ludovic Courtès 2017-05-24Merge branch 'master' into core-updatesRicardo Wurmus 2017-05-07gnu: pcre2: Fix build configuration for pcre2....Leo Famulari 2017-05-07gnu: pcre2: Fix CVE-2017-8786....Leo Famulari 2017-04-10gnu: pcre: Patch CVE-2017-7186....Ludovic Courtès 2017-04-10gnu: pcre2: Patch CVE-2017-7186....Ludovic Courtès 2017-03-09Merge branch 'master' into core-updatesLudovic Courtès 2017-03-07gnu: pcre2: Update to 10.23....Marius Bakke 2017-01-23gnu: pcre: Update to 8.40....Leo Famulari