From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2AY0C/khWWMNUAEAbAwnHQ (envelope-from ) for ; Wed, 26 Oct 2022 14:03:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id ELA5C/khWWN4hwAA9RJhRA (envelope-from ) for ; Wed, 26 Oct 2022 14:03:05 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9A5AE8B54 for ; Wed, 26 Oct 2022 14:03:04 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onf1d-0001mw-D6; Wed, 26 Oct 2022 07:56:50 -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 1onf1a-0001ml-BT for emacs-orgmode@gnu.org; Wed, 26 Oct 2022 07:56:47 -0400 Received: from mr85p00im-ztdg06021801.me.com ([17.58.23.195]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onf1Y-0006El-MR for emacs-orgmode@gnu.org; Wed, 26 Oct 2022 07:56:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1666785402; bh=WaEmARwLNR8tuLOG4LUNjF5TqJ8Hwl+hm+KYpJcx4u8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oRDjXCpwkTIJqYY0OTJYaLRGFCL4EDuKqm7jEXnuyHmxRZfWEYw9ZIrrAyTUNSS56 6IndgOxDSjozuRTTmkRhkFx5opZOg3IGGS5X35n8V8qtUUfj2oFp/+SKjxu9Zzu11D 0Ba0Tt28gTYs9yXqtlfC0pjxYtBW3G3DULjeHuapjofwdC/G3+ThWSjxtHiHvGbDJb kUbgYivOenMiK4+wuFOncYeVgYmJcfJm3AP1Ab59NpLO0iVndau/lnUUgnnZSf03UA LFR+MDvzQehB4nHhllPwbHaj4SIavqJRSI2ln32dEQ1YbgDtc1Fgin2wJZP2fty6d2 I4X4qX7q8/d+w== Received: from Rudolfs-MacBook-Air.local (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-ztdg06021801.me.com (Postfix) with ESMTPSA id 933F5D00E24; Wed, 26 Oct 2022 11:56:40 +0000 (UTC) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: Ihor Radchenko Cc: Ihor Radchenko , emacs-orgmode@gnu.org Subject: Re: Org 9.6-pre and Bash sessions In-Reply-To: <87fsffqi49.fsf@localhost> References: <87edvbysqc.fsf@localhost> <87r0z6j1b1.fsf@localhost> <87pmel68y6.fsf@localhost> <87o7u432tl.fsf@localhost> <87a65o15ut.fsf@localhost> <87fsffqi49.fsf@localhost> Date: Wed, 26 Oct 2022 13:56:37 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Proofpoint-GUID: W6D6apoCYLkXPRbJh4s-vxyc2B0I4iUQ X-Proofpoint-ORIG-GUID: W6D6apoCYLkXPRbJh4s-vxyc2B0I4iUQ X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.425,18.0.816,17.11.62.513.0000000_definitions?= =?UTF-8?Q?=3D2022-01-18=5F01:2022-01-14=5F01,2022-01-18=5F01,2021-12-02?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260067 Received-SPF: pass client-ip=17.58.23.195; envelope-from=salutis@me.com; helo=mr85p00im-ztdg06021801.me.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666785785; h=from:from:sender:sender: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=WaEmARwLNR8tuLOG4LUNjF5TqJ8Hwl+hm+KYpJcx4u8=; b=Wmy+DYlW10Gi0QAfWABCqAqaNz+C/AOUqtzOQ0zxrmZ6NT37A+UGayKyhj3iOLl6vwfpCF YnSy2Qj/BOP6B3y9Cuj6WrM7LNfAW9z2axa8DYSQMU9ZGrpJ+acU7MUzK5uTATRASV0BKx ZmPlmMlmAdWPNOTpo2AfFHxVKCbN6Adc2brmG0Rj2DOZZ9Q/Z9IjmjqzDni9UgpFPgGvEm zayGb834J7YEoGjavsy+QUyZL3yrLC6NeWrfZB2GXlK8ngGDVGYufqUZeF3PzMMckzSbT1 cmc0t6yNMVWwJgszntp8UxOQf+WFqa5UmkfzBm+GK2/nVqJoQyFD9XDj1ZTRIA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666785785; a=rsa-sha256; cv=none; b=LAPi+pO6vAgrP91Tm+tC8r+pdiReZNewitgdRZ7QMbVbEifTkgUJh9ErTf1Xg7NFzaIuaE ilbmatbNrLcRkItHUFqHPUxsFsmbgjQ7L+hPo498UZP1cZZBLjLE6AoZBSmRBZz4qnVvA+ gcRqPUUlq03+Y1r6IMEdRxMEZlMSZaIqFX9/wXYPZAA1a0B5MunBAw2UB18pKjSQJ7XiS3 PY6ZwNJkFW+KisyRmL6fSCudrei/WictFn9EDwkUXARBGSBKPbHrUw7llIjhQuw7ze/S37 f1InefJuXLHZp/McngtkXGBPPgorqfWz2zIpGkqpXoI+w0pQeUj+wIbJ0NNCOA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=oRDjXCpw; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.02 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=oRDjXCpw; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9A5AE8B54 X-Spam-Score: -4.02 X-Migadu-Scanner: scn0.migadu.com X-TUID: Id1LD2UVpe3f --=-=-= Content-Type: text/plain Ihor, Thank you for investigating, explaining, and also fixing the problem! I pulled the latest 'main' and everything works a bit, it seems. Then, to avoid walking in circles, I decided to write some tests, for I think shell blocks should never, never, never break in such basic ways, let alone in production Emacs. Please, see the WIP patch attached to this message. I noticed that the following tests do not pass: 1. ob-shell/error-output-after-success We seem to trash error output, such as warnings, on success. I think we should not do this. Now, on the execution of "echo X &>2", Org says "Code block produced no output." But that does hold true. The block did produce output, just on the other output stream, namely error output. 2. ob-shell/error-output-after-failure We seem not to show the exit code in this case. Why? 3. ob-shell/exit-codes Should we add a newline after the exit code message? Rudy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-WIP-test-ob-shell-Add-tests-for-some-recent-changes.patch >From 90432170552a6e922d48d51138b2062aa11e5575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= Date: Wed, 26 Oct 2022 13:35:26 +0200 Subject: [PATCH] WIP test-ob-shell: Add tests for some recent changes --- testing/lisp/test-ob-shell.el | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 4c00faa49..8cd967343 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -170,6 +170,66 @@ ob-comint.el, which was not previously tested." "#+BEGIN_SRC sh :results table\necho 'I \"want\" it all'\n#+END_SRC" (org-babel-execute-src-block))))) +;;; Standard output + +(ert-deftest ob-shell/standard-output-after-failure () + "Test standard output after exiting with a non-zero code." + (should (= 1 + (org-babel-execute:sh + "echo 1; exit 2" nil)))) + +;;; Error output + +(ert-deftest ob-shell/error-output-after-success () + "Test that error output shows in the error buffer after exiting +with a zero code." + (should + (string= "1 +[ Babel evaluation exited with code 2 ]" + (progn (org-babel-eval-wipe-error-buffer) + (org-babel-execute:sh + "echo 1 >&2" nil) + (with-current-buffer org-babel-error-buffer-name + (buffer-string)))))) + +(ert-deftest ob-shell/error-output-after-failure () + "Test that error output shows in the error buffer, alongside the +exit code, after exiting with a non-zero code." + (should + (string= "1 +[ Babel evaluation exited with code 2 ]" + (progn (org-babel-eval-wipe-error-buffer) + (org-babel-execute:sh + "echo 1 >&2; exit 2" nil) + (with-current-buffer org-babel-error-buffer-name + (buffer-string)))))) + +;;; Exit codes + +(ert-deftest ob-shell/exit-code () + "Test that the exit code shows in the error buffer after exiting +with a non-zero return code." + (should + (string= "[ Babel evaluation exited with code 1 ]" + (progn (org-babel-eval-wipe-error-buffer) + (org-babel-execute:sh + "exit 1" nil) + (with-current-buffer org-babel-error-buffer-name + (buffer-string)))))) + +(ert-deftest ob-shell/exit-codes () + "Test that multiple exit codes show in the error buffer after +exiting with a non-zero return code more than once." + (should + (string= "[ Babel evaluation exited with code 1 ] +[ Babel evaluation exited with code 2 ]" + (progn (org-babel-eval-wipe-error-buffer) + (org-babel-execute:sh + "exit 1" nil) + (org-babel-execute:sh + "exit 2" nil) + (with-current-buffer org-babel-error-buffer-name + (buffer-string)))))) (provide 'test-ob-shell) -- 2.38.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 "One can begin to reason only when a clear picture has been formed in the imagination." -- Walter Warwick Sawyer, Mathematician's Delight, 1943 Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia --=-=-=--