X-Envelope-From: notmuch-bounces@notmuchmail.org  Sat May  9 15:59:54 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 E7CDD5F884;
	Sat,  9 May 2026 15:59:53 +0000 (UTC)
Received: from mail.sindominio.net (mail.sindominio.net [IPv6:2a01:4f8:10b:1e2f::4])
	by mail.notmuchmail.org (Postfix) with ESMTPS id 445325F7D1
	for <notmuch@notmuchmail.org>; Sat,  9 May 2026 15:59:48 +0000 (UTC)
Received: from [127.0.0.1] (localhost [127.0.0.1])
	 by lesnaus.sindominio.net with ESMTP id ACE2E12A45D6
	for <notmuch@notmuchmail.org>; Sat,  9 May 2026 17:53:17 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 lesnaus.sindominio.net ACE2E12A45D6
Authentication-Results: lesnaus.sindominio.net;
	dkim=pass (4096-bit key; unprotected) header.d=sindominio.net header.i=@sindominio.net header.b="LWwsFA4w";
	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 cO5EYCMJxD4P; Sat,  9 May 2026 17:53:15 +0200 (CEST)
Received: from [127.0.0.1] (localhost [127.0.0.1])
	 by lesnaus.sindominio.net with ESMTPSA id BDFE212A45D5;
	Sat,  9 May 2026 17:53:14 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 lesnaus.sindominio.net BDFE212A45D5
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sindominio.net;
	s=mail; t=1778341995;
	bh=xpvDKWhPkEKrf/WbPGE3u9c3lcIEHfypt0k4U4BWFHc=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=LWwsFA4wRFmhKiIkdwViyJnaplRgYqqkljhcJA4Db9CXFVM5L3NMnxa94w4aBabok
	 C0AONZgsV0VZsnPUrXHhEG9J+HEsKCGIIVQxecnsmOVxOgYHyhBS8BYiQDQcAznSSV
	 qUttvGZg6mpyqKMU7eN2oi6D03sgWT4ySP3tzUnCeP/cftufUMDIfMjEUvmOWkPuLO
	 QWn28j1qy8mdWknY2aM53mW1SMyiEYe0KLR0wZ4VyR6WiRTHWxjOhDubcsHRmxpTyC
	 Kl31NRO9O/FhLrD1ZH1+Ad2jetmRqkibF9Nk74JXXsq04y3kqrm9ynVf+f+IjASnib
	 80fpgWPwwqIoMClNBnkPbbagSYgEYoo9W9d+I5aQBVeTPH8o01mVRZesqtUul6lyHb
	 AXXhr8bD/dvjNDRkuEvun9bsSAENi9iMXFKmwEKQ1NKboIZ6gpFNCi5YTjAiVrVKmx
	 SGMwIQ2uIzpUaEjSUETTYEhAz50x1zrWN5IcTfaLDKnPeB0Sw0JOtqdbfqYj/u2u7Q
	 DPH+0MjINUphis3gQpffW/BhVcdEuRAIayxs/qCpSL4GpgsvkwC1W1K1QDpGTUsoKw
	 r68YUeT/YAgH82zRSP+6GbojvXSUGqDN2mw8GbRFhwXiSWbdQ6iEKZLRJz6K8U5RIQ
	 JCjuw2dh/Q9l7ZHXbxno3nok=
From: inwit <inwit@sindominio.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/3] test: add tests for --profile CLI option
Date: Sat,  9 May 2026 17:49:54 +0200
Message-ID: <20260509155257.2477368-4-inwit@sindominio.net>
In-Reply-To: <20260509155257.2477368-1-inwit@sindominio.net>
References: <20260509155257.2477368-1-inwit@sindominio.net>
MIME-Version: 1.0
Message-ID-Hash: UCHTK6KNOXTYO3ANMUMNND3RQSTRCSYD
X-Message-ID-Hash: UCHTK6KNOXTYO3ANMUMNND3RQSTRCSYD
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: lightweight saved-query tests exercising
    both the XDG path and the home fallback path.

  - 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 | 44 ++++++++++++++++++++++++++++++++++++++++
 test/T055-path-config.sh | 25 ++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index ac0f420b..bc057787 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,35 @@ 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
+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
+52
+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
+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
+52
+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..7d5b2eb9 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
