From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0Po3OVTNqWL+7QAAbAwnHQ (envelope-from ) for ; Wed, 15 Jun 2022 14:15:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4PgpOVTNqWLnngAAauVa8A (envelope-from ) for ; Wed, 15 Jun 2022 14:15:16 +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 57520857D for ; Wed, 15 Jun 2022 14:15:16 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7B00C5E540; Wed, 15 Jun 2022 12:15:02 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id C67855E228 for ; Wed, 15 Jun 2022 12:14:58 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 134E15FBD7; Wed, 15 Jun 2022 08:14:57 -0400 (EDT) Received: (nullmailer pid 1465803 invoked by uid 1000); Wed, 15 Jun 2022 12:14:54 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v2 1/2] test/sexp: add known broken tests for macro param inside rx/wildcard Date: Wed, 15 Jun 2022 09:14:46 -0300 Message-Id: <20220615121447.1465635-2-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220615121447.1465635-1-david@tethera.net> References: <20220615121447.1465635-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: T4LJC3JCIPGQLP3ZQN77A2DE7HTQJTT3 X-Message-ID-Hash: T4LJC3JCIPGQLP3ZQN77A2DE7HTQJTT3 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=1655295316; 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=nicAdBtlzgogAj6EYY7RkbjLRmikUD7QLJVtRWkS+ceC2I5sefhuJflmGvUq1k+Ku+yUBp /goea34CYcxT1pwKFiLnXDwSzzK/TrfuQZMhJa0VjDzHYBJ/eUCwyVwfrRIpCWAZ+ZLW6E tXuqvmCv74ie5xpzHmm3c7E794yJwv0Lu5EMXHi06k+6LgA7034FwOxd8EvE7Q9Wr6sZSM Z1ykLtzXQ6CEPAFkKA3n1UhIjQQU8A1vxZh4V6h+aCCf/Gfgi1uZjmIa0tPt8gp5whsD9C 7kx36sqME2nUNIfmmFBQKX+9487Ba66uzIiqmV9eh1ttFg0x8zWyS0c5LegLLw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655295316; a=rsa-sha256; cv=none; b=LbszojTwHrMPNvA2+7evafXpQ32i/t8PExeLj1fLQp6kF2QmZcf7jxAWyJ+gp5ol/X+XVS LY2ZF8oQ0yqmDU+oHM3tUj3iQWsxg0kJaMeelYXVh+0KRTrPrlmTW0Z8HOfLO82AzqYiLp JqFX87FOVCN34xYWd486dgZNNCME5VTprjfaivAr//eESYJHX246AwXorvAsNFf4nuGzQD gI/5Wylr8bTB+GihvDs1BxchXxLQiuSHqUOYwOKSh58QEWgJUMfFMJeIQo0SdhaYQiyag5 g36J623FQuij2p2Ud5GGVrwoh6ZLXkmjCCIKZI22GIKsTtUTupdSSPb2ezWa8g== 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.13 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: 57520857D X-Spam-Score: -1.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: h3huNN/tRhzL 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