Test against the newest version of org-mode

This commit is contained in:
Nathaniel Nicandro 2019-02-21 11:36:17 -06:00
parent 70f4b1b9a3
commit d927d3d58d
No known key found for this signature in database
GPG key ID: C34814B309DD06B8
2 changed files with 43 additions and 27 deletions

2
Cask
View file

@ -1,5 +1,6 @@
(source gnu) (source gnu)
(source melpa) (source melpa)
(source org)
(package-file "jupyter.el") (package-file "jupyter.el")
@ -9,4 +10,5 @@
(development (development
(depends-on "ert-runner") (depends-on "ert-runner")
(depends-on "org-plus-contrib")
(depends-on "julia-mode")) (depends-on "julia-mode"))

View file

@ -352,33 +352,47 @@ results instead of an equality match."
"#+END_SRC"))) "#+END_SRC")))
(defun jupyter-org-test-src-block-1 (code test-result &optional regexp args) (defun jupyter-org-test-src-block-1 (code test-result &optional regexp args)
(insert (jupyter-org-test-make-block code args)) (let ((src-block (jupyter-org-test-make-block code args)))
(let* ((info (org-babel-get-src-block-info)) (insert src-block)
(end (point-marker))) (let* ((info (org-babel-get-src-block-info))
(set-marker-insertion-type end t) (end (point-marker)))
(save-window-excursion (set-marker-insertion-type end t)
(org-babel-execute-src-block nil info)) (save-window-excursion
(org-with-point-at (org-babel-where-is-src-block-result nil info) (org-babel-execute-src-block nil info))
(when (equal (alist-get :async args) "yes") (org-with-point-at (org-babel-where-is-src-block-result nil info)
(jupyter-wait-until-idle (when (equal (alist-get :async args) "yes")
(ring-ref (oref jupyter-current-client pending-requests) 0))) (jupyter-wait-until-idle
(let ((drawer (org-element-at-point))) (ring-ref (oref jupyter-current-client pending-requests) 0)))
;; Handle empty results with just a RESULTS keyword (let ((drawer (org-element-at-point)))
;; ;; Handle empty results with just a RESULTS keyword
;; #+RESULTS: ;;
(if (eq (org-element-type drawer) 'keyword) "" ;; #+RESULTS:
(let ((result (string-trim (if (eq (org-element-type drawer) 'keyword) ""
(if (eq (org-element-type drawer) 'drawer) (let ((result (string-trim
(if (eq (org-element-type drawer) 'drawer)
(buffer-substring-no-properties
(org-element-property :contents-begin drawer)
(org-element-property :contents-end drawer))
(buffer-substring-no-properties (buffer-substring-no-properties
(org-element-property :contents-begin drawer) (org-element-property :post-affiliated drawer)
(org-element-property :contents-end drawer)) (org-element-property :end drawer))))))
(buffer-substring-no-properties (if regexp (should (string-match-p test-result result))
(org-element-property :post-affiliated drawer) (message "\
(org-element-property :end drawer))))))
(if regexp (should (string-match-p test-result result)) Testing src-block:
(should (eq (compare-strings %s
result nil nil test-result nil nil
'ignore-case) Expected result:
t))))))))) %s
Result:
%s
"
src-block result test-result)
(should (eq (compare-strings
result nil nil test-result nil nil
'ignore-case)
t))))))))))
;;; test-helper.el ends here ;;; test-helper.el ends here