Skip to content

Commit

Permalink
disable test creating a .RProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Vannoorenberghe committed Oct 2, 2017
1 parent ae90c3a commit 88788dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
11 changes: 7 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ get_package_from_URL <- function(url){
}

get_r_profile <- function(){
if (!file.exists(file.path(Sys.getenv("HOME"),".Rprofile"))) {
file.create(file.path(Sys.getenv("HOME"), ".Rprofile"), quiet=TRUE)
}
Rprofile <- file.path(Sys.getenv("HOME"), ".Rprofile")
return (Rprofile)
return (file(Rprofile, "w+"))
}

concat <- function(x) {
paste(x, collapse = ",")
}

is_in_profile <- function(targets) {
if (!file.exists(file.path(Sys.getenv("HOME"),".Rprofile"))) {
return (FALSE)
}
any(targets %in% readLines(get_r_profile()))
}

Expand All @@ -83,6 +83,9 @@ add_to_profile <- function(the_line, old_lines = "") {
}

remove_from_profile <- function(the_line, old_lines = "") {
if (!file.exists(file.path(Sys.getenv("HOME"),".Rprofile"))) {
return ()
}
rprofile <- get_r_profile()
lines <- readLines(rprofile)
# Keep all non-matching lines
Expand Down
19 changes: 0 additions & 19 deletions tests/testthat/test-defaults.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
context("defaults")

test_that("autoloads",{
disable_autoload()
expect_false(autoload_line %in% readLines(get_r_profile()))
expect_false(is_autoload())
enable_autoload()
expect_true(autoload_line %in% readLines(get_r_profile()))
expect_true(is_autoload())
disable_autoload()
expect_false(autoload_line %in% readLines(get_r_profile()))
expect_false(is_autoload())
enable_autoload()
write(autoload_line_old, file = get_r_profile(), append = TRUE)
expect_true(is_autoload())
disable_autoload()
expect_false(autoload_line %in% readLines(get_r_profile()))
expect_false(autoload_line_old %in% readLines(get_r_profile()))
expect_false(is_autoload())
})

test_that("overrides", {
disable_rdocs()
expect_false(rdocs_active())
Expand Down

0 comments on commit 88788dd

Please sign in to comment.