From: "Berry, Charles" via "General discussions about Org-mode." <firstname.lastname@example.org>
To: Greg Minshall <email@example.com>
Cc: orgmode <firstname.lastname@example.org>
Subject: Re: using previous =#+results= when =:eval never=
Date: Sat, 3 Jul 2021 19:08:09 +0000 [thread overview]
Message-ID: <AFFDC856-200D-4ABE-99DE-266EBD4A571B@health.ucsd.edu> (raw)
> On Jul 3, 2021, at 9:35 AM, Greg Minshall <email@example.com> wrote:
> i am trying to simplify adding regression test cases to a program.
> to generate the base, "compared-to" results, i want to write some code
> in a source block, then evaluate it, producing the "true" value.
> then, later during development, i want to check if the code that ran in
> that block gives the same results. to do this, i preface the test check
> block with, e.g., =:var fu=bar=. obviously, i do *not* want to
> re-create the base results; so, after producing the base case results, i
> tried marking the source block that produces the results =:eval never=.
> but, doing that, using `:var fu=bar` on a test check source block, fu's
> value is nil. (*)
> is there a way to convince org-mode to, in the face of =:eval never=, go
> ahead and pass the *previous* results? or, some other idea of how to do
> this? there will be a large number of these test cases.
> cheers, Greg
I think it would be easier to leave :eval alone and instead evaluate the src block using `org-babel-ref-resolve' and compare to the current value. Something like this is a start:
(defun org-babel-read-named-result (blkname)
(defun compare-old-to-new (refname)
(let ((new (org-babel-ref-resolve refname))
(old (org-babel-read-named-result refname)))
(or (equal old new)
(format "Comparison failed for block %s" refname))))
Then eval'ing `(compare-old-to-new "testcountsdecompose")` for the ECM you gave will give `t` if the result is the same and return a string saying which block failed the test.
I suppose you could loop thru `(org-babel-src-block-names)` if you want to check all the named blocks in a file.
> (*) this is sort of confusing, so here's an example:
> #+begin_src org
> ,#+name: testcountsdecompose
> ,#+begin_src R :eval never
> ,#+RESULTS: testcountsdecompose
> | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 |
> | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
> | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 |
> ,#+name: testcounts
> ,#+header: :var testcountsdecompose=testcountsdecompose :results output
> ,#+begin_src R
> ,#+RESULTS: testcounts
> : chr "nil"
> whereas, if the =testcountsdecompose= source block does *not* have
> =:eval never=, my =testcountsdecompse= variable has all the rows and
> columns i was hoping for.
next prev parent reply other threads:[~2021-07-03 19:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-03 16:35 using previous =#+results= when =:eval never= Greg Minshall
2021-07-03 19:08 ` Berry, Charles via General discussions about Org-mode. [this message]
2021-07-04 5:19 ` Greg Minshall
2021-07-04 17:20 ` Berry, Charles via General discussions about Org-mode.
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).