[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Need help on my writing org-mode test.
From: |
stardiviner |
Subject: |
[O] Need help on my writing org-mode test. |
Date: |
Sun, 08 Apr 2018 21:01:41 +0800 |
User-agent: |
mu4e 1.0; emacs 27.0.50 |
I'm try to write a test for following src block:
#+begin_src sh :results link :file "test.txt"
echo "hello" > test.txt
echo "test"
#+end_src
#+RESULTS[<2018-04-08 18:30:51> 22a787defa349526768722f4bfc8509dd16ab154]:
[[file:test.txt]]
And here is my ert test:
(ert-deftest test-ob/result-file-link-type-header-argument ()
"Ensure that the result is a link to a file.
The file is just a link to :file value. Inhibit non-empty result write to
:file."
(org-test-with-temp-text
"
#+begin_src sh :results link :file \"/tmp/test.txt\"
echo \"hello\" > /tmp/test.txt
echo \"test\"
#+end_src"
(org-babel-next-src-block 1)
(org-babel-execute-src-block)
(goto-char (point-min))
(should (search-forward "[[file:test.txt]]" nil nil))
(should (with-temp-buffer
(insert-file-contents "/tmp/test.txt")
(string=
"hello\n"
(buffer-substring-no-properties (point-min) (point-max)))))
))
I run test with async shell command in Emacs:
make BTEST_RE="test-ob/result-file-link-type-header-argument" test-dirty
But I got error:
```
selected tests: test-ob/result-file-link-type-header-argument
Running 1 tests (2018-04-08 20:52:41+0800, selector
‘"test-ob/result-file-link-type-header-argument"’)
executing Sh code block...
Code block evaluation complete.
Test test-ob/result-file-link-type-header-argument backtrace:
search-forward("[[file:test.txt]]" nil nil nil)
apply(search-forward ("[[file:test.txt]]" nil nil))
(setq value-1950 (apply fn-1948 args-1949))
(unwind-protect (setq value-1950 (apply fn-1948 args-1949)) (setq fo
(if (unwind-protect (setq value-1950 (apply fn-1948 args-1949)) (set
(let (form-description-1952) (if (unwind-protect (setq value-1950 (a
(let ((value-1950 'ert-form-evaluation-aborted-1951)) (let (form-des
(let* ((fn-1948 (function search-forward)) (args-1949 (condition-cas
(progn (org-mode) (let ((point (string-match "<point>" inside-text))
(unwind-protect (progn (org-mode) (let ((point (string-match "<point
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b
(let ((inside-text (if (stringp "\n#+begin_src sh :results link :fil
(lambda nil (let ((inside-text (if (stringp "\n#+begin_src sh :resul
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name test-ob/result-file-link-type-header-
ert-run-or-rerun-test(#s(ert--stats :selector "test-ob/result-file-l
ert-run-tests("test-ob/result-file-link-type-header-argument" #f(com
ert-run-tests-batch("test-ob/result-file-link-type-header-argument")
ert-run-tests-batch-and-exit("test-ob/result-file-link-type-header-a
(let ((org-id-track-globally t) (org-test-selector (if org-test-sele
org-test-run-batch-tests("test-ob/result-file-link-type-header-argum
eval((org-test-run-batch-tests org-test-select-re))
command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
command-line()
normal-top-level()
Test test-ob/result-file-link-type-header-argument condition:
(search-failed "[[file:test.txt]]")
FAILED 1/1 test-ob/result-file-link-type-header-argument (0.032747 sec)
Ran 1 tests, 0 results as expected, 1 unexpected (2018-04-08 20:52:42+0800,
0.877523 sec)
1 unexpected results:
FAILED test-ob/result-file-link-type-header-argument
make: *** [mk/targets.mk:105: test-dirty] Error 1
```
I tried many modification, I write this test based on existing test:
(ert-deftest test-ob/file-desc-header-argument ()
"Test that the :file-desc header argument is used."
(org-test-with-temp-text "#+begin_src emacs-lisp :results file :file-desc bar
\"foo\"
#+end_src
#+begin_src emacs-lisp :results file :file-desc
\"foo\"
#+end_src"
(org-babel-execute-src-block)
(org-babel-next-src-block 1)
(org-babel-execute-src-block)
(goto-char (point-min))
(should (search-forward "[[file:foo][bar]]" nil t))
(should (search-forward "[[file:foo][foo]]" nil t))))
Don't know why my test error. Can't find out what's wrong from truncated make
test output.
I included my patch in attachment.
0001-ob-core.el-add-results-link-type-result-for-babel.patch
Description: Text Data
--
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
signature.asc
Description: PGP signature
- [O] Need help on my writing org-mode test.,
stardiviner <=