Is there a way to assert that the results of evaluating a code block with Babel are equal to an expected text? Ideally, I would use this to stop an export to PDF if one of the assertions does not hold.
This is an example on how to use the Unix command =touch=. #+begin_src sh :exports code touch main.c touch lib.c #+end_src #+RESULTS: After you execute those commands, you should see in your working directory the following files: #+begin_src sh :results raw :exports results tree . #+end_src #+RESULTS: . |-- example.org |-- lib.c `-- main.c 0 directories, 3 files #+EXPECTED: . ├── lib.c └── main.c
The first code block does not have any results nor any expected results; only its side effects are useful. (Incidentally, it has been evaluated, as you can see because there is an empty RESULTS section underneath).
The second code block is what I would like to have: when it is evaluated, it returns a result that can be compared with the EXPECTED block. As you can see, the results do not match because I forgot to include the org file itself and the summary line returned by
tree. An export to PDF should be stopped with a message that points out the difference. If RESULTS and EXPECTED did match, then the EXPECTED block is not exported, but the rest of the file is.
Is there a way to do this with the currently available features of Org and Babel?