From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 iE1DDzIBlmJtIQEAbAwnHQ (envelope-from ) for ; Tue, 31 May 2022 13:51:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id qBhKDjIBlmIY5QAAG6o9tA (envelope-from ) for ; Tue, 31 May 2022 13:51:14 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 A6A2AC55D for ; Tue, 31 May 2022 13:51:13 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 701BC5F76D; Tue, 31 May 2022 11:51:10 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 9CCE25F407 for ; Tue, 31 May 2022 11:51:07 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 8CB6C5FBD7; Tue, 31 May 2022 07:51:06 -0400 (EDT) Received: (nullmailer pid 2446067 invoked by uid 1000); Tue, 31 May 2022 11:51:04 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/3] test: initial tests for external commands Date: Tue, 31 May 2022 08:50:58 -0300 Message-Id: <20220531115100.2446050-1-david@tethera.net> X-Mailer: git-send-email 2.35.2 MIME-Version: 1.0 Message-ID-Hash: F2UEJRVX2FJPXKZYGCSEKXBEGIGHKPWO X-Message-ID-Hash: F2UEJRVX2FJPXKZYGCSEKXBEGIGHKPWO 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=1653997874; 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:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=vE4v0s41avlZuVpm/+c/T/BQ7G7wCEojBIgwUVx6gB8=; b=ml+pvz6Pw1dY0Hh5wJJeI4E26qhKaLwViTgsa4TopdsEIonS640D1aC5BF3XhjpYE3r2iF +G4fOwW4gDqYDa+arawGiDvbC7/CBeYkygTwbiVWBSfGUTlzPe0iMoNXz06+Wc0Qa+uTfO x6BZZT1/2wAPKTii+UBwTphWgyGA9L2lUdq14xXDEJgxiUMefs3Y9cZrYY/nRkm78gAE5r eqSpbMjrJNSJU6hXEpb6VQWxDFCsZ3ZnooTpNUpP63YKbPGmceN6XsEkV1thMT9mT8Fmbr VuDjqmRCxs9xSWtyt2lek+mOKVAb7HpQ/2yUpmdzpuRHA43I3KYeZdn5CyeUTQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653997874; a=rsa-sha256; cv=none; b=r0oNtriM377EdmGL4NdBfWKaIoFsj2Grd1sh7C2FprMuoj21wLzRV+Vj90Ia5hLlG1G09+ MA1Ljge/UewEvomEXuU78UTHVAxpz5VvE0APgjZrqm9k1S/3zb1fjtP/7YluTA8EGx9b9m S9QHaTVruijuFrN2U0JjSDPseYnsfWNai7VsekSq7nXEpR6BQpKJdSmmsqr0jBUWWVp5pH tbaEamE/9L2GunDBxOhJ198DlqH8gIwDj4lUi/qjZOOVCUYXYGw5YTjVPnolJR+jXQdWMt uP4rpe970sE5cKlFadta5ZoK4I5QfsIut7X2ZFHbxiUZOxSnyA5weHeReYhVdQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.02 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A6A2AC55D X-Spam-Score: -1.02 X-Migadu-Scanner: scn1.migadu.com X-TUID: TzJa5aYx0+qc The main goal is to test the setting of NOTMUCH_CONFIG, but also include a basic sanity test for execing scripts. --- test/T405-external.sh | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 test/T405-external.sh diff --git a/test/T405-external.sh b/test/T405-external.sh new file mode 100755 index 00000000..b121fc72 --- /dev/null +++ b/test/T405-external.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +test_description='hooks' +. $(dirname "$0")/test-lib.sh || exit 1 + +create_echo_script () { + local TOKEN="${RANDOM}" + mkdir -p ${BIN_DIR} + cat <"${BIN_DIR}/${1}" +#!/bin/sh +echo "${TOKEN}" > ${3} +EOF + chmod +x "${BIN_DIR}/${1}" + echo "${TOKEN}" > ${2} +} + +create_printenv_script () { + mkdir -p ${BIN_DIR} + cat <"${BIN_DIR}/${1}" +#!/bin/sh +printenv "${2}" > "${3}" +EOF + chmod +x "${BIN_DIR}/${1}" +} + +# add a message to generate mail dir and database +add_message + +BIN_DIR=`pwd`/bin +PATH=$BIN_DIR:$PATH + +test_begin_subtest "'notmuch foo' runs notmuch-foo" +rm -rf ${BIN_DIR} +create_echo_script "notmuch-foo" EXPECTED OUTPUT $HOOK_DIR +notmuch foo +test_expect_equal_file_nonempty EXPECTED OUTPUT + +create_printenv_script "notmuch-printenv" NOTMUCH_CONFIG OUTPUT + +test_begin_subtest "NOTMUCH_CONFIG is set" +notmuch printenv +cat < EXPECTED +${NOTMUCH_CONFIG} +EOF +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "NOTMUCH_CONFIG is set by --config" +test_subtest_known_broken +cp "${NOTMUCH_CONFIG}" "${NOTMUCH_CONFIG}.alternate" +cat < EXPECTED +${NOTMUCH_CONFIG}.alternate +EOF +notmuch --config "${NOTMUCH_CONFIG}.alternate" printenv +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_done -- 2.35.2