X-Envelope-From: notmuch-bounces@notmuchmail.org  Sun Aug 30 16:06:28 2026
Return-Path: <notmuch-bounces@notmuchmail.org>
X-Original-To: nmbug@yantan.tethera.net
Delivered-To: nmbug@yantan.tethera.net
Received: from yantan.tethera.net (localhost [127.0.0.1])
	by mail.notmuchmail.org (Postfix) with ESMTP id 0D7A85F86D;
	Sun, 30 Aug 2026 16:06:28 +0000 (UTC)
Received: from mail.sindominio.net (mail.sindominio.net [IPv6:2a01:4f8:10b:1e2f::4])
	by mail.notmuchmail.org (Postfix) with ESMTPS id 42BD75E50E
	for <notmuch@notmuchmail.org>; Sun, 30 Aug 2026 16:06:23 +0000 (UTC)
Received: from [127.0.0.1] (localhost [127.0.0.1])
	 by lesnaus.sindominio.net with ESMTP id CE82A12A012F
	for <notmuch@notmuchmail.org>; Sun, 30 Aug 2026 17:57:19 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 lesnaus.sindominio.net CE82A12A012F
Authentication-Results: lesnaus.sindominio.net;
	dkim=pass (4096-bit key; unprotected) header.d=sindominio.net header.i=@sindominio.net header.b="Dboofait";
	dkim-atps=neutral
Received: from mail.sindominio.net ([127.0.0.1])
	by localhost (lesnaus.sindominio.net [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 5SE_qTs_Waju; Sun, 30 Aug 2026 17:57:17 +0200 (CEST)
Received: from [127.0.0.1] (localhost [127.0.0.1])
	 by lesnaus.sindominio.net with ESMTPSA id 7914412A02AF;
	Sun, 30 Aug 2026 17:57:17 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 lesnaus.sindominio.net 7914412A02AF
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sindominio.net;
	s=mail; t=1788105437;
	bh=dL02RC/BChtZIE5tbmHONUtdbVN/vSnQGRik7tJSbFk=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=DboofaitHJTBELgxr0Xp0ReSvp/D5imhCoIkT0DoaKMCb2w6q7h+tUj41UdK5G+XL
	 8bnSTvfq/Mowg87INhxiKHDvql00Ui/e0ix7sNHW5LzR0SJceIycYkMZPjYj9j4saD
	 XcRYOVnYjChaYSXnezIHlHcYgOu4Zq8Xo+Qd1qKbr/WF9rj6PFnkC11Wxpf+b4s38U
	 VyxB67+MiCYAJhtCjYIowadTg/RVRzViNxMJBMQ2UQ3jPrnH0tAphJWqSEojl75sUv
	 NaeWNKri7hIT5UO14xW4Y422nAlMZNo7Jq+HaXuegEO41N2Y6zP6HM0+OVgIbETl/2
	 xBCfsaqMfbWTPiPG3UjyWGLiofxd0cNr8JBD0np3f8bejN+2kHV9lWDKCYD/tAJ+7X
	 OA0IXjAyN5Ik6K/uv0qHVMoqGgE0vr5J55odh2hXwZDvCUliat/6eHq2cJY9CBqVuB
	 v+cOi66MRWit5ZMjdubPf3Jyapg0esUuRxycuPsf07OyNL6qCE/ENDXOqlZWRyqeLg
	 DJZG/OobIRsDNBLwS8gS50QHKNQscmUUPNqjVDgwbnw0MIlh/PhbGbLONsWhqoMeAo
	 s9dK1v7yFMgY2RNj1v24FWYK5Az1BAP/N7J8DEgIRnA5FAJbh+OR5iIvrX6mR4j78y
	 kJqW/gRa7J8Sqo++yaxvSF2o=
From: inwit <inwit@sindominio.net>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 3/3] test: add tests for --profile CLI option
Date: Sun, 30 Aug 2026 17:44:27 +0200
Message-ID: <20260830155628.221888-5-inwit@sindominio.net>
In-Reply-To: <20260830155628.221888-2-inwit@sindominio.net>
References: <20260830155628.221888-2-inwit@sindominio.net>
MIME-Version: 1.0
Message-ID-Hash: RS4GOUVNAODYDZNRB62FTHDRJZ7HOSAN
X-Message-ID-Hash: RS4GOUVNAODYDZNRB62FTHDRJZ7HOSAN
X-MailFrom: inwit@sindominio.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
CC: inwit <inwit@sindominio.net>
X-Mailman-Version: 3.3.3
Precedence: list
List-Id: "Use and development of the notmuch mail system." <notmuch.notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Owner: <mailto:notmuch-owner@notmuchmail.org>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Subscribe: <mailto:notmuch-join@notmuchmail.org>
List-Unsubscribe: <mailto:notmuch-leave@notmuchmail.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Add coverage for the new --profile flag:

  - T035-read-config.sh: saved-query tests exercising both the XDG
    path and the home fallback path. Count expectations are derived
    from the current corpus at test time rather than hard-coded.

  - T055-path-config.sh: XDG+cli-profile variant in the existing
    path-config loop. The setup function exercises --profile for
    config set operations; the NOTMUCH_PROFILE env var is set for
    the remaining loop operations (count, tag, address, dump,
    restore, reindex, new, show, reply, insert, compact, config).

Signed-off-by: inwit <inwit@sindominio.net>
---
 test/T035-read-config.sh | 46 ++++++++++++++++++++++++++++++++++++++++
 test/T055-path-config.sh | 25 +++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index ac0f420b..17433148 100755
--- a/test/T035-read-config.sh
+++ b/test/T035-read-config.sh
@@ -22,6 +22,19 @@ xdg_config () {
     unset NOTMUCH_CONFIG
 }
 
+xdg_config_cli () {
+    local dir
+    local profile=${1:-default}
+    backup_config
+    dir="${HOME}/.config/notmuch/${profile}"
+    rm -rf "$dir"
+    mkdir -p "$dir"
+    CONFIG_PATH=$dir/config
+    mv "${NOTMUCH_CONFIG}" "${CONFIG_PATH}"
+    unset NOTMUCH_CONFIG
+    unset NOTMUCH_PROFILE
+}
+
 restore_config () {
     local test_name=$(basename $0 .sh)
     export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
@@ -473,4 +486,37 @@ output=$(NOTMUCH_NEW --debug)
 restore_config
 test_expect_equal "$output" "Added 1 new message to the database."
 
+test_begin_subtest "count with saved query from config file (xdg+cli-profile)"
+query_name="test${RANDOM}"
+xdg_config_cli work
+total=$(notmuch --profile=work count '*')
+notmuch --profile=work count query:$query_name > OUTPUT
+printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
+notmuch --profile=work count query:$query_name >> OUTPUT
+cat <<EOF > EXPECTED
+0
+$total
+EOF
+restore_config
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "count with saved query from config file (cli-profile, home fallback)"
+query_name="test${RANDOM}"
+profile_name="p${RANDOM}"
+backup_config
+cp "${NOTMUCH_CONFIG}" "${HOME}/.notmuch-config.${profile_name}"
+unset NOTMUCH_CONFIG
+unset NOTMUCH_PROFILE
+total=$(notmuch --profile=$profile_name count '*')
+notmuch --profile=$profile_name count query:$query_name > OUTPUT
+printf "\n[query]\n${query_name} = tag:inbox\n" >> ${HOME}/.notmuch-config.${profile_name}
+notmuch --profile=$profile_name count query:$query_name >> OUTPUT
+rm -f ${HOME}/.notmuch-config.${profile_name}
+cat <<EOF > EXPECTED
+0
+$total
+EOF
+restore_config
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 4d1edec0..3bf29c25 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -92,6 +92,25 @@ xdg_config () {
     notmuch --config=${CONFIG_PATH} config set database.path
 }
 
+xdg_config_cli () {
+    local profile=${1:-default}
+    local dir
+    backup_config
+    dir="${HOME}/.local/share/notmuch/${profile}"
+    DATABASE_PATH="${dir}"
+    rm -rf "$dir"
+    mkdir -p "$dir"
+    dir="${HOME}/.config/notmuch/${profile}"
+    mkdir -p "${dir}"
+    CONFIG_PATH=$dir/config
+    mv "${NOTMUCH_CONFIG}" "$CONFIG_PATH"
+    unset NOTMUCH_CONFIG
+    XAPIAN_PATH="${DATABASE_PATH}/xapian"
+    notmuch --profile=$profile config set database.mail_root ${TMP_DIRECTORY}/mail
+    notmuch --profile=$profile config set database.path
+    export NOTMUCH_PROFILE=$profile
+}
+
 mailroot_only_config () {
     local dir
 
@@ -105,7 +124,7 @@ mailroot_only_config () {
     mv mail/.notmuch/xapian $DATABASE_PATH
 }
 
-for config in traditional split XDG XDG+profile symlink home_mail maildir_env mailroot_only; do
+for config in traditional split XDG XDG+profile XDG+cli-profile symlink home_mail maildir_env mailroot_only; do
     #start each set of tests with an known set of messages
     add_email_corpus
 
@@ -126,6 +145,10 @@ for config in traditional split XDG XDG+profile symlink home_mail maildir_env ma
 	    xdg_config ${RANDOM}
 	    mv mail/.notmuch/xapian $DATABASE_PATH
 	    ;;
+	XDG+cli-profile)
+	    xdg_config_cli ${RANDOM}
+	    mv mail/.notmuch/xapian $DATABASE_PATH
+	    ;;
 	symlink)
 	    symlink_config
 	    ;;
-- 
2.53.0

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org
