From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4AE6AnxvqGIxfQAAbAwnHQ (envelope-from ) for ; Tue, 14 Jun 2022 13:22:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 6OkhAnxvqGKDIgAA9RJhRA (envelope-from ) for ; Tue, 14 Jun 2022 13:22:36 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 366DF3910B for ; Tue, 14 Jun 2022 13:22:35 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3D2065F72D; Tue, 14 Jun 2022 11:22:32 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 32C2E5F702 for ; Tue, 14 Jun 2022 11:22:29 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id EB7F55FBD7; Tue, 14 Jun 2022 07:22:27 -0400 (EDT) Received: (nullmailer pid 1094104 invoked by uid 1000); Tue, 14 Jun 2022 11:22:26 -0000 From: David Bremner To: David Bremner , erik colson , notmuch@notmuchmail.org Subject: [PATCH 1/2] test/sexp: add known broken tests for macro param inside rx/wildcard Date: Tue, 14 Jun 2022 08:22:16 -0300 Message-Id: <20220614112217.1094083-1-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <874k0oz9uq.fsf@tethera.net> References: <874k0oz9uq.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: D5JURBYHAN36PY72JOWIXDRNQBKBVLRL X-Message-ID-Hash: D5JURBYHAN36PY72JOWIXDRNQBKBVLRL X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655205755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=kzcSv65Q2G8xKKtkVPRJgAlwsjItyUJEf92rCJP/XiE=; b=ixkL+ZvvUxhMxdjo0Qeqx7DlhIsNHHIVztbZZeqe3xVC2aGWhZrmgyIVxitX5JEphl0sXR j6HRPQ957LitXSKGvCi+kE0bYNITRBBQfzwgz8XuIT1/MZUQyjYupjGzlyQPbS/Kwvrw/3 Q5kk5hVnhQRDaE+zQI3DhQSoI42B934Ls6k97R1nzXjHI55nH+48dBMytpdI0BDadq43dD rFeH3fmgWHcRHwv1AcwJSH1e9FaKNpkM+iUFsWBs4yjpSKOyivTBJ/VLXq6rpyD77EHIzH H5/LOsXs1D7LIkcsa7WHdRoZQ6uZhB6Iak4uZqj8hqWdzMXf5K6264kzJcEfMw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655205755; a=rsa-sha256; cv=none; b=Fha11BO8+MQ1iJM5h6cvqKGqkkTp0/cdE8497FON9v4hJz3g75d5/gNsG/fP65hslCCqft ht+Fl4Sy+ffTBy9P1HpusQHFfRHWOg/24ek5LnqWUJZThmajVLXnHcnzHwjb75UJ4NpQRb xRdiBSGK3yA+eUxjvZ4PbkeOJy1cKQQ6javA0MyoQp8TE63deil0+6NZhDYo85L4SgieX6 CSGVVIRiwov2nenXBX2Eb2gLqvhH9aUx+gOZsP+KVu/p8C6XpYggQWSleC4Mh4ioizB9tL ABHhuPO4JEeGH1N4Vfg1ubb5kHW3afnV2eDtAeJpI2w4nP5IB5bGEW8UMZQ7sQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.11 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 366DF3910B X-Spam-Score: -1.11 X-Migadu-Scanner: scn1.migadu.com X-TUID: mpvo8da0mShh These tests replicate the problem reported by Eric Colson [1] (for the regex case). [1]: id:87o7yxqxy6.fsf@code.pm --- test/T081-sexpr-search.sh | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh index da819190..d28e5b76 100755 --- a/test/T081-sexpr-search.sh +++ b/test/T081-sexpr-search.sh @@ -1115,6 +1115,26 @@ too many arguments to macro EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "Saved Search: bad parameter syntax 5" +test_subtest_known_broken +notmuch config set squery.Bad5 '(macro (thing) (tag (rx ,thing)))' +notmuch search --query=sexp '(Bad5 (1 2))' >OUTPUT 2>&1 +cat < EXPECTED +notmuch search: Syntax error in query +'rx' expects single atom as argument +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "Saved Search: bad parameter syntax 6" +test_subtest_known_broken +notmuch config set squery.Bad6 '(macro (thing) (tag (starts-with ,thing)))' +notmuch search --query=sexp '(Bad6 (1 2))' >OUTPUT 2>&1 +cat < EXPECTED +notmuch search: Syntax error in query +'starts-with' expects single atom as argument +EOF +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "Saved Search: macro without body" notmuch config set squery.Bad3 '(macro (a b))' notmuch search --query=sexp '(Bad3)' >OUTPUT 2>&1 @@ -1166,6 +1186,20 @@ notmuch config set squery.TagSubject2 '(macro (tagname subj) (and (tag ,tagname notmuch search --query=sexp '(TagSubject2 inbox maildir)' | notmuch_search_sanitize > OUTPUT test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "macro in regex" +test_subtest_known_broken +notmuch search tag:inbox and date:2009-11-17 | notmuch_search_sanitize > EXPECTED +notmuch config set squery.D '(macro (tagname) (and (date 2009-11-17) (tag (rx ,tagname))))' +notmuch search --query=sexp '(D inbo)' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "macro in wildcard" +test_subtest_known_broken +notmuch search tag:inbox and date:2009-11-17 | notmuch_search_sanitize > EXPECTED +notmuch config set squery.W '(macro (tagname) (and (date 2009-11-17) (tag (starts-with ,tagname))))' +notmuch search --query=sexp '(W inbo)' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + test_begin_subtest "nested macros (shadowing)" notmuch search tag:inbox and subject:maildir | notmuch_search_sanitize > EXPECTED notmuch config set squery.Inner '(macro (x) (subject ,x))' @@ -1183,6 +1217,22 @@ undefined parameter y EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "nested macros (shadowing, regex)" +test_subtest_known_broken +notmuch search tag:/inbo/ and subject:/Maildi/ | notmuch_search_sanitize > EXPECTED +notmuch config set squery.Inner3 '(macro (x) (subject (rx ,x)))' +notmuch config set squery.Outer3 '(macro (x y) (and (tag (rx ,x)) (Inner3 ,y)))' +notmuch search --query=sexp '(Outer3 inbo Maildi)' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "nested macros (shadowing, wildcard)" +test_subtest_known_broken +notmuch search tag:inbox and subject:maildir | notmuch_search_sanitize > EXPECTED +notmuch config set squery.Inner4 '(macro (x) (subject (starts-with ,x)))' +notmuch config set squery.Outer4 '(macro (x y) (and (tag (starts-with ,x)) (Inner4 ,y)))' +notmuch search --query=sexp '(Outer4 inbo maildi)' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + test_begin_subtest "combine macro and user defined header" notmuch config set squery.About '(macro (name) (or (subject ,name) (List ,name)))' notmuch search subject:notmuch or List:notmuch | notmuch_search_sanitize > EXPECTED -- 2.35.2