From unknown Sun Aug 10 16:46:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Nov 2022 22:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 59028@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16676024003258 (code B ref -1); Fri, 04 Nov 2022 22:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Nov 2022 22:53:20 +0000 Received: from localhost ([127.0.0.1]:55002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5Yt-0000qT-OQ for submit@debbugs.gnu.org; Fri, 04 Nov 2022 18:53:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:44386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5Yr-0000qL-48 for submit@debbugs.gnu.org; Fri, 04 Nov 2022 18:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5Yp-0004Qi-A0 for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 18:53:16 -0400 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5Yl-0003tJ-7R for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 18:53:13 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 5138140002 for ; Fri, 4 Nov 2022 22:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667602388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=NKaSjuhSwBF+jdBQW15YRSeYpXgnpUlmC+qcAjZ6J6I=; b=JIXBHMNvEkp7z1Ro3HXKqBb4X4HIgKeN8/eWzJGc1Nbv6VAX2mdyjLsAfomYVKyQNk7SnV KyqnK/7Kk2REh90NpEtK5e8J4qhBq9ZmaiUFHAK/awyxAFXvKcpWK/e5FIpepA01iee6sR iN7LYLuiY7BMDyfGR5+Omfga8ARsdsKK64H3iVR0LrjUum69wcN4/0lJgx4Dd0+U5ffOed n8KabrOI2L29I/htFfiE3OzS+fDjjnwbZEJHymQA9ilAYE55vlFYUunhDexWxwP3BvZx8K 9lS7L59BykWGr3xF36OeG/luMew2N0QxHoel5HY2OVW/LXuSMWa6F4cGdj4BNg== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1or5Yf-002BN3-1M for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 15:53:05 -0700 From: Matt Armstrong Date: Fri, 04 Nov 2022 15:53:05 -0700 Message-ID: <87o7tmwcvi.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2001:4b98:dc4:8::222; envelope-from=matt@rfc20.org; helo=relay2-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) 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: -2.6 (--) --=-=-= Content-Type: text/plain Tags: patch Rationale is in the commit description, but it boils down to these tests being annoying for me recently. I like to M-x eval-buffer and run tests interactively, but these tests seemed to work nicely only in batch mode. In interactive mode they would both fail and issue annoying prompts "save this modified buffer?" prompts. In fixing them, I figured out what they were trying to test and attempted to make that more robust and clear. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0003-Rewrite-the-kill-buffer-delete-auto-save-tests.patch >From c7a35edb0c62f5cc392f6748dbf409d5bbfa567c Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Fri, 4 Nov 2022 12:43:30 -0700 Subject: [PATCH 3/6] Rewrite the `kill-buffer-delete-auto-save' tests These tests had been annoying to me when run in interactive mode. They failed to bind `kill-buffer-delete-auto-save' as needed, so they depended on the user's settings, and they failed to mock out the "Buffer modified, save?" prompt. * test/src/buffer-tests.el (test-kill-buffer-auto-save): New helper function that mocks the two different kinds of prompts that occur when killing modified buffers that visit a file. Tests fail if expected prompts are not issued. (test-kill-buffer-auto-save-default): Use it, and explicitly bind `kill-buffer-delete-auto-save' to nil. (test-kill-buffer-auto-save-delete): Delete it. (test-kill-buffer-auto-save-delete-yes): New test for the "yes" half of the old `test-kill-buffer-auto-save-delete'. (test-kill-buffer-auto-save-delete-yes): Ditto for the "no" half. --- test/src/buffer-tests.el | 143 +++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 58 deletions(-) diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index a39d7d51de1..78da02fe0a6 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -8323,65 +8323,92 @@ test-remove-overlays (remove-overlays) (should (= (length (overlays-in (point-min) (point-max))) 0)))) -(ert-deftest test-kill-buffer-auto-save-default () - (ert-with-temp-file file - (let (auto-save) - ;; Always answer yes. - (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - (kill-buffer (current-buffer)) - (should (file-exists-p auto-save))) - (when auto-save - (ignore-errors (delete-file auto-save)))))))) - -(ert-deftest test-kill-buffer-auto-save-delete () +(defun test-kill-buffer-auto-save (auto-save-answer body-func) + "Test helper for `kill-buffer-delete-auto-save' tests. + +Call BODY-FUNC with the current buffer set to a buffer visiting a +temporary file. Around the call, mock the \"Buffer modified; +kill anyway?\" and \"Delete auto-save file?\" prompts, answering +\"yes\" for the former and AUTO-SAVE-ANSWER for the latter. The +expectation should be the characters `?y' or `?n', or `nil' if no +prompt is expected. The test fails if the \"Delete auto-save +file?\" prompt does not either prompt is not issued as expected. +Finally, kill the buffer and its temporary file." (ert-with-temp-file file - (let (auto-save) - (should (file-exists-p file)) - (setq kill-buffer-delete-auto-save-files t) - ;; Always answer yes. - (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - ;; This should delete the auto-save file. - (kill-buffer (current-buffer)) - (should-not (file-exists-p auto-save))) - (ignore-errors (delete-file file)) - (when auto-save - (ignore-errors (delete-file auto-save))))) - ;; Answer no to deletion. - (cl-letf (((symbol-function #'yes-or-no-p) - (lambda (prompt) - (not (string-search "Delete auto-save file" prompt))))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - ;; This should not delete the auto-save file. - (kill-buffer (current-buffer)) - (should (file-exists-p auto-save))) - (when auto-save - (ignore-errors (delete-file auto-save)))))))) + (should (file-exists-p file)) + (save-excursion + (find-file file) + (should (equal file (buffer-file-name))) + (let ((buffer (current-buffer)) + (auto-save-prompt-happened nil)) + (cl-letf (((symbol-function #'read-multiple-choice) + (lambda (prompt choices &rest _) + (should (string-search "modified; kill anyway?" prompt)) + (let ((answer (assq ?y choices))) + (should answer) + answer))) + ((symbol-function #'yes-or-no-p) + (lambda (prompt) + (should (string-search "Delete auto-save file?" prompt)) + (setq auto-save-prompt-happened t) + (pcase-exhaustive auto-save-answer + (?y t) + (?n nil))))) + (funcall body-func) + (should (equal (null auto-save-prompt-happened) + (null auto-save-answer)))) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (set-buffer-modified-p nil) + (kill-buffer))))))) + +(ert-deftest test-kill-buffer-auto-save-default () + (let ((kill-buffer-delete-auto-save-files nil)) + (test-kill-buffer-auto-save + nil + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + (kill-buffer (current-buffer)) + (should (file-exists-p auto-save))))))) + +(ert-deftest test-kill-buffer-auto-save-delete-yes () + (let ((kill-buffer-delete-auto-save-files t)) + (test-kill-buffer-auto-save + ?y + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + ;; This should delete the auto-save file. + (kill-buffer (current-buffer)) + (should-not (file-exists-p auto-save))))))) + +(ert-deftest test-kill-buffer-auto-save-delete-no () + (let ((kill-buffer-delete-auto-save-files t)) + (test-kill-buffer-auto-save + ?n + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + ;; This should not delete the auto-save file. + (kill-buffer (current-buffer)) + (should (file-exists-p auto-save)) + (delete-file auto-save)))))) (ert-deftest test-buffer-modifications () (ert-with-temp-file file -- 2.35.1 --=-=-=-- From unknown Sun Aug 10 16:46:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Nov 2022 09:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Matt Armstrong Cc: 59028@debbugs.gnu.org Received: via spool by 59028-submit@debbugs.gnu.org id=B59028.166807420818620 (code B ref 59028); Thu, 10 Nov 2022 09:57:02 +0000 Received: (at 59028) by debbugs.gnu.org; 10 Nov 2022 09:56:48 +0000 Received: from localhost ([127.0.0.1]:41941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot4Ih-0004qF-OB for submit@debbugs.gnu.org; Thu, 10 Nov 2022 04:56:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52208) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot4Ig-0004q3-FF for 59028@debbugs.gnu.org; Thu, 10 Nov 2022 04:56:46 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ot4Ia-0005z7-Ry; Thu, 10 Nov 2022 04:56:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=k62D/nsgwgLVLtCkJcr++a6Q+bWhi86knDB3kaee0RU=; b=U/03ZStmOG6F 7x25pce0C2AowRO9rfqataSGE02qtEYHfINKow0qPFKZDoYgRF1MZf1QLYhxVfmHyzmeSp/25yF6X UKP47SFH99aVpweg/Yylz1Op4cCOby9AbfIfVjdySrVRlCM3Otjjr+zeJlwU8AsGBj7tFWMDHUWEz Niv7+ROyZ6he5G393wHNpjLEtk/NZwUW9BelKaUFASg1LY5LGttdwi3uhCVdF+PUWycLjY/0kWq/H K00M5IwYPesk/i+4elUPqhSMcLpR6syc1AdUcbzoitCMse0lluOZcqaf/0DGfPSbQ5h8l3ATIROOB kaYnogQ6jubtVeEISF2a9Q==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ot4Ia-00078S-BR; Thu, 10 Nov 2022 04:56:40 -0500 Date: Thu, 10 Nov 2022 11:56:40 +0200 Message-Id: <83cz9vrv3b.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87o7tmwcvi.fsf@rfc20.org> (message from Matt Armstrong on Fri, 04 Nov 2022 15:53:05 -0700) References: <87o7tmwcvi.fsf@rfc20.org> X-Spam-Score: -2.3 (--) 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 (---) > From: Matt Armstrong > Date: Fri, 04 Nov 2022 15:53:05 -0700 > > Rationale is in the commit description, but it boils down to these tests > being annoying for me recently. I like to M-x eval-buffer and run tests > interactively, but these tests seemed to work nicely only in batch mode. > In interactive mode they would both fail and issue annoying prompts > "save this modified buffer?" prompts. In fixing them, I figured out > what they were trying to test and attempted to make that more robust and > clear. Thanks, I installed this. However, the tests are still quite talkative, and emit a lot of stuff for which I see no purpose. Can we shut up those "BEGIN overlay-modification-hooks test-case ((insert-at . 1))" messages and also the "Auto-saving...", "Auto-saving...done"? Or do they serve some useful purpose? From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 15:34:08 2022 Received: (at control) by debbugs.gnu.org; 12 Nov 2022 20:34:08 +0000 Received: from localhost ([127.0.0.1]:49144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCa-0004lL-Jc for submit@debbugs.gnu.org; Sat, 12 Nov 2022 15:34:08 -0500 Received: from mail-oi1-f175.google.com ([209.85.167.175]:33372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCY-0004jl-Bl for control@debbugs.gnu.org; Sat, 12 Nov 2022 15:34:06 -0500 Received: by mail-oi1-f175.google.com with SMTP id c129so8016779oia.0 for ; Sat, 12 Nov 2022 12:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=p4jtWnHJEBukf+uqwI0GGHC2Nk4YiKHpDdO4NCMOcFQ=; b=phoQlMytG4q70GVBDoYVQROinPDr7urT5wJ2mG1/51gZxpUd/BImZmhZn54rSFN74K ATJHihFHs14/zuLsYSYvSmbZNh+FOcmWwyKPhbXeB+TKcfdh32GtJc14K9x6RLgem1rb PRqF6/cDyYLvU1kECn0jWx7ueH0RDtC6DSJM96dtCze3w1N2IKHrAifdMLSqfku6adVK 7F+szZdcQdKncVwKFv1KEFQTGNhbqIXP171/qjBdVYxI0VT+EhV8ehgIv/0rKpo0GWgZ TPzelZzz4lHGda7JGStH7xJu3nrodyp2TU+WydsVDjND//YhV87ksjgTpNX2wNa6eO3N OgXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=p4jtWnHJEBukf+uqwI0GGHC2Nk4YiKHpDdO4NCMOcFQ=; b=VQQvilcgTQbi2F3anHxTaHR5ETtYCIH2q9AV7D4cP5q3novmdhfE0Z/vStDAcMutbk 1s/8c7cMPtjLfd4CqqShdT+XgGL1h67rkeeoYoqcnys2+Vqm5zQ5LD/7HtrX3mDKLZco tdfIjf83r5kDlQeZUKiJdwF6SXgjSwzSYbV8fdFS41qpVh575dFsRP2CH/wjwjkEmxae dVtNOBoUaJca16KSfkEMRaj5pmfxl7NOeNF46floJ7nH6mc/NWv6C2R44jcDwuBOHMQJ AxXBOQFvb8UEEYZ0tG8OBaTfU2NRF9wGhK5JNR0z2L8SkpeKyVqUMHI/z8K7iEGFng8L GWWw== X-Gm-Message-State: ANoB5pl2TsElVH0yaoW+KEVQFQOgVN65/t47WsC3rbsWgmjG4MHdp5d9 MUjgx1pZhQccUyGV/kROo12ll7RISVD1YCFR08csZshG X-Google-Smtp-Source: AA0mqf5+vgxaflsoK3685wiMX+y2K/qDKI6/A8USuvbykHkRNeARy5L0b2rX7X2jyemIRTItn2YZAbo7Wfuf8K76ujo= X-Received: by 2002:a54:460b:0:b0:35a:6524:3c1b with SMTP id p11-20020a54460b000000b0035a65243c1bmr3364151oip.199.1668285240980; Sat, 12 Nov 2022 12:34:00 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 12 Nov 2022 12:34:00 -0800 From: Stefan Kangas X-Hashcash: 1:20:221112:control@debbugs.gnu.org::p4QH7sF+xlHjYZb2:38wq MIME-Version: 1.0 Date: Sat, 12 Nov 2022 12:34:00 -0800 Message-ID: Subject: control message for bug #59028 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) 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: -1.0 (-) severity 59028 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 15:34:22 2022 Received: (at control) by debbugs.gnu.org; 12 Nov 2022 20:34:23 +0000 Received: from localhost ([127.0.0.1]:49157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCo-0004mP-Nv for submit@debbugs.gnu.org; Sat, 12 Nov 2022 15:34:22 -0500 Received: from mail-oi1-f179.google.com ([209.85.167.179]:43747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCl-0004lq-2c for control@debbugs.gnu.org; Sat, 12 Nov 2022 15:34:19 -0500 Received: by mail-oi1-f179.google.com with SMTP id q83so7939590oib.10 for ; Sat, 12 Nov 2022 12:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=00haQv4L3HBDvA3U5RgTelc5jHn19XVMocEnKDyzHuo=; b=mAqIUvACnTH8j5aSRKe+AKXFR+Xr6QcymH0Lh8VuThVeykENERpiF4Phws+gOo3Fvt NdIu4QMEVkhJmVtTInKfFy/frZSx+Vn1eSqG19DUitk02FS+ZrbGeocVvfhz++W9UciW UUerWuCPSkMtIRwcNK0bPdVBtfleFpy5hzv6ZurhRrkAKhWKCMMHgs2v5ilTAxqR5QFS JrtQxs5B8Wa42qNXdANuAyZoevssRuowRlidOeSLL9ihRZLGox9QLKvn26TH80d5EALD Yqmfyw8/ly1wsoAigpMKklAwOMVSxZNMR7ee8/q3UsD/LzImWRKec8AEkK2/rF5aTLE+ WcJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=00haQv4L3HBDvA3U5RgTelc5jHn19XVMocEnKDyzHuo=; b=i72qSmrEwo7LrwLYUqPzVAZDBkjVPiOOdIlp31IF7hgR5+CZ4pbKxSTtd5mIIQY/PE yytwDQmqobVhTv+zr0/j7a6tmsoMB1vh5/vZboUAsuA2D2cTJtBClKBJfSSbYiX0OFCz alJnq3UONYpc8w6o9/myXFSkaVymUYzuW+0+RuHYfAvnj3kZviW/g/FZf53aRKIA5cLT DR8pGTx35SKblHqNb/zAn4BnPWGoHe+bRqvnjcaw3RHT/TEamUI+W+2LnYlZChujD5Ax f2K6xSkKycco79TgS2dMshSFSNLaGRc79niKztSU0T2kSTQ1J3W0FsQyCVOnO9Lt2ZDL 0S7g== X-Gm-Message-State: ANoB5pkw+dpz8Y9TuLsMiitdaTGolbkhFxxn6mkCbL5P9rSgOTyjF6FR 0F4wMcJ+l/2yRMzs/IjcXzKVeQ6sEaZhNlG/5sLtzKMh X-Google-Smtp-Source: AA0mqf7GsUWL8potgDNxjp9iVqL9uydjjWBWZ9P7T6psoP3WTvMkY4JuHm3JjBaD2ifxbDv3Ts80V9rB/c5TSM3zy6Y= X-Received: by 2002:a54:460b:0:b0:35a:6524:3c1b with SMTP id p11-20020a54460b000000b0035a65243c1bmr3364331oip.199.1668285253651; Sat, 12 Nov 2022 12:34:13 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 12 Nov 2022 12:34:13 -0800 From: Stefan Kangas X-Hashcash: 1:20:221112:control@debbugs.gnu.org::YgN3KZsmA3CUKI16:0C+Z MIME-Version: 1.0 Date: Sat, 12 Nov 2022 12:34:13 -0800 Message-ID: Subject: control message for bug #59028 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) 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: -1.0 (-) tags 59028 + moreinfo quit From unknown Sun Aug 10 16:46:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Nov 2022 18:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo patch To: Eli Zaretskii Cc: 59028@debbugs.gnu.org Received: via spool by 59028-submit@debbugs.gnu.org id=B59028.166853837619313 (code B ref 59028); Tue, 15 Nov 2022 18:53:01 +0000 Received: (at 59028) by debbugs.gnu.org; 15 Nov 2022 18:52:56 +0000 Received: from localhost ([127.0.0.1]:55236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov13H-00051R-Nr for submit@debbugs.gnu.org; Tue, 15 Nov 2022 13:52:56 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:57431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov13F-00051D-Pp for 59028@debbugs.gnu.org; Tue, 15 Nov 2022 13:52:54 -0500 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 98FC960004; Tue, 15 Nov 2022 18:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1668538368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4EPm26/MUkS/WPaOoh2v78G6Kyy68j5ncYeE6EGcHvs=; b=BeSxYLQSnQ4tLybPsaAN+YeIH+9EeDqTZBaMILNv8xtEhCZUUewV5AjK1p5OCYz/JvXQWd QoOURUGiwcQsb7ph58WwLh0AL+/mT35FfBBOmU6/EPgQUWQRKGudVNzb2jQ95zIJobz1ya z+S5L8/57c9TXQtK0dewdHcAK46Ypz7wGtWpzgE7zbOro2mQdRHTg0/KdOgKInGXc2lS8P sNqGjWyLf/bT+5KbSLIMBHjD3yX3lUs6VG4o8YpeY0ZkkD5aBEOWg2Uol0rJ7fcaX3kV27 AOuFb4A3B2oneB9tOgRyMpinvYQlFdO76RT2lqH5r/SGGcN4kfAV6qYoYdK+3g== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1ov135-000UMx-0n; Tue, 15 Nov 2022 10:52:43 -0800 From: Matt Armstrong In-Reply-To: <83cz9vrv3b.fsf@gnu.org> References: <87o7tmwcvi.fsf@rfc20.org> <83cz9vrv3b.fsf@gnu.org> Date: Tue, 15 Nov 2022 10:52:43 -0800 Message-ID: <87wn7w59tw.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) 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: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Matt Armstrong >> Date: Fri, 04 Nov 2022 15:53:05 -0700 >> >> Rationale is in the commit description, but it boils down to these tests >> being annoying for me recently. I like to M-x eval-buffer and run tests >> interactively, but these tests seemed to work nicely only in batch mode. >> In interactive mode they would both fail and issue annoying prompts >> "save this modified buffer?" prompts. In fixing them, I figured out >> what they were trying to test and attempted to make that more robust and >> clear. > > Thanks, I installed this. > > However, the tests are still quite talkative, and emit a lot of stuff > for which I see no purpose. Can we shut up those "BEGIN > overlay-modification-hooks test-case ((insert-at . 1))" messages and > also the "Auto-saving...", "Auto-saving...done"? Or do they serve > some useful purpose? See the attached patch, which either removes noisy messages or replaces them with `ert-info'. I didn't know about `ert-info' when I added the noisy messages. As for the "Auto-saving..." messages, they are printed by calls to `message1' in fileio.c. There may be a way to hide them, but see the next paragraph. There is a behavior difference between ert's interactive runner and batch runner. In interactive mode all `message' output is redirected to a buffer normally hidden, made visible only by request after the test runs, and I expect people will look at these only when debugging failed tests. In batch mode `message' output is printed to stdout (or maybe stderr) by default, mixed with ert's other output. It may be possible to change ert's batch runner to hide each test's `message' output, perhaps printing it only if the test fails. Do we have a person who is familiar with ert that we can run this idea by? For example, this kind of noise would also be eliminated by such a change: passed 35/48 simple-tests--undo (0.000591 sec) Undo Redo Mark set Undo in region Redo Redo Redo Undo Undo Undo Undo Undo Undo passed 36/48 simple-tests--undo-equiv-table (0.000453 sec) Mark set Undo in region Mark activated Undo in region Redo in region Redo in region --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Reduce-buffer-tests-noisiness-when-run-in-batch-mode.patch >From 717328dac712f3a53ca950bb1e202b4e0936ceae Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Tue, 15 Nov 2022 10:33:00 -0800 Subject: [PATCH] Reduce buffer-tests noisiness when run in batch mode. * test/src/buffer-tests.el (overlay-modification-hooks): Remove noisy `message' calls and use `ert-info' to log context of test failures. (bug#59028) (overlay-tests-start-recording-modification-hooks): ditto. --- test/src/buffer-tests.el | 77 ++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 3fc52eaf8b..2b6c974159 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -42,7 +42,6 @@ overlay-tests-start-recording-modification-hooks overlay hooks-property (list (lambda (ov &rest args) - (message " %S called on %S with args %S" hooks-property ov args) (should inhibit-modification-hooks) (should (eq ov overlay)) (push (list hooks-property args) @@ -175,47 +174,41 @@ overlay-modification-hooks (t 1 2 0)) (insert-behind-hooks (t 1 2 0))))))) - (message "BEGIN overlay-modification-hooks test-case %S" test-case) - - ;; All three hooks ignore the overlay's `front-advance' and - ;; `rear-advance' option, so test both ways while expecting the same - ;; result. - (dolist (advance '(nil t)) - (message " advance is %S" advance) - (let-alist test-case - (with-temp-buffer - ;; Set up the temporary buffer and overlay as specified by - ;; the test case. - (insert (or .buffer-text "1234")) - (let ((overlay (make-overlay - (or .overlay-beg 2) - (or .overlay-end 4) - nil - advance advance))) - (message " (buffer-string) is %S" (buffer-string)) - (message " overlay is %S" overlay) - (overlay-tests-start-recording-modification-hooks overlay) - - ;; Modify the buffer, possibly inducing calls to the - ;; overlay's modification hooks. - (should (or .insert-at .replace)) - (when .insert-at - (goto-char .insert-at) - (insert "x") - (message " inserted \"x\" at %S, buffer-string now %S" - .insert-at (buffer-string))) - (when .replace - (goto-char (point-min)) - (search-forward .replace) - (replace-match "x") - (message " replaced %S with \"x\"" .replace)) - - ;; Verify that the expected and actual modification hook - ;; calls match. - (should (equal - .expected-calls - (overlay-tests-get-recorded-modification-hooks - overlay))))))))) + (ert-info ((format "test-case: %S" test-case)) + ;; All three hooks ignore the overlay's `front-advance' and + ;; `rear-advance' option, so test both ways while expecting the same + ;; result. + (dolist (advance '(nil t)) + (ert-info ((format "advance is %S" advance)) + (let-alist test-case + (with-temp-buffer + ;; Set up the temporary buffer and overlay as specified by + ;; the test case. + (insert (or .buffer-text "1234")) + (let ((overlay (make-overlay + (or .overlay-beg 2) + (or .overlay-end 4) + nil + advance advance))) + (overlay-tests-start-recording-modification-hooks overlay) + + ;; Modify the buffer, possibly inducing calls to the + ;; overlay's modification hooks. + (should (or .insert-at .replace)) + (when .insert-at + (goto-char .insert-at) + (insert "x")) + (when .replace + (goto-char (point-min)) + (search-forward .replace) + (replace-match "x")) + + ;; Verify that the expected and actual modification hook + ;; calls match. + (should (equal + .expected-calls + (overlay-tests-get-recorded-modification-hooks + overlay))))))))))) (ert-deftest overlay-modification-hooks-message-other-buf () "Test for bug#21824. -- 2.35.1 --=-=-=-- From unknown Sun Aug 10 16:46:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Nov 2022 20:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo patch To: Matt Armstrong , Eli Zaretskii Cc: 59028@debbugs.gnu.org Received: via spool by 59028-submit@debbugs.gnu.org id=B59028.16685424452122 (code B ref 59028); Tue, 15 Nov 2022 20:01:02 +0000 Received: (at 59028) by debbugs.gnu.org; 15 Nov 2022 20:00:45 +0000 Received: from localhost ([127.0.0.1]:55326 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov26v-0000YA-If for submit@debbugs.gnu.org; Tue, 15 Nov 2022 15:00:45 -0500 Received: from mail-oa1-f49.google.com ([209.85.160.49]:39586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov26t-0000Xs-P0 for 59028@debbugs.gnu.org; Tue, 15 Nov 2022 15:00:44 -0500 Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-141ca09c2fbso7888041fac.6 for <59028@debbugs.gnu.org>; Tue, 15 Nov 2022 12:00:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=KzyMvaLfxSOwOxkOQ4n++IOGuGZHxaCQYPfy/GIS0lQ=; b=KNuNiNNJuLevTwxUjWgInWF+w/MahuACkoi5NmynHHFagdfhm6LEM7XvS8zNF5TaVT eJiLz8t+hk0uViIPQ74Q0UXzMM8X4GAqGiV1FRwjW69PjzmoNAjKClgLEARTalpVXNOf YHKSwuhmm/WKkA1GBf9cTyoAP4U0QrCe9CLqA5RAG8mDpbnA+dg8klzwVC9DGMTGb3kS I+9BEi0hwzXwEbhdyYoB4HJL7FMOZ4ScFdzhtHqTq8s07hRsLsRaE6g65oALbiFZ8lvv 81gYXbRcbv8MqeepjDpRzDDtV+kJOuwdH0Nogu9IM9LRfXjp3zxVLBUfPI5lmU0unBjq SMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KzyMvaLfxSOwOxkOQ4n++IOGuGZHxaCQYPfy/GIS0lQ=; b=yHWu7lATaiKCkn0nTZDWe5LEEQkBzBWORESahGpnaht71WKXa/WFevs5Jpt3qxlg5+ BlW3jPKMg3Z/Af14K/pNGogCMxY48M4jRzfnhGp34RuNim+KHa7KeeNbdaMKpMQZK5zt oLGnF1cjSN1VgV+qHXJdUwda3/2FPF2mZ2Lc3JlDicoyw9Vr6aur/zxET9xGk713OiLt 2G+VzTGgmBemVDccsIuOxhNBFJj21ugjM26G8GuzxBuxurNEhffQ4nPURgfsM2U9brYZ 6RoISYjdMJuXcebjW0Ovjpjp0pg0/LHitHs6+KKZCubFRALUGcwSGQVYru1TxYpIMn+I 1W6A== X-Gm-Message-State: ANoB5pmQyj/t8rFRF9VzhLOMj2t0Eay4DGLMHWkwqA1ro1RtYFgNPY4r E55tJK8yDE4Ep8hLoFwC1ANhgzd01WsEesJfN5c= X-Google-Smtp-Source: AA0mqf4BMUPRjbRu2rmUu7Gcw35NMeHp8iA6Cgk/haa/Usa5ldMTSOSgyq454LtQ/7W49opFka3qT7kGCZzY3+S073g= X-Received: by 2002:a05:6871:4808:b0:13b:8a07:2a1f with SMTP id qc8-20020a056871480800b0013b8a072a1fmr1324815oab.199.1668542438136; Tue, 15 Nov 2022 12:00:38 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 15 Nov 2022 12:00:37 -0800 From: Stefan Kangas In-Reply-To: <87wn7w59tw.fsf@rfc20.org> References: <87o7tmwcvi.fsf@rfc20.org> <83cz9vrv3b.fsf@gnu.org> <87wn7w59tw.fsf@rfc20.org> X-Hashcash: 1:20:221115:matt@rfc20.org::yyOulFsuT1U8ciCi:2rvu MIME-Version: 1.0 Date: Tue, 15 Nov 2022 12:00:37 -0800 Message-ID: Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) 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: -1.0 (-) Matt Armstrong writes: > It may be possible to change ert's batch runner to hide each test's > `message' output, perhaps printing it only if the test fails. That's a good idea. How about opening a feature request to track it? From unknown Sun Aug 10 16:46:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2022 14:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59028 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo patch To: Matt Armstrong Cc: 59028@debbugs.gnu.org Received: via spool by 59028-submit@debbugs.gnu.org id=B59028.16686096827789 (code B ref 59028); Wed, 16 Nov 2022 14:42:02 +0000 Received: (at 59028) by debbugs.gnu.org; 16 Nov 2022 14:41:22 +0000 Received: from localhost ([127.0.0.1]:56492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJbO-00021Z-0w for submit@debbugs.gnu.org; Wed, 16 Nov 2022 09:41:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42342) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJbK-00021M-Nb for 59028@debbugs.gnu.org; Wed, 16 Nov 2022 09:41:21 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovJbF-0006uI-6W; Wed, 16 Nov 2022 09:41:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=hBDAl/IihJ11IEQAXeuV+x9lkT4rLCrXVkctMFwX2TE=; b=OdBiMB4sd5FQ qCmvxy8EjebyAnaaanQaHizfOpkVqQtSpmCPOuZP7mE38f0a2Q44EMFDdWSVtmsOPr2uQ0xs2hhGq kUMrqwEQGC+Gc9b3mRDMz4INQ3N29X8jzWOMO9pb6yh+CMBo1nYLwR6ULJ94gbOgyStq3J+ajc1CO tJrKCm3BaCoJAc7VAhRCEOSVhAzm5XWWL+e6V4VJsrp6PEQAejKHL5a7n2w804XgIrzHxUUy9C9cM SzTqUv2qa3c2CTyUYjdOeKKiYCl9blwsXCul/P7AtLoCKW9xsz0F9JgGD4duCWvbABZ6/j1Ocy4EZ PMjYKZw1E+3TfAcB8gpGqA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovJbE-0003lz-Fd; Wed, 16 Nov 2022 09:41:13 -0500 Date: Wed, 16 Nov 2022 16:41:10 +0200 Message-Id: <831qq3gdx5.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87wn7w59tw.fsf@rfc20.org> (message from Matt Armstrong on Tue, 15 Nov 2022 10:52:43 -0800) References: <87o7tmwcvi.fsf@rfc20.org> <83cz9vrv3b.fsf@gnu.org> <87wn7w59tw.fsf@rfc20.org> X-Spam-Score: -2.3 (--) 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 (---) > From: Matt Armstrong > Cc: 59028@debbugs.gnu.org > Date: Tue, 15 Nov 2022 10:52:43 -0800 > > > However, the tests are still quite talkative, and emit a lot of stuff > > for which I see no purpose. Can we shut up those "BEGIN > > overlay-modification-hooks test-case ((insert-at . 1))" messages and > > also the "Auto-saving...", "Auto-saving...done"? Or do they serve > > some useful purpose? > > See the attached patch, which either removes noisy messages or replaces > them with `ert-info'. I didn't know about `ert-info' when I added the > noisy messages. Thanks, I installed this. > As for the "Auto-saving..." messages, they are printed by calls to > `message1' in fileio.c. There may be a way to hide them, but see the > next paragraph. There is a way, and I took it. Now there's no noise. > There is a behavior difference between ert's interactive runner and > batch runner. In interactive mode all `message' output is redirected to > a buffer normally hidden, made visible only by request after the test > runs, and I expect people will look at these only when debugging failed > tests. In batch mode `message' output is printed to stdout (or maybe > stderr) by default, mixed with ert's other output. It may be possible > to change ert's batch runner to hide each test's `message' output, > perhaps printing it only if the test fails. Do we have a person who is > familiar with ert that we can run this idea by? > > For example, this kind of noise would also be eliminated by such a > change: > > passed 35/48 simple-tests--undo (0.000591 sec) > Undo > Redo > Mark set > Undo in region > Redo > Redo > Redo > Undo > Undo > Undo > Undo > Undo > Undo > passed 36/48 simple-tests--undo-equiv-table (0.000453 sec) > Mark set > Undo in region > Mark activated > Undo in region > Redo in region > Redo in region Yes, it would be good to be able to shut that up as well. Thanks. Can we now close this bug? From unknown Sun Aug 10 16:46:05 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Matt Armstrong Subject: bug#59028: closed (Re: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests) Message-ID: References: <87o7t6687w.fsf@rfc20.org> <87o7tmwcvi.fsf@rfc20.org> X-Gnu-PR-Message: they-closed 59028 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: moreinfo patch Reply-To: 59028@debbugs.gnu.org Date: Wed, 16 Nov 2022 18:55:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1668624902-18408-1" This is a multi-part message in MIME format... ------------=_1668624902-18408-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 59028@debbugs.gnu.org. --=20 59028: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D59028 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1668624902-18408-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 59028-done) by debbugs.gnu.org; 16 Nov 2022 18:54:40 +0000 Received: from localhost ([127.0.0.1]:58127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovNYW-0004mF-Gf for submit@debbugs.gnu.org; Wed, 16 Nov 2022 13:54:40 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:50479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovNYU-0004m1-3p for 59028-done@debbugs.gnu.org; Wed, 16 Nov 2022 13:54:39 -0500 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 2BAEB1BF209; Wed, 16 Nov 2022 18:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1668624871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yk1tYMGoNR6Cje1+T/R+DvARqiXMl61S1MerLIYqIFo=; b=VuDbiwWi3Nu+3G/4/5YMgogbAYsMAE/dIcEy9AaxkZoWrRkzfMsFkQERLdnWom0pf8tAwZ kiA/LN0FFAJ+p0Pnj7Rclf4DLRGYcyCJaIBgWSqa+VVRhlhzmYbbD3LqrW2yBimm5GpYEm Gy3NUYIHY9kqQQbgeccSV31B0iLHw3jDbQEFEg0BIJbD1VP7JjzE0J9v0F6MwLtqrEJb/7 gcICBXvxbeoFzK09KBK+Zanhn4ZHM6PYl68Exet1DUbUXy3kiNXzPH0vNC8AANN+fS0klX BFIzi3UHZOwBGKkRZOf58y3To2K7J7wRE6L9PpQ03Y8xxhc9zGt7dge2TWeTYg== Received: by mac-mini.lan (Postfix) with ESMTPS id B0A2B38FD4; Wed, 16 Nov 2022 10:54:27 -0800 (PST) Received: by naz.lan (Postfix, from userid 1000) id 9358E4127389; Wed, 16 Nov 2022 10:54:27 -0800 (PST) From: Matt Armstrong To: Stefan Kangas , Eli Zaretskii Subject: Re: bug#59028: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests In-Reply-To: References: <87o7tmwcvi.fsf@rfc20.org> <83cz9vrv3b.fsf@gnu.org> <87wn7w59tw.fsf@rfc20.org> Date: Wed, 16 Nov 2022 10:54:27 -0800 Message-ID: <87o7t6687w.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59028-done Cc: 59028-done@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: -1.7 (-) Stefan Kangas writes: > Matt Armstrong writes: > >> It may be possible to change ert's batch runner to hide each test's >> `message' output, perhaps printing it only if the test fails. > > That's a good idea. How about opening a feature request to track it? Done as bug#59317. And with that, and Eli's commits, I'll close this bug. Thanks. ------------=_1668624902-18408-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 Nov 2022 22:53:20 +0000 Received: from localhost ([127.0.0.1]:55002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5Yt-0000qT-OQ for submit@debbugs.gnu.org; Fri, 04 Nov 2022 18:53:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:44386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5Yr-0000qL-48 for submit@debbugs.gnu.org; Fri, 04 Nov 2022 18:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5Yp-0004Qi-A0 for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 18:53:16 -0400 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5Yl-0003tJ-7R for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 18:53:13 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 5138140002 for ; Fri, 4 Nov 2022 22:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667602388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=NKaSjuhSwBF+jdBQW15YRSeYpXgnpUlmC+qcAjZ6J6I=; b=JIXBHMNvEkp7z1Ro3HXKqBb4X4HIgKeN8/eWzJGc1Nbv6VAX2mdyjLsAfomYVKyQNk7SnV KyqnK/7Kk2REh90NpEtK5e8J4qhBq9ZmaiUFHAK/awyxAFXvKcpWK/e5FIpepA01iee6sR iN7LYLuiY7BMDyfGR5+Omfga8ARsdsKK64H3iVR0LrjUum69wcN4/0lJgx4Dd0+U5ffOed n8KabrOI2L29I/htFfiE3OzS+fDjjnwbZEJHymQA9ilAYE55vlFYUunhDexWxwP3BvZx8K 9lS7L59BykWGr3xF36OeG/luMew2N0QxHoel5HY2OVW/LXuSMWa6F4cGdj4BNg== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1or5Yf-002BN3-1M for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 15:53:05 -0700 From: Matt Armstrong To: bug-gnu-emacs@gnu.org Subject: [PATCH] Rewrite the `kill-buffer-delete-auto-save' tests Date: Fri, 04 Nov 2022 15:53:05 -0700 Message-ID: <87o7tmwcvi.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2001:4b98:dc4:8::222; envelope-from=matt@rfc20.org; helo=relay2-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) 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: -2.6 (--) --=-=-= Content-Type: text/plain Tags: patch Rationale is in the commit description, but it boils down to these tests being annoying for me recently. I like to M-x eval-buffer and run tests interactively, but these tests seemed to work nicely only in batch mode. In interactive mode they would both fail and issue annoying prompts "save this modified buffer?" prompts. In fixing them, I figured out what they were trying to test and attempted to make that more robust and clear. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0003-Rewrite-the-kill-buffer-delete-auto-save-tests.patch >From c7a35edb0c62f5cc392f6748dbf409d5bbfa567c Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Fri, 4 Nov 2022 12:43:30 -0700 Subject: [PATCH 3/6] Rewrite the `kill-buffer-delete-auto-save' tests These tests had been annoying to me when run in interactive mode. They failed to bind `kill-buffer-delete-auto-save' as needed, so they depended on the user's settings, and they failed to mock out the "Buffer modified, save?" prompt. * test/src/buffer-tests.el (test-kill-buffer-auto-save): New helper function that mocks the two different kinds of prompts that occur when killing modified buffers that visit a file. Tests fail if expected prompts are not issued. (test-kill-buffer-auto-save-default): Use it, and explicitly bind `kill-buffer-delete-auto-save' to nil. (test-kill-buffer-auto-save-delete): Delete it. (test-kill-buffer-auto-save-delete-yes): New test for the "yes" half of the old `test-kill-buffer-auto-save-delete'. (test-kill-buffer-auto-save-delete-yes): Ditto for the "no" half. --- test/src/buffer-tests.el | 143 +++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 58 deletions(-) diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index a39d7d51de1..78da02fe0a6 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -8323,65 +8323,92 @@ test-remove-overlays (remove-overlays) (should (= (length (overlays-in (point-min) (point-max))) 0)))) -(ert-deftest test-kill-buffer-auto-save-default () - (ert-with-temp-file file - (let (auto-save) - ;; Always answer yes. - (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - (kill-buffer (current-buffer)) - (should (file-exists-p auto-save))) - (when auto-save - (ignore-errors (delete-file auto-save)))))))) - -(ert-deftest test-kill-buffer-auto-save-delete () +(defun test-kill-buffer-auto-save (auto-save-answer body-func) + "Test helper for `kill-buffer-delete-auto-save' tests. + +Call BODY-FUNC with the current buffer set to a buffer visiting a +temporary file. Around the call, mock the \"Buffer modified; +kill anyway?\" and \"Delete auto-save file?\" prompts, answering +\"yes\" for the former and AUTO-SAVE-ANSWER for the latter. The +expectation should be the characters `?y' or `?n', or `nil' if no +prompt is expected. The test fails if the \"Delete auto-save +file?\" prompt does not either prompt is not issued as expected. +Finally, kill the buffer and its temporary file." (ert-with-temp-file file - (let (auto-save) - (should (file-exists-p file)) - (setq kill-buffer-delete-auto-save-files t) - ;; Always answer yes. - (cl-letf (((symbol-function #'yes-or-no-p) (lambda (_) t))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - ;; This should delete the auto-save file. - (kill-buffer (current-buffer)) - (should-not (file-exists-p auto-save))) - (ignore-errors (delete-file file)) - (when auto-save - (ignore-errors (delete-file auto-save))))) - ;; Answer no to deletion. - (cl-letf (((symbol-function #'yes-or-no-p) - (lambda (prompt) - (not (string-search "Delete auto-save file" prompt))))) - (unwind-protect - (progn - (find-file file) - (auto-save-mode t) - (insert "foo\n") - (should buffer-auto-save-file-name) - (setq auto-save buffer-auto-save-file-name) - (do-auto-save) - (should (file-exists-p auto-save)) - ;; This should not delete the auto-save file. - (kill-buffer (current-buffer)) - (should (file-exists-p auto-save))) - (when auto-save - (ignore-errors (delete-file auto-save)))))))) + (should (file-exists-p file)) + (save-excursion + (find-file file) + (should (equal file (buffer-file-name))) + (let ((buffer (current-buffer)) + (auto-save-prompt-happened nil)) + (cl-letf (((symbol-function #'read-multiple-choice) + (lambda (prompt choices &rest _) + (should (string-search "modified; kill anyway?" prompt)) + (let ((answer (assq ?y choices))) + (should answer) + answer))) + ((symbol-function #'yes-or-no-p) + (lambda (prompt) + (should (string-search "Delete auto-save file?" prompt)) + (setq auto-save-prompt-happened t) + (pcase-exhaustive auto-save-answer + (?y t) + (?n nil))))) + (funcall body-func) + (should (equal (null auto-save-prompt-happened) + (null auto-save-answer)))) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (set-buffer-modified-p nil) + (kill-buffer))))))) + +(ert-deftest test-kill-buffer-auto-save-default () + (let ((kill-buffer-delete-auto-save-files nil)) + (test-kill-buffer-auto-save + nil + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + (kill-buffer (current-buffer)) + (should (file-exists-p auto-save))))))) + +(ert-deftest test-kill-buffer-auto-save-delete-yes () + (let ((kill-buffer-delete-auto-save-files t)) + (test-kill-buffer-auto-save + ?y + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + ;; This should delete the auto-save file. + (kill-buffer (current-buffer)) + (should-not (file-exists-p auto-save))))))) + +(ert-deftest test-kill-buffer-auto-save-delete-no () + (let ((kill-buffer-delete-auto-save-files t)) + (test-kill-buffer-auto-save + ?n + (lambda () + (let (auto-save) + (auto-save-mode t) + (insert "foo\n") + (should buffer-auto-save-file-name) + (setq auto-save buffer-auto-save-file-name) + (do-auto-save) + (should (file-exists-p auto-save)) + ;; This should not delete the auto-save file. + (kill-buffer (current-buffer)) + (should (file-exists-p auto-save)) + (delete-file auto-save)))))) (ert-deftest test-buffer-modifications () (ert-with-temp-file file -- 2.35.1 --=-=-=-- ------------=_1668624902-18408-1--