klmr / klmr/sys

Add `test` entry point in addition to `run`

Open
#12 0 comments 0 reactions 1 assignee View on GitHub

@klmr is already working on this.

Since Apr 14, 2016.

enhancement
Dominant language
R
Stars
13
Forks
1
PR merge metrics
No merged PRs in 30d

Description

At the moment standalone modules are encouraged to implement a single entry point via sys$run. However, it would also be helpful to make non-standalone modules executable to run tests. This could be achieved via a sys$test entry point.

The disadvantage of this would be that it requires loading sys whenever the dependent module is loaded. This cost may be prohibitive unless loading sys is made extremely lightweight — i.e. not performing any action unless actually running in standalone mode. This should in fact probably be implemented anyway.

Usage could look something like this:

# … rest of module code

modules::import('sys')$test()

Or, to customise the testing directory,

# … rest of module code

modules::import('sys')$test('some_test_dir')

Internally, this should almost certainly use testthat, and we can be opinionated about this. For instance, it could assume that tests are individual files under a _tests subdirectory, and run them via testthat::test_dir('_tests'). Or we can make this configurable by simply importing a _tests submodule, which then loads _tests/__init__.r or _tests.r, whichever is available.

In other words, sys$test() would be pretty much equivalent to the following code:

if (is.null(modules::module_name())) {
    modules::import('./_tests')
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.