From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 92F976DE00AC for ; Thu, 6 Sep 2018 11:15:10 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.307 X-Spam-Level: X-Spam-Status: No, score=0.307 tagged_above=-999 required=5 tests=[AWL=-0.135, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.211, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CdqH-NAc27Z9 for ; Thu, 6 Sep 2018 11:15:09 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by arlo.cworth.org (Postfix) with ESMTPS id 810696DE00C4 for ; Thu, 6 Sep 2018 11:15:01 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id v90-v6so12435144wrc.0 for ; Thu, 06 Sep 2018 11:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ql7rjL+5Ywh+Y2NCULG9vtxy9p1deWNCgHJ8FlAotEo=; b=MF9fr8g1B2kpz0+FyLlf6NeERUyTuIlb7o2JJ0sjZRu56rwj8C9SM45bSzl+YZbuLT lfxPJ8nCj04ADPjTZGAaTJzL/7iiH9py7+pX3eMgdu1bmcbkOcd24dEf34pyeVufnlGv 1k60n/zqHQiagPW4BkvxX6brE0SNKJSDpSRXdeq4hHaIehQtjOW2kenuSvl6zUiIJ5In pG+B3GBV98IAlRskhoWEa2Yvr8qp9b7Yk4hvOqMNcPiAbzeBkUqLOQ7IhHl59ieg1lgd pfQccjepijz6s2+otFmaZtoz8ne5qfpAXjZoDWCUDzeOLvCYGxKfeETg2iy4m55uvNVw irGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ql7rjL+5Ywh+Y2NCULG9vtxy9p1deWNCgHJ8FlAotEo=; b=UJ9/3xHfx+lqzwO1ZNNc8c5a2UMYHVPig/v/pL2c9BCWv+5CwYS9f9dYAVHSF+BRPv 0QLgOaa8hPUQb2mYnm04u9zmtd11+I6mzLMzVwXYiIG6csxrMFyfWd07i0Sxhqq0gqAw VJyLEnWM7oLyNjNuwptdtQ9mLwquRowOVbO4c8dsZX/OLsUrRObaBOQ/IpJKOah5WOuK wWa+nd+9fiNHbyoUQQpozZpamXm6uveo4NWs+yyPQGtBqFQW4Z2iD+0TZ5TVecQjJ35+ WIPy7lKyPdNXipZjV/k9un8BpU8YGhIL0Y97oQQdIif2WEcIkUOjq3rUQ9AUTr4N+U/2 Z95A== X-Gm-Message-State: APzg51DlHqb7pC5vm660IFpdhgJgHBQ8QgZ2OnkrFcwrMLZBSiLy+emV Pol5RnXtxpFNNt/dqQjcZ1iK7FUDupA= X-Google-Smtp-Source: ANB0VdatqW0jJqO5918QQyJ1IHPQqdjZ1jJTHZb2dXP5vDwPLY17YCncacRTK6lzSz/kGAYHmfYh5w== X-Received: by 2002:adf:9227:: with SMTP id 36-v6mr3500591wrj.275.1536257699807; Thu, 06 Sep 2018 11:14:59 -0700 (PDT) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by smtp.gmail.com with ESMTPSA id b124-v6sm3806430wmg.47.2018.09.06.11.14.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 11:14:58 -0700 (PDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 5e2372de for ; Thu, 6 Sep 2018 18:14:56 +0000 (UTC) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v1 2/2] test: Add emacs attachment check tests. Date: Thu, 6 Sep 2018 19:14:56 +0100 Message-Id: <20180906181456.21719-3-dme@dme.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180906181456.21719-1-dme@dme.org> References: <20180906181456.21719-1-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 18:15:10 -0000 --- test/T720-emacs-attachment-warnings.sh | 36 ++++++++++++++++++++++++++++++++++ test/emacs-attachment-test.el | 25 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 test/T720-emacs-attachment-warnings.sh create mode 100644 test/emacs-attachment-test.el diff --git a/test/T720-emacs-attachment-warnings.sh b/test/T720-emacs-attachment-warnings.sh new file mode 100755 index 00000000..19bb2338 --- /dev/null +++ b/test/T720-emacs-attachment-warnings.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +test_description="emacs attachment warnings" +. $(dirname "$0")/test-lib.sh || exit 1 + +declare -a okays=( + "nothing to see" + "attachment\n<#part filename=foo />" + "<#part filename=foo/>" +) + +declare -a not_okays=( + "attachment" +) + +echo "okay" > EXPECTED +for okay in "${okays[@]}"; do + test_begin_subtest "Check okay" + test_emacs ' +(load-library "emacs-attachment-test.el") +(single-test "'"$okay"'") +(test-output)' + test_expect_equal_file EXPECTED OUTPUT +done + +echo "not okay!" > EXPECTED +for not_okay in "${not_okays[@]}"; do + test_begin_subtest "Check not_okay" + test_emacs ' +(load-library "emacs-attachment-test.el") +(single-test "'"$not_okay"'") +(test-output)' + test_expect_equal_file EXPECTED OUTPUT +done + +test_done diff --git a/test/emacs-attachment-test.el b/test/emacs-attachment-test.el new file mode 100644 index 00000000..604a16e5 --- /dev/null +++ b/test/emacs-attachment-test.el @@ -0,0 +1,25 @@ +(defun single-test (bodytext) + (set-buffer (get-buffer-create "result")) + (delete-region (point-min) (point-max)) + (insert (save-excursion + (single-test1 bodytext)) + "\n")) + +(defun single-test1 (bodytext) + "Test `notmuch-mua-attachment-check' using a message consisting of BODYTEXT. + +Return 'okay' if the message would be sent, otherwise 'not +okay!'" + (notmuch-mua-mail) + (message-goto-body) + (insert bodytext) + (prog1 + (condition-case detail + ;; Force `y-or-n-p' to always return `nil', as if the user + ;; pressed "n". + (letf (((symbol-function 'y-or-n-p) (lambda (&rest args) nil))) + (notmuch-mua-attachment-check) + "okay") + ('error "not okay!")) + (set-buffer-modified-p nil) + (kill-buffer (current-buffer)))) -- 2.11.0