R icon indicating copy to clipboard operation
R copied to clipboard

Suggestion: ability to wite tests in R

Open sebffischer opened this issue 1 year ago • 1 comments

One way to make this project accessible to people that do not (yet) know how to write rust code, would be to give a possibility to contribute to the project by only writing R code. One way to enable writing R code (without requiring any knowledge of rust) right now would be to support writing tests in R files (as e.g. here in the r-source).

We could then split up the tests as follows:

  • the "rust tests" are those that test more internal implementation, e.g. optimizations etc., which cannot be tested otherwise
  • the "R tests" test that the language works as expected

I imagine a folder like R/r-tests containing .R files. These R files contain the test-code, which also requires us to support something like a stop() primitive. When running the rust tests, each file from the r-tests directory could be passed to the r! macro (or a slight variant thereof). Generating the rust code that runs the tests from r-tests could also be automated in the build.rs file.

sebffischer avatar May 22 '24 15:05 sebffischer

Interesting idea! I'm a bit torn on this one, though. Let me lay out my ideas in favor and against this idea:

I do like that this could bring in new contributors, and I like that we can steer them towards something more familiar. I also like that this might prompt us to develop a core set of internal tools to support the primitives needed for testing (like stop()).

That said, I'm a bit skeptical that this would actually bring in new contributors - or enough to warrant the overhead. The r!-style tests are already pretty easy to contribute to, and part of me prefers that style because it sits right next to the relevant code and has the added benefit of being a gateway to the rust internals.

Looking past the high level concept and commenting specifically on your implementation, I think I'd prefer that the solution just source an R script instead of converting a R script into rust code. This might require a few extra primitives, but would offload the complexity out of the build script and having redundant source files.

dgkf avatar May 22 '24 17:05 dgkf

That said, I'm a bit skeptical that this would actually bring in new contributors - or enough to warrant the overhead. The r!-style tests are already pretty easy to contribute to, and part of me prefers that style because it sits right next to the relevant code and has the added benefit of being a gateway to the rust internals.

think you might be right, I will try to keep the focus on the core data structures, so I am closing this issue.

sebffischer avatar Jun 02 '24 12:06 sebffischer