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

Integrate 'testthat' into the Tests feature for R packages #1365

Closed
Tracked by #1467
jmcphers opened this issue Sep 21, 2023 · 8 comments
Closed
Tracked by #1467

Integrate 'testthat' into the Tests feature for R packages #1365

jmcphers opened this issue Sep 21, 2023 · 8 comments
Assignees
Labels
Milestone

Comments

@jmcphers
Copy link
Collaborator

Currently, if you have an R package and open the Testing view, it says that 'No tests have been found in the workspace', even if the workspace contains testthat tests.

image

We should:

  • Detect any testthat tests and display them in the Tests pane; support running tests, showing results, and jumping to errors
  • Have a "Configure R Tests" button that helps new users set up testthat for the first time
@jmcphers jmcphers added this to the Internal Preview milestone Sep 21, 2023
@jennybc
Copy link
Member

jennybc commented Sep 22, 2023

The first groundwork for this has been laid by @juliasilge in #915. That creates the scaffold for hooking into VS Code's test UI.

At the complete other extreme, I have standalone code that extracts the relevant test info (e.g. coordinates for test_that() calls, their descriptions) from a folder's worth of test files, using a tree-sitter-generated R parser. In a private repo: https://github.com/jennybc/treesitrrust.

The next phase is to create the plumbing that connects those two pieces.

Re: 'Have a "Configure R Tests" button that helps new users set up testthat for the first time'

☝️ if one can use R code, that is usethis::use_testthat() and, if not, then replicating that.

@jmcphers
Copy link
Collaborator Author

if one can use R code...

I think it's fine to lean on R code; it'd be nicer to have our own UI but not essential. We'll need an RStudio-like mechanism for helping users get bootstrapped by installing the packages needed for this kind of functionality ("configuring R tests requires usethis and testthat, would you like to install those now?").

@juliasilge
Copy link
Contributor

With #1445 we can now run tests in a little self-contained R session or alternatively in the console.

@juliasilge
Copy link
Contributor

With #915 merged in, we can now move on to a next step, such as parsing the test files.

@juliasilge
Copy link
Contributor

In build 1214 I see:

  • R package tests identified 🎉
  • I can click to run a test 🎉
  • the test does not run or return info to the UI about success/failure 😢

When I click to run a test, it looks like it is going but it never finishes (will wait for minutes) or returns success/failure info to the UI.

@jennybc
Copy link
Member

jennybc commented Nov 16, 2023

Having experienced this myself now in build 1214, my leading hypothesis is that it's this, quoting @jmcphers:

One thing you'll need to watch out for when you get closer to making a PR is that it can be a little tricky to get wasm files to get picked up properly when the extension is webpacked for release. You'll probably have to add it to positron-r/positron.json.

It's clear (from logging) that the hang is at the test file parsing stage.

@jennybc
Copy link
Member

jennybc commented Nov 18, 2023

Oh lordy, we're back in business and I think this is fixed now in release builds. A simple fix but rather hard to divine.

@juliasilge
Copy link
Contributor

In build 1327, I can use the testing extension for R packages. Looking so great! 🎉

Passing tests:

test2

A failing test:

test1

@wesm wesm added the lang: r label Feb 29, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants