IRC channel logs

2023-06-06.log

back to list of logs

<flypaper-ultimat>rekado: ah, gnu:dump-file-contents already does recursively via find-files, so i could instead of '(string-append pkg-name "-tests")' just do "."
<rekado>okay, I’ll try that
<rekado>civodul: neat!
<rekado>flypaper-ultimat: that works
<rekado>the test failure in r-biocgenerics is due to the fact that annotationdbi isn’t among the inputs; it can’t be added because that would introduce a package cycle
<rekado>(how appropriate!)
<rekado>gotta see if we can add a more convenient way to disable individual tests
<rekado>but first:
<rekado>ACTION —> zzzZ
<flypaper-ultimat>yeah me too, good night!
<rekado>flypaper-ultimat: I think we should pass type="tests" to tools::testInstalledPackage
<rekado>the examples often require too many other packages
<rekado>I guess we should also try to update the importer to add packages to the inputs (not propagated-inputs) that are required by the tests
<flypaper-ultimat>yeah, that makes sense. this is what i've got now: http://ix.io/4xAh/text , works as expected with r-guix-install if i put r-runit to inputs, with and without failing patch.
<rekado>yes, that’s what I got too
<rekado>(I adjusted the patch a little after we’ve talked here)
<rekado>I’m now trying to write a little test runner that lets us disable individual tests easily
<flypaper-ultimat>cool. i'll get back to $JOB for now.
<rekado>here’s the test runner: https://elephly.net/paste/1686045314.R.html
<rekado>we’d need to pass “--file=guix_test_runner.R --” as Ropts to testInstalledPackage
<rekado>this way we can disable individual tests via the R_DISABLED_TESTS variable
<rekado>bah, this won’t work because of the wildly different ways that R packages can launch their tests upon evaluation.
<flypaper-ultimat>rekado: can you give me a a few packages that do wildly different things, maybe theres a way with hacking with R's `trace', which you can use kinda like emacs's "advice".
<rekado>my assumption was that we can load all the test files first and then run them (after checking if they appear in a list of disabled tests)
<rekado>tools::testInstalledPackage(type="tests", …) will look for tests in “tests”
<rekado>BiocGenerics actually has its tests in inst/unitTests
<rekado>the tests directory merely contains the custom launcher, which configures and runs RUnit
<rekado>packages are free to do whatever they want inside of tests/*
<rekado>testInstalledPackage will evaluate the contents of any R file in that directory
<flypaper-ultimat>yeah, and if that exits non-zero then the tests are considered failed
<rekado>BiocGenerics uses RUnit with a regexp to select what tests to run
<rekado>so I don’t see a generic way to disable individual tests
<flypaper-ultimat>so what if we advice `<-` during tests to assign function(...) {true} if the first arg matches one if the disabled tests?
<flypaper-ultimat>i once wrote a script that hooked to "read.csv", "load", and "save" with `trace' in order to crate a graphviz plot of when data was being loaded / written to, maybe something similar could be done here.
<rekado>flypaper-ultimat: that’s a very good idea
<rekado>I’ll try it
<flypaper-ultimat>i'm also mucking around with it. gotta love that R is practically a scheme.
<flypaper-ultimat>ACTION has half a mind of writing an R-lexer that takes s-expression.
<rekado>I get “object '"<-"' not found” whenever I try to go beyond just “trace("<-")”
<rekado>(with any custom tracer)
<flypaper-ultimat>rekado: i'm getting somewhere i think. useful reading: https://www.r-project.org/doc/Rnews/Rnews_2001-3.pdf
<flypaper-ultimat>(the bit about macro's in R)
<flypaper-ultimat>rekado: how about something like this? http://ix.io/4xBB
<flypaper-ultimat>ooh just read about 'lockBinding', that might also be what we want to do.
<civodul>rekado: i find (filter (lambda (x) ((negate string=?) ...)) ...) convoluted
<civodul>i'd write (remove (lambda (x) (string=? ...)) ...)
<civodul>(no big deal, i just saw it while browsing guix-commits)
<rekado>civodul: ah, yes. I know that “remove” exists but I just failed to remember it
<rekado>embarrassing!
<rekado>flypaper-ultimat: this looks more complicated than I would have guessed. Good you got that far!
<rekado>I’m a little worried about missing other ways of defining tests
<flypaper-ultimat>rekado: got a slightly more informative one here: http://ix.io/4xCd
<rekado>we could probably catch cases where a function is assigned to “test_…”, but I wonder if there are other conventions
<flypaper-ultimat>(this one looks less clean, but the message itself will keep echo the function it sileneced)
<rekado>what does the frame=parent.frame(n=1) do?
<rekado>I get that eval needs a frame as a context, but what’s the parent.frame?
<flypaper-ultimat>it gets the environment that `<-` was called in.
<flypaper-ultimat>in other words, it goes up 1 level in the stack
<flypaper-ultimat>so that we do the primitive `<-` in the place where the user wrote `<-`, rather than in `guix_maybe_assign`
<flypaper-ultimat>so you can think of it as a macro.
<rekado>right
<rekado>I’ll give this a spin a little while later
<flypaper-ultimat>another common testing framework is r-testthat, which uses the format `test_that("Testing for foo bar", { expect_equal(foo,bar)})` so we could shadow "test_that", and discard things that match certain titles.