Skip to content

Commit

Permalink
Avoid looking at the RStudio state when running tests inside of it.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Jan 18, 2024
1 parent ceb0d66 commit 2933414
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/interactive.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ is_plausible_orderly_report <- function(path) {
}

rstudio_get_current_active_editor_path <- function() {
if (rstudioapi::isAvailable()) {
# Avoid looking at the RStudio state when running tests inside of it.
if (!is_testing() && rstudioapi::isAvailable()) {
rstudioapi::getSourceEditorContext()$path
} else {
NULL
Expand Down
7 changes: 7 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,10 @@ paths_are_different <- function(x, y) {
x_real != y_real
}, error = function(e) FALSE)
}


is_testing <- function() {
# Copied from testthat, to avoid having the package as a run-time dependency.
# https://github.com/r-lib/testthat/blob/fe50a222c62cc8733b397690caf3b2a95856f902/R/test-env.R#L20
identical(Sys.getenv("TESTTHAT"), "true")
}

0 comments on commit 2933414

Please sign in to comment.