Skip to main content
added 420 characters in body
Source Link
John Kitchin
  • 12.1k
  • 1
  • 23
  • 45

One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them.

(defun run-tests ()
  (interactive)
  (copy-to-buffer "*my-test*" (point-min) (point-max))
  (org-babel-execute-buffer)
  (diff-buffers "*my-test*" (current-buffer)))

This will make a new buffer showing the diff (if any). There are lots of variations I suppose, like writing to files, different ways of diffing.

It would be hard I think to get this to work for images.

[edit]: here is a version that works on a copy of the buffer with ediff.

(defun run-tests ()
  (interactive)
  (let ((contents (buffer-string))
    (buf (current-buffer)))
    (with-current-buffer (get-buffer-create "*my-test*")
      (erase-buffer)
      (insert contents)
      (org-mode)
      (org-babel-execute-buffer)
      (ediff-buffers buf "*my-test*"))))

One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them.

(defun run-tests ()
  (interactive)
  (copy-to-buffer "*my-test*" (point-min) (point-max))
  (org-babel-execute-buffer)
  (diff-buffers "*my-test*" (current-buffer)))

This will make a new buffer showing the diff (if any). There are lots of variations I suppose, like writing to files, different ways of diffing.

It would be hard I think to get this to work for images.

One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them.

(defun run-tests ()
  (interactive)
  (copy-to-buffer "*my-test*" (point-min) (point-max))
  (org-babel-execute-buffer)
  (diff-buffers "*my-test*" (current-buffer)))

This will make a new buffer showing the diff (if any). There are lots of variations I suppose, like writing to files, different ways of diffing.

It would be hard I think to get this to work for images.

[edit]: here is a version that works on a copy of the buffer with ediff.

(defun run-tests ()
  (interactive)
  (let ((contents (buffer-string))
    (buf (current-buffer)))
    (with-current-buffer (get-buffer-create "*my-test*")
      (erase-buffer)
      (insert contents)
      (org-mode)
      (org-babel-execute-buffer)
      (ediff-buffers buf "*my-test*"))))
Source Link
John Kitchin
  • 12.1k
  • 1
  • 23
  • 45

One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them.

(defun run-tests ()
  (interactive)
  (copy-to-buffer "*my-test*" (point-min) (point-max))
  (org-babel-execute-buffer)
  (diff-buffers "*my-test*" (current-buffer)))

This will make a new buffer showing the diff (if any). There are lots of variations I suppose, like writing to files, different ways of diffing.

It would be hard I think to get this to work for images.