Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Test or remove runnableExamples in non-exported procs #97

Open
ee7 opened this issue Nov 27, 2020 · 0 comments
Open

Tests: Test or remove runnableExamples in non-exported procs #97

ee7 opened this issue Nov 27, 2020 · 0 comments
Labels
kind: tests Adding or refactoring tests

Comments

@ee7
Copy link
Member

ee7 commented Nov 27, 2020

PR #94 added some runnableExamples to a non-exported proc, which means that the examples don't run even if we were to add nim doc to the CI.

It would be nice to have:

  • the benefits of having examples right next to the implementation of non-exported procs
  • and keep those examples tested.

@ee7 wrote:

The alternatives that I'm aware of:

  1. Remove the examples entirely, but then the documentation is less clear.
  2. Turn the runnableExamples into doc comments, but then they're harder to test and thus keep in-sync with the code.
  3. Move the examples into when isMainModule tests, and add nim c -r cli.nim to the CI workflow. This means that they're tested, but the documentation suffers because the examples aren't close to the func itself, and the test layout becomes more convoluted.
  4. Move the examples into a new file in the tests directory. This requires using include cli (rather than import), or a short hack/macro to export non-exported procs for testing purposes.
  5. Export the func, but that signals to the reader that the func is used outside the cli.nim file, which it isn't.
@ee7 ee7 added the kind: tests Adding or refactoring tests label May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: tests Adding or refactoring tests
Projects
None yet
Development

No branches or pull requests

1 participant