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

DESCRIPTION can break test_r() #461

Open
kamilzyla opened this issue Jun 1, 2023 · 0 comments
Open

DESCRIPTION can break test_r() #461

kamilzyla opened this issue Jun 1, 2023 · 0 comments
Labels
type: bug Defect or unexpected limitation in existing functionality

Comments

@kamilzyla
Copy link
Collaborator

kamilzyla commented Jun 1, 2023

Steps to reproduce

  1. Initialize a fresh Rhino app.
  2. In the parent directory create a DESCRIPTION file with the following content:
    Package: whatever
    Config/testthat/edition: 3
    Config/testthat/parallel: true
    
  3. Run rhino::test_r() inside the Rhino app directory.

Bug description

The rhino::test_r() function fails to run with an error along the lines:

> rhino::test_r()
Starting 1 test process
✔ | F W S  OK | Context
⠼ [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ] Starting up...                                                                                                                                                                                                                                    

Error in `private$handle_error()`:
! testthat subprocess failed to start, stderr:
Error in idesc_get_version(self, private) : No ‘Version’ field found
Calls: callr_startup_hook ... desc_desc_get_version -> <Anonymous> -> idesc_get_version
Caused by error:
! R session crashed with exit code 1
Run `rlang::last_trace()` to see where the error occurred.

Expected behavior

The rhino::test_r() function should run normally. A DESCRIPTION file in a parent directory of a Rhino app should not affect it in any way.

Rhino diagnostics

Linux 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30)
R version 4.1.1 (2021-08-10)
rhino: 1.3.1
node: v16.20.0

Comments

The problems seems to boil down to this: testthat::test_dir() (called by rhino::test_r()) ascends to ancestor directories trying to find a DESCRIPTION file to read some config from it. This is undesirable in our case and caused a headache when working on #58 (see this comment).

The following shell script can be used to reproduce the problem without involving Rhino (checked with testthat 3.1.7):

mkdir app
touch app/test-app.R

Rscript -e 'testthat::test_dir("app")' # Works fine

cat <<EOF >DESCRIPTION
Package: whatever
Config/testthat/edition: 3
Config/testthat/parallel: true
EOF

Rscript -e 'testthat::test_dir("app")' # Fails

The full error is as follows:

Starting 1 test process
✔ | F W S  OK | Context
⠸ [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ] Starting up...                                                                                                                                                                                                                                    

Error in `private$handle_error()`:
! testthat subprocess failed to start, stderr:
Error in idesc_get_version(self, private) : No ‘Version’ field found
Calls: callr_startup_hook ... desc_desc_get_version -> <Anonymous> -> idesc_get_version
Caused by error:
! R session crashed with exit code 1
Backtrace:
     ▆
  1. └─testthat::test_dir("app")
  2.   └─testthat:::test_files(...)
  3.     └─testthat:::test_files_parallel(...)
  4.       ├─testthat::with_reporter(...)
  5.       │ └─base::tryCatch(...)
  6.       │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  7.       │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  8.       │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  9.       └─testthat:::parallel_event_loop_smooth(queue, reporters)
 10.         └─queue$poll(poll_time)
 11.           └─base::lapply(...)
 12.             └─testthat (local) FUN(X[[i]], ...)
 13.               └─private$handle_error(msg, i)
 14.                 └─rlang::abort(...)
Execution halted
@kamilzyla kamilzyla added status: triage Awaiting review and labeling by a core developer type: bug Defect or unexpected limitation in existing functionality and removed status: triage Awaiting review and labeling by a core developer labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Defect or unexpected limitation in existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant