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 6IqqFB2r7WOADwEAbAwnHQ (envelope-from ) for ; Thu, 16 Feb 2023 05:03:41 +0100 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 wFnWFB2r7WOGRQEA9RJhRA (envelope-from ) for ; Thu, 16 Feb 2023 05:03:41 +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 18B0D393CC for ; Thu, 16 Feb 2023 05:03:40 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=S9mrPudk; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; 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" ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676520220; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ZYH+Q6Vnxrya01HSWCFBNtPiNO2OOlh7AafZtS9cIk4=; b=p2ToTPznYpi1yRXxwVnrpqXZf855/lYdUVF33hFCR+NyliGyipgqAOZpb6zJejIM2VwEea nPWThL4A78Mr9Rmt1cgVZHrxvrnadHKZHYyqGpy76eVlM6LWk1LRWfUXIPJ73F1nQD3Y65 cDub1RsXKQd1GQnivBmZ94q2HPe5nZ1uymJy10JoR+W3t+oGnsSNauR67FYyxJMn4BZsvt X9kUCBAUS02UZyd0wEKlUizzNO+OavkQSfGJ7wRl+Kh6qDjdmLyhvrIRffll0N4g3GWNLl AijeNHLUBpvupV+pBIDFptQ0w7GCyUp02bi3FO1HITjGsPoQGdY9Sz+R3aFEbA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=excalamus.com header.s=zmail header.b=S9mrPudk; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; 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" ARC-Seal: i=2; s=key1; d=yhetil.org; t=1676520220; a=rsa-sha256; cv=pass; b=mS/mA/QC0MpBFeiUGxNoRWCfXzOvegCH4RGcIdgsPLmyfmjm27cMOTA65Sh0M0lfobFF6V Nc6clpQWarpN6E6XOgPXPzevh6cYErqJD8h57G7bm443Nox42LZOkCcwvdL6e/l+SPUkcB kKrIHOmk13VImyYzIPNM6+LpT5V90e+CtI+06FXHZL2/krT1XleD9uSvM1IoL4uYz+sf6S wsJ9pHjhDM3N/tlVK+jPf4MT4rpft6+Mz+L467tB58J1QhBpKAaEp2fIKsWgzK/5faNW5e g+dOY0/GKaqb7Me7QzTBH4DvlCcYdRfSwmcNG3QZDZg9Q98EVwDlsIb7y9dh8A== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSVU4-0001fr-15; Wed, 15 Feb 2023 23:03:00 -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 1pSVTz-0001es-ON for emacs-orgmode@gnu.org; Wed, 15 Feb 2023 23:02:56 -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 1pSVTy-0004a4-06 for emacs-orgmode@gnu.org; Wed, 15 Feb 2023 23:02:55 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1676520168; cv=none; d=zohomail.com; s=zohoarc; b=c1PxOYHi0rQKLPKdKi0hj01oN5ZKvlTqp2OmZUqs2Kyq24kZihDDV6VYEdQwG/TqxUXC0C0OSN2fPOvqAXOc8Wz0sjyGHq1QSeh5/gTV82IxIGtS7PMN5spkwfnUeEjRL4e55gfX3p9pehf5T3gagOh7uBHPwPqhMHrwId6Qy4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676520168; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ZYH+Q6Vnxrya01HSWCFBNtPiNO2OOlh7AafZtS9cIk4=; b=Nkn+3rrvhqMtOZZ4omGv42464/RMqJ1uSWFAjsTWdj6DrinDSP+j8WKuR4uTxRq7BmTw4egbpX5Du2fmNDCkSVAwG+GaTX9JOSnO+TkJnkBRfPxS+ys+unk2pR5d4cX5ureNG253Bik4L9lY4XIrmcUSEUSQumfSYcCNn2rUMrg= 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=1676520168; s=zmail; d=excalamus.com; i=matt@excalamus.com; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=ZYH+Q6Vnxrya01HSWCFBNtPiNO2OOlh7AafZtS9cIk4=; b=S9mrPudkOcQ9n3HSqntfr0+IKakq4CkDTL0tUmGWUi54ahZMBr4Dy9xg5imZZQoZ blKjCViMOfhot+19+JXEGDD1uXzK63S4AgSWzf692J4WzOHtuq0NbIRL74FYkcp8Vfx iXDsBd8o6chNEJl6NMhbkLeaXXsvEef4+Z7tqMXA= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1676520167999478.9809869528816; Wed, 15 Feb 2023 20:02:47 -0800 (PST) Date: Wed, 15 Feb 2023 23:02:47 -0500 From: Matt To: "Ihor Radchenko" Cc: "emacs-orgmode" Message-ID: <18658639a30.dec640641420614.2364646537016397698@excalamus.com> In-Reply-To: <87sff73r0g.fsf@localhost> References: <186283d230a.129f5feb61660123.3289004102603503414@excalamus.com> <87v8kd8zzw.fsf@localhost> <1863472efe9.10fdd5ba4258906.5972264927968042941@excalamus.com> <87y1p7axpe.fsf@localhost> <1863d69188f.11e078bd1228881.451172865246440158@excalamus.com> <87fsbcbf47.fsf@localhost> <186471d8980.c36aecd0374444.2548279362371712281@excalamus.com> <87sff73r0g.fsf@localhost> Subject: Re: [PATCH] Async evaluation in ob-shell MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail 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: X-Migadu-Queue-Id: 18B0D393CC X-Spam-Score: -9.96 X-Migadu-Spam-Score: -9.96 X-Migadu-Scanner: scn0.migadu.com 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 X-TUID: GzHfx1+aRHRM ---- On Wed, 15 Feb 2023 10:08:47 -0500 Ihor Radchenko wrote --- > Matt matt@excalamus.com> writes: > > > Checking the final result from the callback is trickier. The following works, but requires advice (which could potentially persist beyond the test) and a delay (which slows testing overall and whose duration likely depends on the hardware the test runs on). Without the delay, I could not get the callback to execute within the test. It would execute when running manually in an Org buffer, however. I'm not sure why. > > Doesn't (while ... (sleep-for ...)) work? I'm afraid I don't follow what you mean. My biggest concern is the sleep-for itself. Aside from the concerns above, the test doesn't work without it. For example, the check made by the advice looks for "1\n2\n". I've changed the source block from "echo 1" to "echo 2" to induce a failure (it will now receive "2\n2\n"). I re-evaluate the test and call M-: (ert "test-ob-shell/session-async-evaluation"). The test passes! I can put a message or debug in the advice and see that it's never called. However, if I uncomment the sleep-for, the advice runs, and the test fails as expected. (ert-deftest test-ob-shell/session-async-evaluation () (let ((session-name "test-ob-shell/session-async-evaluation") (kill-buffer-query-functions nil) result) ;; check callback return for correct results (advice-add 'ob-shell-async-chunk-callback :filter-return (lambda (&rest r) (let ((result (car r))) (should (string= result "1\n2\n")) ; this was previously an if statement result)) `((name . ,session-name))) ;; always remove advice, regardless of test outcome (unwind-protect (org-test-with-temp-text (concat "#+begin_src sh :session " session-name " :async t echo 2 echo 2 #+end_src") ;; execute block; callback only executes when delay (setq result (org-trim (org-babel-execute-src-block))) (if (should (and (string-match test-ob-shell/uuid-regex result) ; block runs (not (sleep-for 0.1)) ; callback doesn't fail )) (kill-buffer session-name))) (advice-remove 'ob-shell-async-chunk-callback session-name))))