Skip to content

Commit

Permalink
updated snapshot tests of rix_init
Browse files Browse the repository at this point in the history
  • Loading branch information
b-rodrigues committed Feb 3, 2025
1 parent 0ed4a71 commit 5f9305e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion tests/testthat/_snaps/rix_init/append_Rprofile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This is in the original Rprofile
{
is_rstudio <- Sys.getenv("RSTUDIO") == "1"
is_nix_r <- nzchar(Sys.getenv("NIX_STORE"))
is_code <- Sys.getenv("TERM_PROGRAM") == "vscode"
is_positron <- Sys.getenv("POSITRON") == "1"
if (isFALSE(is_nix_r) && isTRUE(is_rstudio)) {
cat("{rix} detected RStudio R session")
old_path <- Sys.getenv("PATH")
Expand Down Expand Up @@ -38,5 +40,16 @@ This is in the original Rprofile
.libPaths(new_paths)
rm(current_paths, userlib_paths, user_dir, new_paths)
}
rm(is_rstudio, is_nix_r)
if (isTRUE(is_code) && interactive() && isFALSE(is_rstudio) && isFALSE(is_positron)) {
vscode_r_init <- file.path(Sys.getenv(if (.Platform$OS.type == "windows")
"USERPROFILE"
else "HOME"), ".vscode-R", "init.R")
if (file.exists(vscode_r_init)) {
source(vscode_r_init)
}
else {
message("No .vscode-R/init.R file found. If you want to use VSCode-R, you need to source it in your .Rprofile or start vscode from within nix-shell")
}
}
rm(is_rstudio, is_nix_r, is_code, is_positron)
}
15 changes: 14 additions & 1 deletion tests/testthat/_snaps/rix_init/golden_Rprofile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
{
is_rstudio <- Sys.getenv("RSTUDIO") == "1"
is_nix_r <- nzchar(Sys.getenv("NIX_STORE"))
is_code <- Sys.getenv("TERM_PROGRAM") == "vscode"
is_positron <- Sys.getenv("POSITRON") == "1"
if (isFALSE(is_nix_r) && isTRUE(is_rstudio)) {
cat("{rix} detected RStudio R session")
old_path <- Sys.getenv("PATH")
Expand Down Expand Up @@ -37,5 +39,16 @@
.libPaths(new_paths)
rm(current_paths, userlib_paths, user_dir, new_paths)
}
rm(is_rstudio, is_nix_r)
if (isTRUE(is_code) && interactive() && isFALSE(is_rstudio) && isFALSE(is_positron)) {
vscode_r_init <- file.path(Sys.getenv(if (.Platform$OS.type == "windows")
"USERPROFILE"
else "HOME"), ".vscode-R", "init.R")
if (file.exists(vscode_r_init)) {
source(vscode_r_init)
}
else {
message("No .vscode-R/init.R file found. If you want to use VSCode-R, you need to source it in your .Rprofile or start vscode from within nix-shell")
}
}
rm(is_rstudio, is_nix_r, is_code, is_positron)
}

0 comments on commit 5f9305e

Please sign in to comment.