From unknown Fri Jun 20 07:16:51 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#65851 <65851@debbugs.gnu.org> To: bug#65851 <65851@debbugs.gnu.org> Subject: Status: 29.1.50; `ert-simulate-command' and non-local exits Reply-To: bug#65851 <65851@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:16:51 +0000 retitle 65851 29.1.50; `ert-simulate-command' and non-local exits reassign 65851 emacs submitter 65851 Sebastian Miele severity 65851 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 10 06:17:23 2023 Received: (at submit) by debbugs.gnu.org; 10 Sep 2023 10:17:23 +0000 Received: from localhost ([127.0.0.1]:49110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfHVL-0007m6-A3 for submit@debbugs.gnu.org; Sun, 10 Sep 2023 06:17:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfHVF-0007lp-Gf for submit@debbugs.gnu.org; Sun, 10 Sep 2023 06:17:21 -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 1qfHV6-0001P6-AU for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 06:17:08 -0400 Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1qfHUs-0005Rq-2I for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 06:16:57 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Rk5Ns6Kf9z9skg for ; Sun, 10 Sep 2023 12:16:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whxvd.name; s=MBO0001; t=1694341005; 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; bh=jkkvHnJRJ3NkwElyz9NDzT5iicqgBgyeEghf0pKB2do=; b=knquPu5XPL6G9u4wE7TUJeKkZmv2co9xFmCzpixNfxNqLIFtDt+FrpL2vD1E8UWor9mVtj zK7KUO5aVL57Vg7lhak/hPNkVhV1qp16byrcoRVQKu1X7nzdBxy3gAuQIhkqHJvtNCNDBx i0v66J1UocDXCJcj2AnmRZtk4sK6E1M7vOcYCoH2W0uupaX0OVWJIFJ+//VEQS7HOfWGpt tTfSDz42pAyUi5cE09JYaWcZegna4/VaP59D9jzsl8n0W1DYH7t/mcvlc8bXA6P6MmDx9g /Y+ZFFaY0Hrb9EqeJpJCoH0/sFcPt6fjb/z6vxaeYOlHTvQ7XWMSoJdGEvlh3w== From: Sebastian Miele To: bug-gnu-emacs@gnu.org Subject: 29.1.50; `ert-simulate-command' and non-local exits Date: Sun, 10 Sep 2023 11:49:07 +0200 Message-ID: <87v8cixrhv.fsf@whxvd.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2001:67c:2050:0:465::202; envelope-from=iota@whxvd.name; helo=mout-p-202.mailbox.org 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: 0.7 (/) 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: -0.3 (/) In GNU Emacs 29.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-09-06 built on huette When a command exits non-locally (e.g., by calling `user-error'), the command loop seems to still do what `ert-simulate-command' in that case currently does not (e.g., run `post-command-hook', and set `last-command'). At the moment, the Emacs sources have less than 40 uses of `ert-simulate-command'. None of them seems to be wrapped in anything like `(should-error =E2=80=A6)'. So this has not become an issue in Emacs testing so far. Also, in the tests I am currently writing, I could live without `ert-simulate-command' handling non-local exits like the command loop does, because I do not need `ert-simulate-command' in that particular cases. I do not really know the details of what the command loop actually does. But wouldn't something like the following be more "in line" with what the command loop does? diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 98a017c8a8e..e7c670b27c9 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -173,28 +173,26 @@ ert-simulate-command (cl-assert (listp command) t) (cl-assert (commandp (car command)) t) (cl-assert (not unread-command-events) t) - (let (return-value) - ;; For the order of things here see command_loop_1 in keyboard.c. - ;; - ;; The command loop will reset the command-related variables so - ;; there is no reason to let-bind them. They are set here, - ;; however, to be able to test several commands in a row and how - ;; they affect each other. - (setq deactivate-mark nil - this-original-command (car command) - ;; remap through active keymaps - this-command (or (command-remapping this-original-command) - this-original-command)) - (run-hooks 'pre-command-hook) - (setq return-value (apply (car command) (cdr command))) + ;; For the order of things here see command_loop_1 in keyboard.c. + ;; + ;; The command loop will reset the command-related variables so + ;; there is no reason to let-bind them. They are set here, + ;; however, to be able to test several commands in a row and how + ;; they affect each other. + (setq deactivate-mark nil + this-original-command (car command) + ;; remap through active keymaps + this-command (or (command-remapping this-original-command) + this-original-command)) + (run-hooks 'pre-command-hook) + (unwind-protect (apply (car command) (cdr command)) (run-hooks 'post-command-hook) (setq real-last-command (car command) last-command this-command) (when (boundp 'last-repeatable-command) (setq last-repeatable-command real-last-command)) (when (and deactivate-mark transient-mark-mode) (deactivate-mark)) - (cl-assert (not unread-command-events) t) - return-value)) + (cl-assert (not unread-command-events) t))) =20 (defmacro ert-simulate-keys (keys &rest body) "Execute BODY with KEYS as pseudo-interactive input."