From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 ALMOEVNaq2NKQQEAbAwnHQ (envelope-from ) for ; Tue, 27 Dec 2022 21:49:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id gNkYEFNaq2OrKAAAG6o9tA (envelope-from ) for ; Tue, 27 Dec 2022 21:49:23 +0100 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 B1BC03E5D5 for ; Tue, 27 Dec 2022 21:49:22 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAGsM-0001w0-Tw; Tue, 27 Dec 2022 15:48:42 -0500 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 1pAGsL-0001vs-JX for emacs-orgmode@gnu.org; Tue, 27 Dec 2022 15:48:41 -0500 Received: from sender4-op-o12.zoho.com ([136.143.188.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAGsJ-0005gQ-HM for emacs-orgmode@gnu.org; Tue, 27 Dec 2022 15:48:41 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1672174114; cv=none; d=zohomail.com; s=zohoarc; b=V4aO+HT4mgPc0ieGvi0guSgQS4li5h3IffnY1/zXbhhQyvUJuvGQkU1qbvEYC5QhI04aENCvS9RcZ+yYtFE3IdOH9U8SDD3pwIo7xoZioSoWxvSQEe126Y+cUNL38ERrZO7N/CKuugsdV60lqLPyMUxT07QiBgmdgo/18tVa5P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672174114; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=zdIJO6c80uMo+AL3Zr5OlKOdMMfQV3eZyaqwTiWUuo4=; b=eLQ4Wpf8/Hac6v46VPKvIrlO6IWDeqE+jV34DGWTP5lqj8urVCF/u/Ej+bUlKAFwOdI/ZdCcakawMI7WYyI8h8IcldJTz52o3QHRGx3t7YzDmA+Vi4ils6gfE8WQu7wDo5oDBJzeNxZKgaH5KKaVPJcn2alzESTm3UJDaYJcqto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=excalamus.com; spf=pass smtp.mailfrom=matt@excalamus.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1672174114; s=zmail; d=excalamus.com; i=matt@excalamus.com; h=Date:Date:From:From:To:To:Cc:Cc:Message-Id:Message-Id:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Reply-To; bh=zdIJO6c80uMo+AL3Zr5OlKOdMMfQV3eZyaqwTiWUuo4=; b=Uv51deU5AWngEZKn1sfq8RgeBo51Ytnlv+2hy+J971MFtWF0MmZ9+f7GnN6BpeTL NdVfhxhy+UIOGPjfqLIXyEjOpmbjlimLqIf6Ocq3epySJyYly0htGYZ3nSZ6EPQqK9B Ua+uoxEu6YI6lqYwiRpV4Iv83Yu736d4iGQkL6Og= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1672174112220908.2942994779459; Tue, 27 Dec 2022 12:48:32 -0800 (PST) Date: Tue, 27 Dec 2022 15:48:32 -0500 From: Matt To: "Ihor Radchenko" Cc: "emacs-orgmode" Message-Id: <18555580d75.d7b471f9370716.1497263973038999899@excalamus.com> In-Reply-To: <1853354beb4.fce54d8d902653.6359367327256505471@excalamus.com> References: <878rj7s0ti.fsf@localhost> <1853354beb4.fce54d8d902653.6359367327256505471@excalamus.com> Subject: Re: ob-shell intentions and paperwork (was Bash results broken?) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1156018_505111957.1672174112117" Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Zoho-Virus-Status: 1 Received-SPF: pass client-ip=136.143.188.12; envelope-from=matt@excalamus.com; helo=sender4-op-o12.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=2; s=key1; d=yhetil.org; t=1672174163; a=rsa-sha256; cv=pass; b=SV7EnNypCjs55PGIz9fMXO68xrjCTgjBl6q5UuiySdCRn7lboNZMALIN/chzkrOjmxNna7 sBwi/4QM38y8BHk+7N3StqzKhynSyF054MgDSe2Dd73J54jBKKF15NT4lsi5N/4z8fQPKg J2SjrNUxmW6q/kRYivnt2zMTYISJ3yOloAqe73s3Cd2iOZVEvBza99UPS1kDG76naP1U1y NinBFpywumaLZrwRGwOAglrvr6pYnaDB+pToTYUhdy7KpA+rdCKBsl7BQDTKiWVKlAENEj 3x85BF/6ZSGg7G1IHCnEjKrh4bHnBPmDrQNg8yJLV7Wc6KP0YS6/nIm+nNFJOg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=Uv51deU5; 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"; dmarc=none; arc=pass ("zohomail.com:s=zohoarc:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672174163; 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=zdIJO6c80uMo+AL3Zr5OlKOdMMfQV3eZyaqwTiWUuo4=; b=CYjsUDx+d0uvcbrR7lOlqtl6XKsh863rodWB6xzHlHz6uHK+7fxTBH4s8GO9HwXnHB9Q29 zCvdMJTmqrEvLsVQdBBHTzacieIxLsFJxjIWidEJMOQvMYLcniRud+mMtQA2xKlJTwlXx+ qOJYcPH7oYcUE2b/JTiq4PedwK3usmBbFb/VOXopBGjWpj6/Iqu3Y9C4cdPt6INIdcM9j/ FK/nprJytQSHkQVx0zwC9aK3M94HgfsRM68Ccx9t0IlKc1eEaRuWlV+0iqyZ8CHhK+nJwx 9xOm625US+aKrsfRymb5crVwkkwQsFYpQEhcSVxO7Q3/inoUKzeaLouxdM/+EA== X-Spam-Score: -9.99 X-Migadu-Queue-Id: B1BC03E5D5 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=Uv51deU5; 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"; dmarc=none; arc=pass ("zohomail.com:s=zohoarc:i=1") X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -9.99 X-TUID: UNEOds3RAec+ ------=_Part_1156018_505111957.1672174112117 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit ---- On Wed, 21 Dec 2022 01:17:50 -0500 Matt wrote --- > Currently, though, I'm refactoring the ob-shell tests to remove dependency on ob-shell-test.org and to stop the suite from littering. Done. Branched off bugfix, 12e10eb0d, and refactored test-ob-shell.el. See attached patches. The main changes spanning the patches are: - tests are now standalone; they don't rely on ob-shell-test.org - tests now share a common prefix, "test-ob-shell". The entire suite runs with (ert "test-ob-shell") - buffers and processes created during a test are killed when the test passes > After that, I intend to incorporate the worg examples as tests. This is probably a good place for me to pause and get feedback before writing more code. I just got the signed paperwork back from Craig and am waiting to be admitted to the Emacs group on Savannah. ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0001-test-ob-shell.el-Remove-mixed-tabs-and-spaces.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121180090 Content-Disposition: attachment; filename=0001-test-ob-shell.el-Remove-mixed-tabs-and-spaces.patch >From ecdb71afa00ca137b4faa737393cb027907a7f9f Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Tue, 20 Dec 2022 13:51:26 -0500 Subject: [PATCH 01/20] test-ob-shell.el: Remove mixed tabs and spaces * test-ob-shell.el: Convert tabs to spaces. Change made under the premise that one or the other is better than both. --- testing/lisp/test-ob-shell.el | 58 +++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index b0d9beff4..816e93ac5 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -32,9 +32,9 @@ "Expanded shell bodies should not start with a blank line unless the body of the tangled block does." (should-not (string-match "^[\n\r][\t ]*[\n\r]" - (org-babel-expand-body:generic "echo 2" '()))) + (org-babel-expand-body:generic "echo 2" '()))) (should (string-match "^[\n\r][\t ]*[\n\r]" - (org-babel-expand-body:generic "\n\necho 2" '())))) + (org-babel-expand-body:generic "\n\necho 2" '())))) (ert-deftest test-ob-shell/dont-error-on-empty-results () "Was throwing an elisp error when shell blocks threw errors and @@ -49,8 +49,8 @@ ob-comint.el, which was not previously tested." (should (listp res))) ;; Test multi-line input. (let ((result (org-babel-execute:sh - "if true \n then \n echo yes \n fi" - '((:session . "yes"))))) + "if true \n then \n echo yes \n fi" + '((:session . "yes"))))) (should result) (should (string= "yes" result)))) @@ -71,47 +71,47 @@ ob-comint.el, which was not previously tested." "No associative arrays for generic" (should (equal "first one second two third three" - (org-test-at-id - "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" - (org-babel-next-src-block) - (org-trim (org-babel-execute-src-block))))) + (org-test-at-id + "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" + (org-babel-next-src-block) + (org-trim (org-babel-execute-src-block))))) (should (equal "bread 2 kg spaghetti 20 cm milk 50 dl" - (org-test-at-id - "82320a48-3409-49d7-85c9-5de1c6d3ff87" - (org-babel-next-src-block) - (org-trim (org-babel-execute-src-block)))))) + (org-test-at-id + "82320a48-3409-49d7-85c9-5de1c6d3ff87" + (org-babel-next-src-block) + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/bash-uses-assoc-arrays () "Bash associative arrays" (should (equal "two" - (org-test-at-id - "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" - (org-babel-next-src-block 2) - (org-trim (org-babel-execute-src-block))))) + (org-test-at-id + "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" + (org-babel-next-src-block 2) + (org-trim (org-babel-execute-src-block))))) ;; Bash associative arrays as strings for the row. (should (equal "20 cm" - (org-test-at-id - "82320a48-3409-49d7-85c9-5de1c6d3ff87" - (org-babel-next-src-block 2) - (org-trim (org-babel-execute-src-block)))))) + (org-test-at-id + "82320a48-3409-49d7-85c9-5de1c6d3ff87" + (org-babel-next-src-block 2) + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/simple-list () "Test list variables in shell." ;; With bash, a list is turned into an array. (should (equal "2" - (org-test-with-temp-text - "#+BEGIN_SRC bash :results output :var l='(1 2)\necho ${l[1]}\n#+END_SRC" - (org-trim (org-babel-execute-src-block))))) + (org-test-with-temp-text + "#+BEGIN_SRC bash :results output :var l='(1 2)\necho ${l[1]}\n#+END_SRC" + (org-trim (org-babel-execute-src-block))))) ;; On sh, it is a string containing all values. (should (equal "1 2" - (org-test-with-temp-text - "#+BEGIN_SRC sh :results output :var l='(1 2)\necho ${l}\n#+END_SRC" - (org-trim (org-babel-execute-src-block)))))) + (org-test-with-temp-text + "#+BEGIN_SRC sh :results output :var l='(1 2)\necho ${l}\n#+END_SRC" + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/remote-with-stdin-or-cmdline () "Test :stdin and :cmdline with a remote directory." @@ -166,9 +166,9 @@ ob-comint.el, which was not previously tested." "Test :results table." (should (equal '(("I \"want\" it all")) - (org-test-with-temp-text - "#+BEGIN_SRC sh :results table\necho 'I \"want\" it all'\n#+END_SRC" - (org-babel-execute-src-block))))) + (org-test-with-temp-text + "#+BEGIN_SRC sh :results table\necho 'I \"want\" it all'\n#+END_SRC" + (org-babel-execute-src-block))))) (ert-deftest ob-shell/results-list () "Test :results list." -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0002-test-ob-shell.el-Split-cases-into-two-tests.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121400000 Content-Disposition: attachment; filename=0002-test-ob-shell.el-Split-cases-into-two-tests.patch >From 3f712ecc2302a16514d0ce4b2dbb98f0330bc8a2 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Tue, 20 Dec 2022 13:53:44 -0500 Subject: [PATCH 02/20] test-ob-shell.el: Split cases into two tests * testing/lisp/test-ob-shell.el (test-ob-shell/dont-error-on-empty-results): Fix ambiguity in test name, docstring, and function. Explicitly test for empty results. (test-ob-shell/dont-error-on-babel-error): Explicitly test for babel error handling. Previously tested implicitly. On pass, remove buffers created during test. Two sources of errors exist: 1) empty results and 2) babel errors. Original test checked both, despite its name specifing only the first type. Change splits original test into two according type of error. --- testing/lisp/test-ob-shell.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 816e93ac5..625dc64b9 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -37,9 +37,11 @@ unless the body of the tangled block does." (org-babel-expand-body:generic "\n\necho 2" '())))) (ert-deftest test-ob-shell/dont-error-on-empty-results () - "Was throwing an elisp error when shell blocks threw errors and -returned empty results." - (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil)))) + (should (null (org-babel-execute:sh nil nil)))) + +(ert-deftest test-ob-shell/dont-error-on-babel-error () + (if (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil))) + (kill-buffer "*Org-Babel Error Output*"))) (ert-deftest test-ob-shell/session () "This also tests `org-babel-comint-with-output' in -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0003-test-ob-shell.el-Refactor-test-ob-shell-session.patch Content-Transfer-Encoding: base64 X-ZM_AttachId: 138914669121480000 Content-Disposition: attachment; filename=0003-test-ob-shell.el-Refactor-test-ob-shell-session.patch RnJvbSBjNjQzNTQ4NTRmNjAxNmNiMGFkMDdjOTBmNWU0NzRjOTdjZDc5MGRiIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXR0IFRyemNpbnNraSA8bWF0dEBleGNhbGFtdXMuY29tPgpE YXRlOiBUdWUsIDIwIERlYyAyMDIyIDE1OjIyOjM4IC0wNTAwClN1YmplY3Q6IFtQQVRDSCAwMy8y MF0gdGVzdC1vYi1zaGVsbC5lbDogUmVmYWN0b3IgdGVzdC1vYi1zaGVsbC9zZXNzaW9uCk1JTUUt VmVyc2lv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1iYWJl bC1leGVjdXRlOnNoCisgICAgICAgICAgICAgICAgICJlY2hvIDE7IGVjaG8gMiIKKyAgICAgICAg ICAgICAgICAgJygoOnNlc3Npb24gLiAidGVzdC1vYi1zaGVsbC9zZXNzaW9uLW11bHRpcGxlLXJl dHVybnMtcmV0dXJucy1saXN0IikpKSkpCisgICAgKHNob3VsZCByZXN1bHQpCisgICAgKHNob3Vs ZCAobGlzdHAgcmVzdWx0KSkKKyAgICAoaWYgKHNob3VsZCAoZXF1YWwgJygoMSkgKDIpKSByZXN1 bHQpKQorICAgICAgICAoa2lsbC1idWZmZXIgInRlc3Qtb2Itc2hlbGwvc2Vzc2lvbi1tdWx0aXBs ZS1yZXR1cm5zLXJldHVybnMtbGlzdCIpKSkpCiAKIDsgQSBsaXN0IG9mIHRlc3RzIHVzaW5nIHRo ZSBzYW1wbGVzIGluIG9iLXNoZWxsLXRlc3Qub3JnCiAoZXJ0LWRlZnRlc3Qgb2Itc2hlbGwvZ2Vu ZXJpYy11c2VzLW5vLWFycmF5cyAoKQotLSAKMi4zOC4xCgo= ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0004-test-ob-shell.el-Refactor-ob-shell-generic-uses-no-a.patch Content-Transfer-Encoding: base64 X-ZM_AttachId: 138914669121500000 Content-Disposition: attachment; filename=0004-test-ob-shell.el-Refactor-ob-shell-generic-uses-no-a.patch RnJvbSA1NWNhYWY1YzBmZTRmMmU5ZmU0YjFjM2NiMTc0MGVjMmE2MDcyYzdiIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXR0IFRyemNpbnNraSA8bWF0dEBleGNhbGFtdXMuY29tPgpE YXRlOiBUdWUsIDIwIERlYyAyMDIyIDE4OjEwOjUyIC0wNTAwClN1YmplY3Q6IFtQQVRDSCAwNC8y MF0gdGVzdC1vYi1zaGVsbC5lbDogUmVmYWN0b3IKIG9iLXNoZWxsL2dlbmVyaWMtdXNlcy1uby1h cnJheXMKCiogdGVz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vcnRzIHJlc3VsdHMgOnJlc3VsdHMgb3V0cHV0 IDp2YXIgYXJyYXk9c2FtcGxlX2FycmF5IgorICAgICAgICJlY2hvICR7YXJyYXl9IgorICAgICAg ICI8cG9pbnQ+IgorICAgICAgICIjK2VuZF9zcmMiKQogICAgIChzaG91bGQgKGVxdWFsICJvbmUg dHdvIHRocmVlIiAob3JnLXRyaW0gKG9yZy1iYWJlbC1leGVjdXRlLXNyYy1ibG9jaykpKSkpKQog CiAoZXJ0LWRlZnRlc3Qgb2Itc2hlbGwvYmFzaC11c2VzLWFycmF5cyAoKQotLSAKMi4zOC4xCgo= ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0005-test-ob-shell.el-Refactor-ob-shell-bash-uses-arrays.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121530000 Content-Disposition: attachment; filename=0005-test-ob-shell.el-Refactor-ob-shell-bash-uses-arrays.patch >From ebc48d2e7c3314d9669d212a237e319787974ab8 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Tue, 20 Dec 2022 18:16:17 -0500 Subject: [PATCH 05/20] test-ob-shell.el: Refactor ob-shell/bash-uses-arrays * test-ob-shell.el (ob-shell/bash-uses-arrays): Rename `ob-shell/bash-uses-arrays' to `test-ob-shell/bash-uses-arrays'. (ob-shell/bash-uses-arrays): Explain test in docstring. (ob-shell/bash-uses-arrays): Remove dependency on testing/examples/ob-shell-test.org. --- testing/lisp/test-ob-shell.el | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index df32b8aa7..4c70c07fb 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -96,10 +96,23 @@ the strings of the tangled block does." "#+end_src") (should (equal "one two three" (org-trim (org-babel-execute-src-block)))))) -(ert-deftest ob-shell/bash-uses-arrays () - "Bash arrays" - (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf" - (org-babel-next-src-block 2) +(ert-deftest test-ob-shell/bash-uses-arrays () + "Bash sees named array as a simple indexed array. + +In this test, we check that the returned value is indeed only the +first item of the array, as opposed to the generic serialiation +that will return all elements of the array as a single string." + (org-test-with-temp-text + (test-ob-shell-multiline-string + "#+NAME: sample_array" + "| one |" + "| two |" + "| three |" + "" + "#+begin_src bash :exports results :results output :var array=sample_array" + "echo ${array}" + "" + "#+end_src") (should (equal "one" (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/generic-uses-no-assoc-arrays () -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0006-test-ob-shell.el-Refactor-ob-shell-generic-uses-no-a.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121540010 Content-Disposition: attachment; filename=0006-test-ob-shell.el-Refactor-ob-shell-generic-uses-no-a.patch >From 021a950bff733730be99a3a9a124c5e66de66b4e Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Tue, 20 Dec 2022 19:22:40 -0500 Subject: [PATCH 06/20] test-ob-shell.el: Refactor ob-shell/generic-uses-no-assoc-arrays * test-ob-shell.el (ob-shell/generic-uses-no-assoc-arrays): Move headlines and commentary from `testing/examples/ob-shell-test.org' to docstring. (ob-shell/generic-uses-no-assoc-arrays): Remove dependency on testing/examples/ob-shell-test.org. (ob-shell/generic-uses-no-assoc-arrays): Split test based on simple versus complex mapping cases, `test-ob-shell/generic-uses-no-assoc-arrays-simple-map' and `test-ob-shell/generic-uses-no-assoc-arrays-3-columns'. Rename prefix from "ob-shell" to "test-ob-shell". --- testing/lisp/test-ob-shell.el | 53 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 4c70c07fb..5c77b088b 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -115,20 +115,45 @@ that will return all elements of the array as a single string." "#+end_src") (should (equal "one" (org-trim (org-babel-execute-src-block)))))) -(ert-deftest ob-shell/generic-uses-no-assoc-arrays () - "No associative arrays for generic" - (should - (equal "first one second two third three" - (org-test-at-id - "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" - (org-babel-next-src-block) - (org-trim (org-babel-execute-src-block))))) - (should - (equal "bread 2 kg spaghetti 20 cm milk 50 dl" - (org-test-at-id - "82320a48-3409-49d7-85c9-5de1c6d3ff87" - (org-babel-next-src-block) - (org-trim (org-babel-execute-src-block)))))) +(ert-deftest test-ob-shell/generic-uses-no-assoc-arrays-simple-map () + "Generic shell: no special handing for key-value mapping table + +No associative arrays for generic. The shell will see all values +as a single string." + (org-test-with-temp-text + (test-ob-shell-multiline-string + "#+NAME: sample_mapping_table" + "| first | one |" + "| second | two |" + "| third | three |" + "" + "#+begin_src sh :exports results :results output :var table=sample_mapping_table" + "echo ${table}" + "" + "#+end_src") + (should + (equal "first one second two third three" + (org-trim (org-babel-execute-src-block)))))) + +(ert-deftest test-ob-shell/generic-uses-no-assoc-arrays-3-columns () + "Associative array tests (more than 2 columns) + +No associative arrays for generic. The shell will see all values +as a single string." + (org-test-with-temp-text + (test-ob-shell-multiline-string + "#+NAME: sample_big_table" + "| bread | 2 | kg |" + "| spaghetti | 20 | cm |" + "| milk | 50 | dl |" + "" + "#+begin_src sh :exports results :results output :var table=sample_big_table" + "echo ${table}" + "" + "#+end_src") + (should + (equal "bread 2 kg spaghetti 20 cm milk 50 dl" + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/bash-uses-assoc-arrays () "Bash associative arrays" -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0007-test-ob-shell.el-Refactor-ob-shell-bash-uses-assoc-a.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121560000 Content-Disposition: attachment; filename=0007-test-ob-shell.el-Refactor-ob-shell-bash-uses-assoc-a.patch >From 5b24aa18ec1fe8d60968d6530b2373d487bd8e9f Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Wed, 21 Dec 2022 00:45:44 -0500 Subject: [PATCH 07/20] test-ob-shell.el: Refactor ob-shell/bash-uses-assoc-arrays * testing/lisp/test-ob-shell.el (ob-shell/bash-uses-assoc-arrays): Split test cases into separate tests, `test-ob-shell/bash-uses-assoc-arrays' and `test-ob-shell/bash-uses-assoc-arrays-with-lists'. Rename prefix from "ob-shell" to "test-ob-shell". (ob-shell/bash-uses-assoc-arrays): Move comments from testing/examples/ob-shell-test.org to docstrings. (ob-shell/bash-uses-assoc-arrays): Remove dependency on testing/examples/ob-shell-test.org. --- testing/lisp/test-ob-shell.el | 51 ++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 5c77b088b..a1cacdc16 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -155,21 +155,46 @@ as a single string." (equal "bread 2 kg spaghetti 20 cm milk 50 dl" (org-trim (org-babel-execute-src-block)))))) -(ert-deftest ob-shell/bash-uses-assoc-arrays () - "Bash associative arrays" - (should - (equal "two" - (org-test-at-id - "bec1a5b0-4619-4450-a8c0-2a746b44bf8d" - (org-babel-next-src-block 2) - (org-trim (org-babel-execute-src-block))))) - ;; Bash associative arrays as strings for the row. +(ert-deftest test-ob-shell/bash-uses-assoc-arrays () + "Bash shell: support for associative arrays + +Bash will see a table that contains the first column as the +'index' of the associative array, and the second column as the +value. " + (org-test-with-temp-text + (test-ob-shell-multiline-string + "#+NAME: sample_mapping_table" + "| first | one |" + "| second | two |" + "| third | three |" + "" + "#+begin_src bash :exports :results output results :var table=sample_mapping_table" + "echo ${table[second]}" + "" + "#+end_src") + (should + (equal "two" + (org-trim (org-babel-execute-src-block)))))) + +(ert-deftest test-ob-shell/bash-uses-assoc-arrays-with-lists () + "Bash shell: support for associative arrays with lists + +Bash will see an associative array that contains each row as a single +string. Bash cannot handle lists in associative arrays." + (org-test-with-temp-text + (test-ob-shell-multiline-string + "#+NAME: sample_big_table" + "| bread | 2 | kg |" + "| spaghetti | 20 | cm |" + "| milk | 50 | dl |" + "" + "#+begin_src bash :exports results :results output :var table=sample_big_table" + "echo ${table[spaghetti]}" + "" + "#+end_src") (should (equal "20 cm" - (org-test-at-id - "82320a48-3409-49d7-85c9-5de1c6d3ff87" - (org-babel-next-src-block 2) - (org-trim (org-babel-execute-src-block)))))) + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/simple-list () "Test list variables in shell." -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0008-test-ob-shell.el-Refactor-ob-shell-simple-list.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121580060 Content-Disposition: attachment; filename=0008-test-ob-shell.el-Refactor-ob-shell-simple-list.patch >From c05e7eaace70589546083c84ae78369c613c532d Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 21:16:42 -0500 Subject: [PATCH 08/20] test-ob-shell.el: Refactor ob-shell/simple-list * test-ob-shell.el (ob-shell/simple-list): Change test name from `ob-shell/simple-list' to `test-ob-shell/simple-list'. (ob-shell/simple-list): Use `test-ob-shell-multiline-string' to write source block on multiple lines. --- testing/lisp/test-ob-shell.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index a1cacdc16..085dc694d 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -196,20 +196,27 @@ string. Bash cannot handle lists in associative arrays." (equal "20 cm" (org-trim (org-babel-execute-src-block)))))) -(ert-deftest ob-shell/simple-list () - "Test list variables in shell." - ;; With bash, a list is turned into an array. +(ert-deftest test-ob-shell/simple-list () + "Test list variables." + ;; bash: a list is turned into an array (should (equal "2" (org-test-with-temp-text - "#+BEGIN_SRC bash :results output :var l='(1 2)\necho ${l[1]}\n#+END_SRC" + (test-ob-shell-multiline-string + "#+BEGIN_SRC bash :results output :var l='(1 2)" + "echo ${l[1]}" + "#+END_SRC") (org-trim (org-babel-execute-src-block))))) - ;; On sh, it is a string containing all values. + + ;; sh: a list is a string containing all values (should (equal "1 2" (org-test-with-temp-text - "#+BEGIN_SRC sh :results output :var l='(1 2)\necho ${l}\n#+END_SRC" - (org-trim (org-babel-execute-src-block)))))) + (test-ob-shell-multiline-string + "#+BEGIN_SRC sh :results output :var l='(1 2)" + "echo ${l}" + "#+END_SRC") + (org-trim (org-babel-execute-src-block)))))) (ert-deftest ob-shell/remote-with-stdin-or-cmdline () "Test :stdin and :cmdline with a remote directory." -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0009-test-ob-shell.el-Refactor-ob-shell-remote-with-stdin.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121600020 Content-Disposition: attachment; filename=0009-test-ob-shell.el-Refactor-ob-shell-remote-with-stdin.patch >From 2178b926cd9b2a3ee01e6fc6d0282372f4ff72bd Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 21:26:16 -0500 Subject: [PATCH 09/20] test-ob-shell.el: Refactor ob-shell/remote-with-stdin-or-cmdline * test-ob-shell.el (ob-shell/remote-with-stdin-or-cmdline): Change test name from `ob-shell/remote-with-stdin-or-cmdline' to `test-ob-shell/remote-with-stdin-or-cmdline'. (ob-shell/remote-with-stdin-or-cmdline): When test passes, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 085dc694d..d32cc9002 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -218,7 +218,7 @@ string. Bash cannot handle lists in associative arrays." "#+END_SRC") (org-trim (org-babel-execute-src-block)))))) -(ert-deftest ob-shell/remote-with-stdin-or-cmdline () +(ert-deftest test-ob-shell/remote-with-stdin-or-cmdline () "Test :stdin and :cmdline with a remote directory." ;; We assume `default-directory' is a local directory. (skip-unless (not (memq system-type '(ms-dos windows-nt)))) @@ -265,7 +265,8 @@ string. Bash cannot handle lists in associative arrays." (org-trim (org-babel-execute-src-block)))) (expected (concat "ARGS: --verbose 23 71" "\nhello tramp from " (file-local-name default-directory)))) - (should (equal result expected))))))) + (if (should (equal result expected)) + (kill-matching-buffers (format "\\*tramp/mock\\s-%s\\*" system-name) t t))))))) (ert-deftest ob-shell/results-table () "Test :results table." -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0010-test-ob-shell.el-Refactor-ob-shell-results-table.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121620010 Content-Disposition: attachment; filename=0010-test-ob-shell.el-Refactor-ob-shell-results-table.patch >From 02f510153a252655da8fe11ab662f59bdf281a21 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:14:19 -0500 Subject: [PATCH 10/20] test-ob-shell.el: Refactor ob-shell/results-table * test-ob-shell.el (ob-shell/results-table): Rename `ob-shell/results-table' to `test-ob-shell/results-table'. (ob-shell/results-table): Use `test-ob-shell-multiline-string' to write source block on multiple lines. --- testing/lisp/test-ob-shell.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index d32cc9002..87a10eaa3 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -268,12 +268,15 @@ string. Bash cannot handle lists in associative arrays." (if (should (equal result expected)) (kill-matching-buffers (format "\\*tramp/mock\\s-%s\\*" system-name) t t))))))) -(ert-deftest ob-shell/results-table () +(ert-deftest test-ob-shell/results-table () "Test :results table." (should (equal '(("I \"want\" it all")) (org-test-with-temp-text - "#+BEGIN_SRC sh :results table\necho 'I \"want\" it all'\n#+END_SRC" + (test-ob-shell-multiline-string + "#+BEGIN_SRC sh :results table" + "echo 'I \"want\" it all'" + "#+END_SRC") (org-babel-execute-src-block))))) (ert-deftest ob-shell/results-list () -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0011-test-ob-shell.el-Refactor-ob-shell-results-list.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121630020 Content-Disposition: attachment; filename=0011-test-ob-shell.el-Refactor-ob-shell-results-list.patch >From eef3d9ade6171c5469a366e4dffee0c63c949458 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:34:12 -0500 Subject: [PATCH 11/20] test-ob-shell.el: Refactor ob-shell/results-list * test-ob-shell.el (ob-shell/results-list): Rename `ob-shell/results-list' to `test-ob-shell/results-list'. (ob-shell/results-list): Use `test-ob-shell-multiline-string' to write source block on multiple lines. --- testing/lisp/test-ob-shell.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 87a10eaa3..93f4c45af 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -279,10 +279,15 @@ string. Bash cannot handle lists in associative arrays." "#+END_SRC") (org-babel-execute-src-block))))) -(ert-deftest ob-shell/results-list () +(ert-deftest test-ob-shell/results-list () "Test :results list." (org-test-with-temp-text - "#+BEGIN_SRC sh :results list\necho 1\necho 2\necho 3\n#+END_SRC" + (test-ob-shell-multiline-string + "#+BEGIN_SRC sh :results list" + "echo 1" + "echo 2" + "echo 3" + "#+END_SRC") (should (equal '((1) (2) (3)) (org-babel-execute-src-block))) -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0012-test-ob-shell.el-Refactor-ob-shell-standard-output-a.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121650150 Content-Disposition: attachment; filename=0012-test-ob-shell.el-Refactor-ob-shell-standard-output-a.patch >From 49378281e970d434d004c9e0ebc21f57dd0c3f56 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:36:51 -0500 Subject: [PATCH 12/20] test-ob-shell.el: Refactor ob-shell/standard-output-after-success * test-ob-shell.el (ob-shell/standard-output-after-success): Rename `ob-shell/standard-output-after-success' to `test-ob-shell/standard-output-after-success'. --- testing/lisp/test-ob-shell.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 93f4c45af..a3b2e9ee0 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -300,7 +300,7 @@ string. Bash cannot handle lists in associative arrays." ;;; Standard output -(ert-deftest ob-shell/standard-output-after-success () +(ert-deftest test-ob-shell/standard-output-after-success () "Test standard output after exiting with a zero code." (should (= 1 (org-babel-execute:sh -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0013-test-ob-shell.el-Refactor-ob-shell-standard-output-a.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121670020 Content-Disposition: attachment; filename=0013-test-ob-shell.el-Refactor-ob-shell-standard-output-a.patch >From ec9ae8226a895b1aecbb9037456b52649295563a Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:38:00 -0500 Subject: [PATCH 13/20] test-ob-shell.el: Refactor ob-shell/standard-output-after-failure * test-ob-shell.el (ob-shell/standard-output-after-failure): Rename `ob-shell/standard-output-after-failure' to `test-ob-shell/standard-output-after-failure'. (ob-shell/standard-output-after-failure): On pass, kill buffer created during test. --- testing/lisp/test-ob-shell.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index a3b2e9ee0..1742cf16f 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -306,11 +306,13 @@ string. Bash cannot handle lists in associative arrays." (org-babel-execute:sh "echo 1" nil)))) -(ert-deftest ob-shell/standard-output-after-failure () +(ert-deftest test-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)))) + (if + (should (= 1 + (org-babel-execute:sh + "echo 1; exit 2" nil))) + (kill-buffer "*Org-Babel Error Output*"))) ;;; Standard error -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0014-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121690000 Content-Disposition: attachment; filename=0014-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch >From 0e643556f41e1a14b77d9973b2e1034fd5f22da8 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:39:11 -0500 Subject: [PATCH 14/20] test-ob-shell.el: Refactor ob-shell/error-output-after-success * test-ob-shell.el (ob-shell/error-output-after-success): Rename `ob-shell/error-output-after-success' to `test-ob-shell/error-output-after-success'. (ob-shell/error-output-after-success): On pass, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 1742cf16f..9d0dea537 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -316,7 +316,7 @@ string. Bash cannot handle lists in associative arrays." ;;; Standard error -(ert-deftest ob-shell/error-output-after-success () +(ert-deftest test-ob-shell/error-output-after-success () "Test that standard error shows in the error buffer, alongside the exit code, after exiting with a zero code." (should -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0015-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121700080 Content-Disposition: attachment; filename=0015-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch >From 0b72f870ec8f079ab5f00d02f7768797e57a40b8 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:53:33 -0500 Subject: [PATCH 15/20] test-ob-shell.el: Refactor ob-shell/error-output-after-failure * test-ob-shell.el (ob-shell/error-output-after-failure): Rename `ob-shell/error-output-after-failure' to `test-ob-shell/error-output-after-failure'. (ob-shell/error-output-after-failure): On pass, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 9d0dea537..9ba09908b 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -319,26 +319,30 @@ string. Bash cannot handle lists in associative arrays." (ert-deftest test-ob-shell/error-output-after-success () "Test that standard error shows in the error buffer, alongside the exit code, after exiting with a zero code." - (should - (string= "1 + (if + (should + (string= "1 [ Babel evaluation exited with code 0 ]" - (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)))))) + (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))))) + (kill-buffer "*Org-Babel Error Output*"))) -(ert-deftest ob-shell/error-output-after-failure () +(ert-deftest test-ob-shell/error-output-after-failure () "Test that standard error shows in the error buffer, alongside the exit code, after exiting with a non-zero code." - (should - (string= "1 + (if + (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)))))) + (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))))) + (kill-buffer "*Org-Babel Error Output*"))) (ert-deftest ob-shell/error-output-after-failure-multiple () "Test that multiple standard error strings show in the error -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0016-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121720030 Content-Disposition: attachment; filename=0016-test-ob-shell.el-Refactor-ob-shell-error-output-afte.patch >From f2f56a6919d877e36d95ab33dce3b1fcd1e9bcf9 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:55:34 -0500 Subject: [PATCH 16/20] test-ob-shell.el: Refactor ob-shell/error-output-after-failure-multiple * test-ob-shell.el (ob-shell/error-output-after-failure-multiple): Rename `ob-shell/error-output-after-failure-multiple' to `test-ob-shell/error-output-after-failure-multiple'. (ob-shell/error-output-after-failure-multiple): On pass, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index 9ba09908b..fb58e70e1 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -344,21 +344,23 @@ exit code, after exiting with a non-zero code." (buffer-string))))) (kill-buffer "*Org-Babel Error Output*"))) -(ert-deftest ob-shell/error-output-after-failure-multiple () +(ert-deftest test-ob-shell/error-output-after-failure-multiple () "Test that multiple standard error strings show in the error buffer, alongside multiple exit codes." - (should - (string= "1 + (if + (should + (string= "1 [ Babel evaluation exited with code 2 ] 3 [ Babel evaluation exited with code 4 ]" - (progn (org-babel-eval-wipe-error-buffer) - (org-babel-execute:sh - "echo 1 >&2; exit 2" nil) - (org-babel-execute:sh - "echo 3 >&2; exit 4" nil) - (with-current-buffer org-babel-error-buffer-name - (buffer-string)))))) + (progn (org-babel-eval-wipe-error-buffer) + (org-babel-execute:sh + "echo 1 >&2; exit 2" nil) + (org-babel-execute:sh + "echo 3 >&2; exit 4" nil) + (with-current-buffer org-babel-error-buffer-name + (buffer-string))))) + (kill-buffer "*Org-Babel Error Output*"))) ;;; Exit codes -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0017-test-ob-shell.el-Refactor-ob-shell-exit-code.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121740040 Content-Disposition: attachment; filename=0017-test-ob-shell.el-Refactor-ob-shell-exit-code.patch >From a02faa555d218ff6c042eb6590b106deedd77ecb Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:57:12 -0500 Subject: [PATCH 17/20] test-ob-shell.el: Refactor ob-shell/exit-code * test-ob-shell.el (ob-shell/exit-code): Rename `ob-shell/exit-code' to `test-ob-shell/exit-code'. (ob-shell/exit-code): On pass, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index fb58e70e1..be9d1488d 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -364,16 +364,18 @@ buffer, alongside multiple exit codes." ;;; Exit codes -(ert-deftest ob-shell/exit-code () +(ert-deftest test-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)))))) + (if + (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))))) + (kill-buffer "*Org-Babel Error Output*"))) (ert-deftest ob-shell/exit-code-multiple () "Test that multiple exit codes show in the error buffer after -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0018-test-ob-shell.el-Refactor-ob-shell-exit-code-multipl.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121760030 Content-Disposition: attachment; filename=0018-test-ob-shell.el-Refactor-ob-shell-exit-code-multipl.patch >From b879fceda8e211bf4a0930474f36a8e48d935191 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Fri, 23 Dec 2022 22:58:50 -0500 Subject: [PATCH 18/20] test-ob-shell.el: Refactor ob-shell/exit-code-multiple * test-ob-shell.el (ob-shell/exit-code-multiple): Rename `ob-shell/exit-code-multiple' to `test-ob-shell/exit-code-multiple'. (ob-shell/exit-code-multiple): On pass, kill buffer created by test. --- testing/lisp/test-ob-shell.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el index be9d1488d..e4a9849c6 100644 --- a/testing/lisp/test-ob-shell.el +++ b/testing/lisp/test-ob-shell.el @@ -377,19 +377,21 @@ with a non-zero return code." (buffer-string))))) (kill-buffer "*Org-Babel Error Output*"))) -(ert-deftest ob-shell/exit-code-multiple () +(ert-deftest test-ob-shell/exit-code-multiple () "Test that multiple exit codes show in the error buffer after exiting with a non-zero return code multiple times." - (should - (string= "[ Babel evaluation exited with code 1 ] + (if + (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)))))) + (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))))) + (kill-buffer "*Org-Babel Error Output*"))) (provide 'test-ob-shell) -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0019-ob-shell-test.org-Remove-ob-shell-test.org.patch Content-Transfer-Encoding: 7bit X-ZM_AttachId: 138914669121770050 Content-Disposition: attachment; filename=0019-ob-shell-test.org-Remove-ob-shell-test.org.patch >From 07a74181f5cf0f90eaea3abd296a5cf7254b3454 Mon Sep 17 00:00:00 2001 From: Matt Trzcinski Date: Sat, 24 Dec 2022 11:29:06 -0500 Subject: [PATCH 19/20] ob-shell-test.org: Remove ob-shell-test.org * testing/examples/ob-shell-test.org: Delete file File was used by test-ob-shell.el to test ob-shell.el. Tests have been updated to use temporary buffers, rendering ob-shell-test.org unnecessary. --- testing/examples/ob-shell-test.org | 88 ------------------------------ 1 file changed, 88 deletions(-) delete mode 100644 testing/examples/ob-shell-test.org diff --git a/testing/examples/ob-shell-test.org b/testing/examples/ob-shell-test.org deleted file mode 100644 index 2510f4f96..000000000 --- a/testing/examples/ob-shell-test.org +++ /dev/null @@ -1,88 +0,0 @@ -#+Title: a collection of examples for ob-shell tests -#+OPTIONS: ^:nil - -* Sample data structures -#+NAME: sample_array -| one | -| two | -| three | - -#+NAME: sample_mapping_table -| first | one | -| second | two | -| third | three | - -#+NAME: sample_big_table -| bread | 2 | kg | -| spaghetti | 20 | cm | -| milk | 50 | dl | - -* Array tests - :PROPERTIES: - :ID: 0ba56632-8dc1-405c-a083-c204bae477cf - :END: -** Generic shell: no arrays -#+begin_src sh :exports results :results output :var array=sample_array -echo ${array} -#+end_src - -#+RESULTS: -: one two three - -** Bash shell: support for arrays -Bash will see a simple indexed array. In this test, we check that the -returned value is indeed only the first item of the array, as opposed to -the generic serialiation that will return all elements of the array as -a single string. -#+begin_src bash :exports results :results output :var array=sample_array -echo ${array} -#+end_src - -#+RESULTS: -: one - -* Associative array tests (simple map) - :PROPERTIES: - :ID: bec1a5b0-4619-4450-a8c0-2a746b44bf8d - :END: -** Generic shell: no special handing -The shell will see all values as a single string. -#+begin_src sh :exports results :results output :var table=sample_mapping_table -echo ${table} -#+end_src - -#+RESULTS: -: first one second two third three - -** Bash shell: support for associative arrays -Bash will see a table that contains the first column as the 'index' -of the associative array, and the second column as the value. -#+begin_src bash :exports :results output results :var table=sample_mapping_table -echo ${table[second]} -#+end_src - -#+RESULTS: -: two - -* Associative array tests (more than 2 columns) - :PROPERTIES: - :ID: 82320a48-3409-49d7-85c9-5de1c6d3ff87 - :END: -** Generic shell: no special handing -#+begin_src sh :exports results :results output :var table=sample_big_table -echo ${table} -#+end_src - -#+RESULTS: -: bread 2 kg spaghetti 20 cm milk 50 dl - -** Bash shell: support for associative arrays with lists -Bash will see an associative array that contains each row as a single -string. Bash cannot handle lists in associative arrays. -#+begin_src bash :exports results :results output :var table=sample_big_table -echo ${table[spaghetti]} -#+end_src - -#+RESULTS: -: 20 cm - -- 2.38.1 ------=_Part_1156018_505111957.1672174112117 Content-Type: application/octet-stream; name=0020-test-ob-shell.el-Organize-tests.patch Content-Transfer-Encoding: base64 X-ZM_AttachId: 138914669121790000 Content-Disposition: attachment; filename=0020-test-ob-shell.el-Organize-tests.patch RnJvbSA5ZjM1MmJiYmZjNGI0OWQzYWNkNjkwMzI4YThlNDNiYTEzNGJhYTgzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXR0IFRyemNpbnNraSA8bWF0dEBleGNhbGFtdXMuY29tPgpE YXRlOiBTdW4sIDI1IERlYyAyMDIyIDIzOjI1OjIxIC0wNTAwClN1YmplY3Q6IFtQQVRDSCAyMC8y MF0gdGVzdC1vYi1zaGVsbC5lbDogT3JnYW5pemUgdGVzdHMKCiogdGVzdGluZy9saXNwL3Rlc3Qt b2Itc2hlbGwuZWw6CgogIC0gUHJvdmlkZSBpbnN0cnVjdGlvbnMgZm9yIHJ1bm5pbmcgdGVzdHMK ICAtIFJlcXVpcmUgYG9yZy10ZXN0JyBleHBsaWNpdGx5CiAgLSBHcm91cCB0ZXN0cyBpbnRvIHNl Y3Rpb25zCiAgLSBJbnNlcnQgYHBhZ2UtZGVsaW1pdGVyJ3MgYmV0d2VlbiBzZWN0aW9ucwotLS0K IHRlc3RpbmcvbGl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