Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 362C8421171 for ; Mon, 27 Jun 2011 21:45:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t+au47icWxr3 for ; Mon, 27 Jun 2011 21:45:52 -0700 (PDT) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 551AB421164 for ; Mon, 27 Jun 2011 21:45:46 -0700 (PDT) Received: by mail-bw0-f53.google.com with SMTP id 12so4889638bwg.26 for ; Mon, 27 Jun 2011 21:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=ViAC0yiCPc8h0RD+Z5ygFoUeMRd3OtTPtadiKH3EalY=; b=R96eTgt6Ya/35yRrgaGBd/gE9o708qlVS8n3KD8RKXsjr62vin76TZVyNa2UrXNAO/ s+nNcU39dvqjsvu5G2lO9NP54TKjkYPtpNGgSFSIAQwH8XyrlIhlNmkP//qsf+8kka0f cVmAQRSFHZieo+xL6Iwnhilo2yelCrGvK1JbU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=hyZP45Uita2oE5mNTwuTbnbIU3vpCzqanobDPGrdGgFjSPl1WXk1IjrgdZjky0IliP 6HaqipiS1v+SRm9hF5is3hA+/wxardVX9NGhSmuLp/ZBlDkIu8vlpdXq1ktkcZTK7ZdJ lNd4fCyHxedwf/kOu/+MR3XX2bDPhLsrEqz6Q= Received: by 10.204.189.74 with SMTP id dd10mr4575050bkb.174.1309236345754; Mon, 27 Jun 2011 21:45:45 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id g13sm2876218bkd.10.2011.06.27.21.45.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 21:45:45 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 08/10] test: set variables using `let' instead of `setq' in Emacs tests Date: Tue, 28 Jun 2011 08:45:09 +0400 Message-Id: <1309236311-2162-8-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309236311-2162-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1309236311-2162-1-git-send-email-dmitry.kurochkin@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Tue, 28 Jun 2011 04:45:54 -0000 Using `setq' for setting variables in Emacs tests affect other tests that may run in the same Emacs environment. Currently it works because each test is run in a separate Emacs instance. But in the future multiple tests will run in a single Emacs instance. The patch changes all variables to use `let', so the scope of the change is limited to a single test. --- test/emacs | 70 +++++++++++++++++++++++++++++------------------------ test/test-lib.sh | 27 ++++++++++---------- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/test/emacs b/test/emacs index 409e033..3d42645 100755 --- a/test/emacs +++ b/test/emacs @@ -1,4 +1,10 @@ #!/usr/bin/env bash + +# Note: do not use `setq' for setting variables in Emacs tests because +# it affects other tests that may run in the same Emacs instance. Use +# `let' instead so the scope of the changed variables is limited to a +# single test. + test_description="emacs interface" . test-lib.sh @@ -12,20 +18,20 @@ test_emacs '(notmuch-hello) test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello test_begin_subtest "Saved search with 0 results" -test_emacs '(setq notmuch-show-empty-saved-searches t) - (setq notmuch-saved-searches - '\''(("inbox" . "tag:inbox") - ("unread" . "tag:unread") - ("empty" . "tag:doesnotexist"))) - (notmuch-hello) - (test-output)' +test_emacs '(let ((notmuch-show-empty-saved-searches t) + (notmuch-saved-searches + '\''(("inbox" . "tag:inbox") + ("unread" . "tag:unread") + ("empty" . "tag:doesnotexist")))) + (notmuch-hello) + (test-output))' test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty test_begin_subtest "No saved searches displayed (all with 0 results)" -test_emacs '(setq notmuch-saved-searches - '\''(("empty" . "tag:doesnotexist"))) - (notmuch-hello) - (test-output)' +test_emacs '(let ((notmuch-saved-searches + '\''(("empty" . "tag:doesnotexist")))) + (notmuch-hello) + (test-output))' test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches test_begin_subtest "Basic notmuch-search view in emacs" @@ -147,9 +153,9 @@ output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_sear test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)" test_begin_subtest "notmuch-fcc-dirs set to nil" -test_emacs "(setq notmuch-fcc-dirs nil) - (notmuch-mua-mail) - (test-output)" +test_emacs "(let ((notmuch-fcc-dirs nil)) + (notmuch-mua-mail) + (test-output))" cat <EXPECTED From: Notmuch Test Suite To: @@ -164,9 +170,9 @@ mkdir -p mail/sent-string/new mkdir -p mail/sent-string/tmp test_begin_subtest "notmuch-fcc-dirs set to a string" -test_emacs "(setq notmuch-fcc-dirs \"sent-string\") - (notmuch-mua-mail) - (test-output)" +test_emacs "(let ((notmuch-fcc-dirs \"sent-string\")) + (notmuch-mua-mail) + (test-output))" cat <EXPECTED From: Notmuch Test Suite To: @@ -185,11 +191,11 @@ mkdir -p mail/failure/new mkdir -p mail/failure/tmp test_begin_subtest "notmuch-fcc-dirs set to a list (with match)" -test_emacs "(setq notmuch-fcc-dirs - '((\"notmuchmail.org\" . \"sent-list-match\") - (\".*\" . \"failure\"))) - (notmuch-mua-mail) - (test-output)" +test_emacs "(let ((notmuch-fcc-dirs + '((\"notmuchmail.org\" . \"sent-list-match\") + (\".*\" . \"failure\")))) + (notmuch-mua-mail) + (test-output))" cat <EXPECTED From: Notmuch Test Suite To: @@ -205,11 +211,11 @@ mkdir -p mail/sent-list-catch-all/new mkdir -p mail/sent-list-catch-all/tmp test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)" -test_emacs "(setq notmuch-fcc-dirs - '((\"example.com\" . \"failure\") - (\".*\" . \"sent-list-catch-all\"))) - (notmuch-mua-mail) - (test-output)" +test_emacs "(let ((notmuch-fcc-dirs + '((\"example.com\" . \"failure\") + (\".*\" . \"sent-list-catch-all\")))) + (notmuch-mua-mail) + (test-output))" cat <EXPECTED From: Notmuch Test Suite To: @@ -220,11 +226,11 @@ EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "notmuch-fcc-dirs set to a list (no match)" -test_emacs "(setq notmuch-fcc-dirs - '((\"example.com\" . \"failure\") - (\"nomatchhere.net\" . \"failure\"))) - (notmuch-mua-mail) - (test-output)" +test_emacs "(let ((notmuch-fcc-dirs + '((\"example.com\" . \"failure\") + (\"nomatchhere.net\" . \"failure\")))) + (notmuch-mua-mail) + (test-output))" cat <EXPECTED From: Notmuch Test Suite To: diff --git a/test/test-lib.sh b/test/test-lib.sh index ad1506c..7c8a86f 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -394,19 +394,20 @@ emacs_deliver_message () mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} ../smtp-dummy sent_message & smtp_dummy_pid=$! - test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it) - (setq smtpmail-smtp-server \"localhost\") - (setq smtpmail-smtp-service \"25025\") - (notmuch-hello) - (notmuch-mua-mail) - (message-goto-to) - (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") - (message-goto-subject) - (insert \"${subject}\") - (message-goto-body) - (insert \"${body}\") - $@ - (message-send-and-exit)" >/dev/null 2>&1 + test_emacs \ + "(let ((message-send-mail-function 'message-smtpmail-send-it) + (smtpmail-smtp-server \"localhost\") + (smtpmail-smtp-service \"25025\")) + (notmuch-hello) + (notmuch-mua-mail) + (message-goto-to) + (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") + (message-goto-subject) + (insert \"${subject}\") + (message-goto-body) + (insert \"${body}\") + $@ + (message-send-and-exit))" >/dev/null 2>&1 wait ${smtp_dummy_pid} notmuch new >/dev/null } -- 1.7.5.4