Skip to content

Commit

Permalink
Merge pull request #9 from stnutt/master
Browse files Browse the repository at this point in the history
Inherit :dir header arg in async function for remote execution
  • Loading branch information
astahlman committed Jun 25, 2017
2 parents 6bdb5b6 + 360d93c commit fc0020e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: generic
sudo: false
sudo: required
git:
submodules: false

Expand Down
3 changes: 2 additions & 1 deletion ob-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 23 additions & 1 deletion ob-async.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions test/ob-async-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fc0020e

Please sign in to comment.