Skip to content

Breakpoints not working with devtools::test + testthat #187

@katrinabrock

Description

@katrinabrock

NOTE: Before submitting an issue, please make sure to install the latest version of both the vscode extension and the R package. This can usually be achieved by running the command r.debugger.updateRPackage in vscode's command palette (F1).

Describe the bug
devtools::test() doesn't trigger breakpoints in testing file or package.

MRE

  1. Open this repo as an r project with vsc r debugger enabled: https://github.com/katrinabrock/minimal-r-package
  2. Open tests/testthat/test-output.R).
  3. Add some breakpoints.
  4. Run the Debug testthat test config. (This runs devtools::test(filter='output'))
    image

Your Launch config
If applicable, the launch config that causes the bug. E.g.:

https://github.com/katrinabrock/minimal-r-package/blob/main/.vscode/launch.json#L15-L23

Expected behavior
Dropped into debug console at breakpoints.

Actual behavior
Tests run without stopping at breakpoints.

Desktop (please complete the following information):

  • OS: Desktop is Mac OS, using VS Code Remote..remote (where R is running) is Ubuntu
  • R Version: 4.3.2
  • VSCode version: 1.92.2
  • vscDebugger Version: 0.5.3
  • vscode-r-debugger Version: v0.5.4

Additional context

  • Breakpoints in the code that calls devtools::test (in this case example2.R): working ✅
  • Breakpoints in the test files themselves: not working ❌
  • Breakpoints in package functions called within the tests: not working: ❌
  • Direct browser calls: working everywhere ✅
    I believe this is failing because testthat runs pkgload::load_all(): https://github.com/r-lib/testthat/blob/fe38519d72247a8907228a4ecaf926483aa5d4ff/R/test-files.R#L235 and that call is not successfully getting overwritten with vscDebugger::.vsc.load_all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions