Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Stardiviner PR 52 #54

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ob-async.el
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ block."
(save-excursion
(goto-char ,src-block-marker)
(let ((file (cdr (assq :file ',params))))
;; If non-empty result and :file then write to :file.
(when file
(when result
(with-temp-file file
(insert (org-babel-format-result
result (cdr (assq :sep ',params))))))
;; when result type is link, don't write result content to file.
(unless (member "link" ',result-params)
;; If non-empty result and :file then write to :file.
(when result
(with-temp-file file
(insert (org-babel-format-result
result (cdr (assq :sep ',params)))))))
(setq result file))
;; Possibly perform post process provided its
;; appropriate. Dynamically bind "*this*" to the
Expand Down
21 changes: 21 additions & 0 deletions test/ob-async-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ when content has been added below the source block"
(let ((foo-contents (progn (find-file "/tmp/foo") (buffer-substring-no-properties (point-min) (point-max)))))
(should (string= "Don't wait on me\n" foo-contents))))))))

(ert-deftest test-async-execute-file-link-result-block ()
"Test that we can insert results when header-arg :file and :results link is present."
(let ((buffer-contents "Here's a sh source block:

#+BEGIN_SRC sh :async :results link :file \"/tmp/foo\"
echo \"Don't wait on me\" > /tmp/foo
#+END_SRC"))
(with-buffer-contents
buffer-contents
(org-babel-next-src-block)
(ctrl-c-ctrl-c-with-callbacks
:pre (should (placeholder-p (results-block-contents)))
:post (progn
(should (string= "/tmp/foo" (results-block-contents)))
(let ((foo-contents (progn
(let ((revert-without-query '(".*")))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I add it now.

(find-file "/tmp/foo"))
(buffer-substring-no-properties
(point-min) (point-max)))))
(should (string= "Don't wait on me\n" foo-contents))))))))

(ert-deftest test-async-execute-table-output ()
"Test that we can insert table output"
(let ((buffer-contents "Here's a source block:
Expand Down