branch: elpa/datetime commit 15ad70fe88c1864d42b4f3c6528c13921feebcf8 Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Improve `datetime--test' to print stderr of the process on any error. --- test/base.el | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/test/base.el b/test/base.el index 576fb14a9b..4064e1e4fc 100644 --- a/test/base.el +++ b/test/base.el @@ -51,28 +51,37 @@ (position (marker-position marker)) (num-times (length times)) (num-result-lines 0) - result) - (with-current-buffer (marker-buffer marker) - ;; It is much faster to give "tasks" to the remote process in - ;; batch, then fetch the results. - (dolist (time times) - (process-send-string datetime--test-java-process - (format "%s %s\n%s %s %s\n" command time datetime--test-timezone datetime--test-locale datetime--test-pattern))) - (while (< num-result-lines num-times) - (while (or (= (marker-position marker) position) (/= (char-before marker) ?\n)) - (accept-process-output datetime--test-java-process)) - (unless (process-live-p datetime--test-java-process) - (error "ProcessTimestamp process exited unexpectedly with code %d:\n%s" - (process-exit-status datetime--test-java-process) (with-current-buffer "java-benchmark/stderr" (buffer-string )))) - (while (> (marker-position marker) position) - (goto-char position) - (end-of-line) - (let ((as-string (buffer-substring position (point)))) - (push (if (eq command 'format) as-string (car (read-from-string as-string))) result)) - (beginning-of-line 2) - (setq position (point) - num-result-lines (1+ num-result-lines)))) - (nreverse result)))) + result + successful) + (unwind-protect + (with-current-buffer (marker-buffer marker) + ;; It is much faster to give "tasks" to the remote process in + ;; batch, then fetch the results. + (dolist (time times) + (process-send-string datetime--test-java-process + (format "%s %s\n%s %s %s\n" command time datetime--test-timezone datetime--test-locale datetime--test-pattern))) + (while (< num-result-lines num-times) + (while (or (= (marker-position marker) position) (/= (char-before marker) ?\n)) + (accept-process-output datetime--test-java-process)) + (unless (process-live-p datetime--test-java-process) + (error "ProcessTimestamp process exited unexpectedly with code %d:\n%s" + (process-exit-status datetime--test-java-process) (with-current-buffer "java-benchmark/stderr" (buffer-string)))) + (while (> (marker-position marker) position) + (goto-char position) + (end-of-line) + (let ((as-string (buffer-substring position (point)))) + (push (if (eq command 'format) as-string (car (read-from-string as-string))) result)) + (beginning-of-line 2) + (setq position (point) + num-result-lines (1+ num-result-lines)))) + (setf successful t) + (nreverse result)) + (unless successful + (message "stderr of `java-benchmark':\n%s" + (condition-case error + (with-current-buffer "java-benchmark/stderr" + (if (bobp) "[empty]" (buffer-string))) + (error (format "[failed to retrieve: %S]" error)))))))) (provide 'test/base)