From 410234f999642d10b7d3250cc28edb13edc6ed10 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Thu, 18 Jan 2024 12:34:41 +0000 Subject: [PATCH] Avoid looking at the RStudio state when running tests inside of it. --- R/interactive.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/interactive.R b/R/interactive.R index 332ef7dd..519ee02d 100644 --- a/R/interactive.R +++ b/R/interactive.R @@ -7,7 +7,10 @@ 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. + # https://github.com/r-lib/testthat/blob/fe50a222c62cc8733b397690caf3b2a95856f902/R/test-env.R#L20 + testing <- identical(Sys.getenv("TESTTHAT"), "true") + if (!testing && rstudioapi::isAvailable()) { rstudioapi::getSourceEditorContext()$path } else { NULL