diff --git a/.travis.yml b/.travis.yml index 7194abd..49ab6a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: generic -sudo: false +sudo: required git: submodules: false diff --git a/ob-async.el b/ob-async.el index f0d8940..97fcf09 100644 --- a/ob-async.el +++ b/ob-async.el @@ -125,7 +125,8 @@ block." (setq exec-path ',exec-path) (package-initialize) (org-babel-do-load-languages 'org-babel-load-languages ',org-babel-load-languages) - (,cmd ,body ',params)) + (let ((default-directory ,default-directory)) + (,cmd ,body ',params))) (if (member "none" ',result-params) (progn (message "result silenced") 'ignore) diff --git a/ob-async.org b/ob-async.org index 8751f52..ed2bb1d 100644 --- a/ob-async.org +++ b/ob-async.org @@ -558,6 +558,27 @@ I'd also like to test this with ERT. #+RESULTS: : test-async-execute-table-output +*** Tramp + +#+BEGIN_SRC emacs-lisp + (ert-deftest test-async-execute-tramp-block () + "Test that we can execute a block via Tramp with a :dir header-arg" + (let ((buffer-contents (format "Here's a sh source block: + + ,#+BEGIN_SRC sh :async :dir \"/sudo:%s@localhost:/\" + echo $SUDO_USER $PWD + ,#+END_SRC" user-login-name))) + (with-buffer-contents buffer-contents + (org-babel-next-src-block) + (org-ctrl-c-ctrl-c) + (should (placeholder-p (results-block-contents))) + (wait-for-seconds 5) + (should (string= (format "%s /" user-login-name) (results-block-contents)))))) +#+END_SRC + +#+RESULTS: +: test-async-execute-tramp-block + *** TODO Concurrent execution of multiple blocks *** TODO Execute a named block *** TODO Execute a blocks with post-processing @@ -690,7 +711,8 @@ ripped straight from the original source for (setq exec-path ',exec-path) (package-initialize) (org-babel-do-load-languages 'org-babel-load-languages ',org-babel-load-languages) - (,cmd ,body ',params)) + (let ((default-directory ,default-directory)) + (,cmd ,body ',params))) (if (member "none" ',result-params) (progn (message "result silenced") 'ignore) diff --git a/test/ob-async-test.el b/test/ob-async-test.el index 939df85..bc7f6ac 100644 --- a/test/ob-async-test.el +++ b/test/ob-async-test.el @@ -160,6 +160,20 @@ for row in x: (should (equal '(("1,1" "1,2") ("2,1" "2,2")) (results-block-contents))) (message "%s" (results-block-contents))))) +(ert-deftest test-async-execute-tramp-block () + "Test that we can execute a block via Tramp with a :dir header-arg" + (let ((buffer-contents (format "Here's a sh source block: + + #+BEGIN_SRC sh :async :dir \"/sudo:%s@localhost:/\" + echo $SUDO_USER $PWD + #+END_SRC" user-login-name))) + (with-buffer-contents buffer-contents + (org-babel-next-src-block) + (org-ctrl-c-ctrl-c) + (should (placeholder-p (results-block-contents))) + (wait-for-seconds 5) + (should (string= (format "%s /" user-login-name) (results-block-contents)))))) + (ert-deftest test-async-execute-silent-block () "Test that we can insert results for a sh block that hasn't been executed yet" :expected-result :failed