Implement org-babel-tmux-test

Tests the tmux functionality. Also solves some problems in the
original implementation where the temp file would be read directly
after creation, i.e. before the random string could be written to the
file.
hello-test
Allard Hendriksen 2018-01-05 15:01:27 +01:00
parent f7fd2b2301
commit d5deb53751
1 changed files with 24 additions and 21 deletions

View File

@ -119,27 +119,30 @@ In case you want to use a different tmux than one selected by your $PATH")
sockets))))) sockets)))))
(when match-socket (car (split-string match-socket ":"))))) (when match-socket (car (split-string match-socket ":")))))
;; (defun org-babel-screen-test () (defun org-babel-tmux-open-file (path)
;; "Test if the default setup works. (with-temp-buffer
;; The terminal should shortly flicker." (insert-file-contents-literally path)
;; (interactive) (buffer-substring (point-min) (point-max))))
;; (let* ((random-string (format "%s" (random 99999)))
;; (tmpfile (org-babel-temp-file "ob-screen-test-")) (defun org-babel-tmux-test ()
;; (body (concat "echo '" random-string "' > " tmpfile "\nexit\n")) "Test if the default setup works. The terminal should shortly flicker."
;; tmp-string) (interactive)
;; (org-babel-execute:screen body org-babel-default-header-args:screen) (let* ((random-string (format "%s" (random 99999)))
;; ;; XXX: need to find a better way to do the following (tmpfile (org-babel-temp-file "ob-screen-test-"))
;; (while (not (file-readable-p tmpfile)) (body (concat "echo '" random-string "' > " tmpfile " ; exit"))
;; ;; do something, otherwise this will be optimized away tmp-string)
;; (format "org-babel-screen: File not readable yet.")) (org-babel-execute:tmux body org-babel-default-header-args:tmux)
;; (setq tmp-string (with-temp-buffer ;; XXX: need to find a better way to do the following
;; (insert-file-contents-literally tmpfile) (while (or (not (file-readable-p tmpfile))
;; (buffer-substring (point-min) (point-max)))) (= 0 (length (org-babel-tmux-open-file tmpfile))))
;; (delete-file tmpfile) ;; do something, otherwise this will be optimized away
;; (message (concat "org-babel-screen: Setup " (format "org-babel-screen: File not readable yet."))
;; (if (string-match random-string tmp-string) (setq tmp-string (org-babel-tmux-open-file tmpfile))
;; "WORKS." (delete-file tmpfile)
;; "DOESN'T work."))))) (message (concat "org-babel-screen: Setup "
(if (string-match random-string tmp-string)
"WORKS."
"DOESN'T work.")))))
(provide 'ob-tmux) (provide 'ob-tmux)