Re: [PATCH] test-ob-tangle.el: Fix dirty repo state caused by testing

2020-05-26 Thread Kyle Meyer
Kevin Foley writes:

> The attached patch kills the buffer of the file modified
> during testing to prevent leaving the repo in a dirty state.

Thanks.  I applied it in 7a2b785d6 with a small tweak so that a buffer
rather than a buffer name is passed to kill-buffer.  In the context of
the tests, the buffer name "babel.org" is very likely to be the one we
intend to kill, but I think it's better to use the actual buffer object.



[PATCH] test-ob-tangle.el: Fix dirty repo state caused by testing

2020-05-26 Thread Kevin Foley

The attached patch kills the buffer of the file modified
during testing to prevent leaving the repo in a dirty state.

Thanks to Kyle for seeing this and providing guidance on how to
address.

Thanks,
Kevin

>From 46dd1cf3c34a372612e4a67a79afd84ca3317500 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Tue, 26 May 2020 20:42:54 -0400
Subject: [PATCH] test-ob-tangle.el: Fix dirty repo state caused by testing

* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Kill modified buffer after test.

Another test is causing the modifications to be saved which leaves the
repo in a dirty state after testing.
---
 testing/lisp/test-ob-tangle.el | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index ed75e6ca4..bd2d99ca2 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -384,12 +384,14 @@ (ert-deftest ob-tangle/commented-src-blocks ()

 (ert-deftest ob-tangle/detangle-false-positive ()
   "Test handling of false positive link during detangle."
-  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
-(org-babel-detangle)
-(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
-(org-babel-next-src-block)
-(should (equal (string-trim (org-element-property :value (org-element-at-point)))
-		   ";; detangle changes")
+  (unwind-protect
+  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
+	(org-babel-detangle)
+	(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
+	  (org-babel-next-src-block)
+	  (should (equal (string-trim (org-element-property :value (org-element-at-point)))
+			 ";; detangle changes"
+(kill-buffer "babel.org")))

 (provide 'test-ob-tangle)

--
2.19.0