From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 17 10:16:36 2022 Received: (at submit) by debbugs.gnu.org; 17 Mar 2022 14:16:36 +0000 Received: from localhost ([127.0.0.1]:54880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUqvc-0007Dn-0L for submit@debbugs.gnu.org; Thu, 17 Mar 2022 10:16:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:52098) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUqvb-0007Cs-3P for submit@debbugs.gnu.org; Thu, 17 Mar 2022 10:16:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUqvY-0004R4-SQ for bug-gnu-emacs@gnu.org; Thu, 17 Mar 2022 10:16:34 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:42879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUqvV-0006gU-Vj for bug-gnu-emacs@gnu.org; Thu, 17 Mar 2022 10:16:31 -0400 Received: from localhost ([77.183.118.101]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MA7Om-1nNkAt36k6-00BbXG for ; Thu, 17 Mar 2022 15:16:25 +0100 From: Felix Dietrich To: bug-gnu-emacs Subject: The test mailcap-parsing-and-mailcap-mime-info forgets to restore the HOME environment variable Date: Thu, 17 Mar 2022 15:16:19 +0100 Message-ID: <878rt81x70.fsf@sperrhaken.name> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:jvVIxRxbIYPiHeVM7X931wRVush6MGXaaF+ja2z2JfIM4uOf0K8 APhCCeoNtWjvZWq/dp3FbUe5idMPkekOh/kM2dYBzeHHoXALTd36C+3kCfgyDB9tRlAn9bj fxGtiPOwOzJ6Ip+DLl4H/ROfhGHJQve9aj9lkj/iWyV7ILym1mqPukojgEpi2gBGFRLimy7 mWUiX7Z32pUH8ES9igMPQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:zmrDJt6T35g=:FYcEvYmRoyMrs0Ay9UrGV6 y3HNCVrQHY7rSh5FYM87AllFYVkc0JhqBdiHSmv+HOYSFbj5xTmtW91lxHISGgIsd3LuSqpsC Z87tIh4Cji6qJqBymss8WyMBS8veEv61ydY8X8pUuVl7ex/Fg1pIANl3VUWob3EY4iYyUBdON 1ahhJv7rVG2wh1Gc2FhZ/rZzbX1XoS6Dw5qk/Qcs3ofcCetIBc/ZmPK1RsiY507uyTxWiKNd9 cQDmd5erY+kBWNSlP52jaVFFzqQ6gq1WGjeLY1xzxgU7s8K+AAIYVL93L8fCqdpaD0f6FbuT4 LKuJx3YJ4SMP9ACALOH5UUGw1+Y7xjm4ZSXypGN/y/ztB7ZUPmayBTTCktv+8cYO1GrHYTukU PsJWpQDdU1s/jg/8DmpY15yHdN22FLnKxEpx2pzzulBF+RR3siyoqr+kTTN7DYCxhHokD7wE1 gtLMVT0VGO7dyp6Dnf8m4zfZyOmU1RF9grOjfokTJ2dENKlT6JzB Received-SPF: none client-ip=217.72.192.75; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Severity: minor Tags: patch Running the test =E2=80=98mailcap-parsing-and-mailcap-mime-info=E2=80=99 wi= ll set the HOME environment variable to a temporary directory. After the test the directory is removed (thanks to the =E2=80=98ert-with-temp-directory=E2=80= =99 macro), but the value of the environment variable not restored, polluting the state of a running Emacs and affecting later commands in the Emacs session, like the vc-* commands when git cannot find its global configuration anymore. The patch wraps the test in a =E2=80=98let=E2=80=99 and =E2=80=98unwind-pro= tect=E2=80=99 to restore the value of the environment variable after the test has been run. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-mailcap-tests-Restore-HOME-environment-variable.patch Content-Transfer-Encoding: quoted-printable Content-Description: Patch to ensure restoration of HOME environment variable >From 137f3fcce83a3f2eadefcc7302fedca86f4ec38a Mon Sep 17 00:00:00 2001 From: Felix Dietrich Date: Wed, 16 Mar 2022 15:22:51 +0100 Subject: [PATCH] mailcap-tests: Restore HOME environment variable MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit In the test =E2=80=98mailcap-parsing-and-mailcap-mime-info=E2=80=99 --- test/lisp/net/mailcap-tests.el | 83 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/test/lisp/net/mailcap-tests.el b/test/lisp/net/mailcap-tests.el index b439c08c79..2c2955c68f 100644 --- a/test/lisp/net/mailcap-tests.el +++ b/test/lisp/net/mailcap-tests.el @@ -78,46 +78,49 @@ ;; One mailcap entry has a test=3Dfalse field. The shell command ;; execution errors when running the tests from the Makefile ;; because then HOME=3D/nonexistent. - (ert-with-temp-directory home - (setenv "HOME" home) - ;; Now parse our resource mailcap file. - (mailcap-parse-mailcap (ert-resource-file "mailcap")) - - ;; Assert that we get what we have defined. - (dolist (type '("audio/ogg" "audio/flac")) - (should (string=3D "mpv %s" (mailcap-mime-info type)))) - (should (string=3D "aplay %s" (mailcap-mime-info "audio/x-wav"))) - (should (string=3D "emacsclient -t %s" - (mailcap-mime-info "text/plain"))) - ;; evince is chosen because acroread has test=3Dfalse and okular - ;; comes later. - (should (string=3D "evince %s" - (mailcap-mime-info "application/pdf"))) - (should (string=3D "inkscape %s" - (mailcap-mime-info "image/svg+xml"))) - (should (string=3D "eog %s" - (mailcap-mime-info "image/jpg"))) - ;; With REQUEST being a number, all fields of the selected entry - ;; should be returned. - (should (equal '((viewer . "evince %s") - (type . "application/pdf")) - (mailcap-mime-info "application/pdf" 1))) - ;; With 'all, all applicable entries should be returned. - (should (equal '(((viewer . "evince %s") - (type . "application/pdf")) - ((viewer . "okular %s") - (type . "application/pdf"))) - (mailcap-mime-info "application/pdf" 'all))) - (let* ((c nil) - (toggle (lambda (_) (setq c (not c))))) - (mailcap-add "audio/ogg" "toggle %s" toggle) - (should (string=3D "toggle %s" (mailcap-mime-info "audio/ogg"))) - ;; The test results are cached, so in order to have the test - ;; re-evaluated, one needs to clear the cache. - (setq mailcap-viewer-test-cache nil) - (should (string=3D "mpv %s" (mailcap-mime-info "audio/ogg"))) - (setq mailcap-viewer-test-cache nil) - (should (string=3D "toggle %s" (mailcap-mime-info "audio/ogg"))))))) + (let ((home (getenv "HOME"))) + (unwind-protect + (ert-with-temp-directory tmp-home + (setenv "HOME" tmp-home) + ;; Now parse our resource mailcap file. + (mailcap-parse-mailcap (ert-resource-file "mailcap")) + + ;; Assert that we get what we have defined. + (dolist (type '("audio/ogg" "audio/flac")) + (should (string=3D "mpv %s" (mailcap-mime-info type)))) + (should (string=3D "aplay %s" (mailcap-mime-info "audio/x-wav")= )) + (should (string=3D "emacsclient -t %s" + (mailcap-mime-info "text/plain"))) + ;; evince is chosen because acroread has test=3Dfalse and okular + ;; comes later. + (should (string=3D "evince %s" + (mailcap-mime-info "application/pdf"))) + (should (string=3D "inkscape %s" + (mailcap-mime-info "image/svg+xml"))) + (should (string=3D "eog %s" + (mailcap-mime-info "image/jpg"))) + ;; With REQUEST being a number, all fields of the selected entry + ;; should be returned. + (should (equal '((viewer . "evince %s") + (type . "application/pdf")) + (mailcap-mime-info "application/pdf" 1))) + ;; With 'all, all applicable entries should be returned. + (should (equal '(((viewer . "evince %s") + (type . "application/pdf")) + ((viewer . "okular %s") + (type . "application/pdf"))) + (mailcap-mime-info "application/pdf" 'all))) + (let* ((c nil) + (toggle (lambda (_) (setq c (not c))))) + (mailcap-add "audio/ogg" "toggle %s" toggle) + (should (string=3D "toggle %s" (mailcap-mime-info "audio/ogg"= ))) + ;; The test results are cached, so in order to have the test + ;; re-evaluated, one needs to clear the cache. + (setq mailcap-viewer-test-cache nil) + (should (string=3D "mpv %s" (mailcap-mime-info "audio/ogg"))) + (setq mailcap-viewer-test-cache nil) + (should (string=3D "toggle %s" (mailcap-mime-info "audio/ogg"= ))))) + (setenv "HOME" home))))) =20 (defvar mailcap--test-result nil) (defun mailcap--test-viewer () --=20 2.35.1 --=-=-= Content-Type: text/plain -- Felix Dietrich --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 17 11:12:47 2022 Received: (at 54435) by debbugs.gnu.org; 17 Mar 2022 15:12:47 +0000 Received: from localhost ([127.0.0.1]:54974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUrnz-0000vf-4r for submit@debbugs.gnu.org; Thu, 17 Mar 2022 11:12:47 -0400 Received: from quimby.gnus.org ([95.216.78.240]:48948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUrnx-0000vJ-5X for 54435@debbugs.gnu.org; Thu, 17 Mar 2022 11:12:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=yHIUe4U4IcK9sd6R6xvWRFKG2vgh6EsCH7LCQAP0mNk=; b=Y2JiT2z1NCO1r3QlFeRPEbnQel 4jykhWKrj3QoO0Pofs6++ml4biyObOyqwdWLCgW0TUpkyO3u1YaNJxfov3S4fhRL3Pk3+HDm6fPPz KrDDb/TAPZRPrEwUFWENKyUaw89HMFM50SgTc570aAn8OXqWgCnim5PtmoHguHweQbV0=; Received: from 109.179.236.69.tmi.telenormobil.no ([109.179.236.69] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUrnn-0000W5-Uo; Thu, 17 Mar 2022 16:12:38 +0100 From: Lars Ingebrigtsen To: Felix Dietrich Subject: Re: bug#54435: The test mailcap-parsing-and-mailcap-mime-info forgets to restore the HOME environment variable References: <878rt81x70.fsf@sperrhaken.name> Date: Thu, 17 Mar 2022 16:12:34 +0100 In-Reply-To: <878rt81x70.fsf@sperrhaken.name> (Felix Dietrich's message of "Thu, 17 Mar 2022 15:16:19 +0100") Message-ID: <87tubwsjdp.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Felix Dietrich writes: > The patch wraps the test in a ‘let’ and ‘unwind-protect’ to restore the > value of the environment variable after the test has been run. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 54435 Cc: 54435@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Felix Dietrich writes: > The patch wraps the test in a =E2=80=98let=E2=80=99 and =E2=80=98unwind-p= rotect=E2=80=99 to restore the > value of the environment variable after the test has been run. Thanks. I've now applied a similar change to Emacs 29, but used `with-environment-variables' instead of let/unwind-protect. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 17 11:12:57 2022 Received: (at control) by debbugs.gnu.org; 17 Mar 2022 15:12:57 +0000 Received: from localhost ([127.0.0.1]:54977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUro9-0000w3-FQ for submit@debbugs.gnu.org; Thu, 17 Mar 2022 11:12:57 -0400 Received: from quimby.gnus.org ([95.216.78.240]:48964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUro7-0000vp-5l for control@debbugs.gnu.org; Thu, 17 Mar 2022 11:12:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=s4x10CBxRuwyDBiGR/VCOFEUougKzKCXGg7wIaB7fM8=; b=h5OPEQgo80JtWFSMtcVdsKYyyM l53M2vLegUxZJoZ6KRupKMP6xBtHrVF3AxtS/l/aiofGevdK70E1qVCOntRj3CNWyh/tRBI6zuhQ1 oJP5VuYkdgoXHJd+aiK18jjrQ5pc/rIawjVZEUwGNYfE58ECatxaF2xtuh0pyq7YhxKo=; Received: from 109.179.236.69.tmi.telenormobil.no ([109.179.236.69] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUrnz-0000WK-Lc for control@debbugs.gnu.org; Thu, 17 Mar 2022 16:12:49 +0100 Date: Thu, 17 Mar 2022 16:12:46 +0100 Message-Id: <87sfrgsjdd.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #54435 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 54435 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 54435 29.1 quit From unknown Fri Jun 20 07:24:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 15 Apr 2022 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator