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

testthat::set_max_fails() not working anymore #2723

Closed
EmilHvitfeldt opened this issue Apr 10, 2024 · 9 comments
Closed

testthat::set_max_fails() not working anymore #2723

EmilHvitfeldt opened this issue Apr 10, 2024 · 9 comments
Assignees
Labels
bug Something isn't working lang: r

Comments

@EmilHvitfeldt
Copy link

Positron Version:

Positron Version: 2024.04.0 (Universal) build 29
Code - OSS Version: 1.87.0
Commit: 6c41ddd
Date: 2024-04-04T03:32:13.676Z
Electron: 27.3.2
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.4.0

Steps to reproduce the issue:

  1. run testthat::set_max_fails(1000)
  2. run test R package command
  3. have many failures
Kapture.2024-04-10.at.09.58.06.mp4

What did you expect to happen?

I feel like this used to work (although, didn't check)

Were there any error messages in the output or Developer Tools console?

Nope

@EmilHvitfeldt EmilHvitfeldt added the bug Something isn't working label Apr 10, 2024
@DavisVaughan
Copy link
Contributor

That just sets the TESTTHAT_MAX_FAILS env var so we are likely not inheriting session env vars in the subprocess

@DavisVaughan DavisVaughan added this to the Release Candidate milestone Apr 10, 2024
@jennybc
Copy link
Member

jennybc commented Apr 10, 2024

@EmilHvitfeldt since you seem to have a good test case of massive test failure at hand 😄, what happens in RStudio?

@DavisVaughan
Copy link
Contributor

RStudio's build pane inherits the env vars of the R process, so it "just works" and will chug through all the tests because it inherits the new max failure limit of 1k

@lionel-
Copy link
Contributor

lionel- commented Apr 17, 2024

Two ways we could go about this:

  • Expose a .ps.set_env() function that testthat and others would use to manipulate envvars in positron
  • Inspect the environment of the R session and reproduce it when launching subprocesses

The second approach has the downside that it might make it a bit harder to create reproducible behaviour in subprocesses. Did that come up as an issue in RStudio?

@DavisVaughan
Copy link
Contributor

We probably want variants for "clean" R subprocesses and "make it look like the current session" R subprocesses

@lionel-
Copy link
Contributor

lionel- commented Apr 17, 2024

That would be nice but it's not clear which one we should choose in this case. We want a clean process to run tests but also propagate user configuration.

Maybe the solution in this case is to call set_max_fail() in Rprofile though.

@jennybc
Copy link
Member

jennybc commented Apr 17, 2024

We have encountered this type of problem before. It's why I ask the running session for its locale-related info and then pass LANG along to the test explorer's child process here in #2488. I guess it's the downside (outweighed by lots of upsides) of having these "side" processes encapsulated from the main R session.

Another alternative is for the env vars to transmit to be task-specific, by using the options argument in these ShellExecution calls:

new vscode.ShellExecution(
binpath,
['-e', { value: data.rcode, quoting: vscode.ShellQuoting.Strong }]
),

Maybe our taskData entries should optionally include env vars to transmit. And for r.task.packageTest this would include testthat usual suspects, such as TESTTHAT_MAX_FAILS.

@juliasilge juliasilge self-assigned this Sep 6, 2024
juliasilge added a commit that referenced this issue Sep 11, 2024
Addresses #2723

Together with posit-dev/ark#507, this sets up
infrastructure so we can propagate known sets of environment variables
to our tasks that use `ShellExecution` (or `ProcessExecution`). I added
the `TESTTHAT` environment variables for `devtools::test()` only, for
now. We can add other sets of environment variables as they come up.

### TODO:

- [x] Bump ark

### QA Notes

To QA this, you'll need an R package with some failing tests. [Here's
one!](https://github.com/juliasilge/vamplyr)

- Run `testthat::set_max_fails(1)` in the console
- Run the command "R: Test R Package"
- Notice that although this package has 4 failing tests, only ones from
the first file are run. You'll see output like this:

> Maximum number of failures exceeded; quitting at end of file.
> ℹ Increase this number with (e.g.) `testthat::set_max_fails(Inf)`

---------

Signed-off-by: Julia Silge <[email protected]>
@juliasilge
Copy link
Contributor

I've got QA notes available here: #4606 (comment)

@testlabauto
Copy link
Contributor

Verified Fixed

Positron Version(s) : 2024.09.0-33
OS Version          : OSX

Test scenario(s)

Hit:
Maximum number of failures exceeded; quitting at end of file.
After setting:
testthat::set_max_fails(1)

Link(s) to TestRail test cases run or created:
N/A

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lang: r
Projects
None yet
Development

No branches or pull requests

6 participants