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

Parallel testing subdirs throws error (test_subdir, test_integration, ...) #18

Closed
markschat opened this issue Feb 10, 2022 · 4 comments
Closed

Comments

@markschat
Copy link

markschat commented Feb 10, 2022

I can´t use parallel testing (introduced by testthat 3) with testthis when testing subdirs.
E.g. testing dir /testthat/integration_tests with test_integration() within my R-Package throws this error (see reprex at the end):

Starting 2 test processes
✓ | F W S  OK | Context
⠸ [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ] Starting up...  
Error: testthat subprocess failed to start, stderr:
...
Error in getNamespace(ns) : attempt to use zero-length variable name
Calls: callr_startup_hook ... get_env_retired -> is_environment -> asNamespace -> getNamespace

This problem is already discussed in testthat #1216 with the conclusion that the package argument should be specified in testthat::test_dir which is called by testthis::test_subdir under the hood.
As far as I see, this solution don´t works here as package will not be passed on to testthat.

Reprex

Add this lines to DESCRIPTION to enable parallel testing (>= testthat 3) which should be enough to reproduce the error.

Config/testthat/edition: 3
Config/testthat/parallel: true
@markschat markschat changed the title Testing subdirs in parallel throws error (test_subdir, test_integration, ...) Parallel testing subdirs throws error (test_subdir, test_integration, ...) Feb 10, 2022
@markschat
Copy link
Author

markschat commented Feb 10, 2022

I can now confirm that providing the package argument to testthis::test_dir solves the problem.
I copied the call to testthat from testthis::test_subdir and added the argument which runs without any errors.

testthat::test_dir(
  file.path(usethis::proj_get(), testthat::test_path(), "integration_tests"),
  package = "pkg_name"
)

@s-fleck
Copy link
Owner

s-fleck commented Feb 10, 2022

Thanks! I'll look into it asap.

@s-fleck
Copy link
Owner

s-fleck commented Feb 15, 2022

So this is fixed now... Is it vital to deploy this to CRAN soon? I probably have to fix #19 as well before submitting a new CRAN release as well.

@markschat
Copy link
Author

Awesome! 🎉
For now I use a workaround, so releasing to CRAN is not critical for me right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants