Hello,
Instead of going through the process of creating a reproducible example, can you just look at this diff?
diff --git a/R/proj.R b/R/proj.R
index 5ac1e5e..974b301 100644
--- a/R/proj.R
+++ b/R/proj.R
@@ -274,11 +274,11 @@ proj_activate <- function(path) {
rstudioapi::openProject(path, newSession = TRUE)
invisible(FALSE)
} else {
+ proj_set(path)
if (user_path_prep(getwd()) != path) {
ui_done("Changing working directory to {ui_path(path, base = NA)}")
setwd(path)
}
- proj_set(path)
invisible(TRUE)
}
}
diff --git a/tests/testthat/test-proj.R b/tests/testthat/test-proj.R
index 5294411..22bfe4b 100644
--- a/tests/testthat/test-proj.R
+++ b/tests/testthat/test-proj.R
@@ -1,5 +1,19 @@
context("projects")
+test_that("proj_activate() on relative dir", {
+ tmpdir <- file_temp()
+ tmpleaf <- basename(tmpdir)
+ tmpparent <- dirname(tmpdir)
+ on.exit(dir_delete(tmpdir))
+ dir_create(tmpdir)
+ setwd(tmpparent)
+ proj_activate(tmpleaf) # This is the important part.
+ expect_equal(
+ getwd(),
+ tmpdir
+ )
+})
+
test_that("proj_set() errors on non-existent path", {
expect_usethis_error(
proj_set("abcedefgihklmnopqrstuv"),
Unfortunately the tests cannot be run for some reason, so if there are any regressions that is possibly going to need someone to look at the tests themselves.
Here is the output of the tests:
> devtools::test()
Loading usethis
Attaching package: ‘testthat’
The following object is masked from ‘package:devtools’:
test_file
✔ Setting active project to '/usr/home/r/usethis'
Error in importIntoEnv(pkgenv, exports, nsenv, exports) :
cannot change value of locked binding for 'proj_get'
Calls: test ... load_all -> <Anonymous> -> export_ns -> importIntoEnv
> traceback()
5: importIntoEnv(pkgenv, exports, nsenv, exports)
4: export_ns(package)
3: pkgload::load_all(path = path, reset = reset, recompile = recompile,
export_all = export_all, helpers = helpers, quiet = quiet,
...)
2: load_all(pkg$path, quiet = TRUE)
1: test()
Code created by my friend _@thomaslevine.com He prefers to not use proprietary software so I am giving him a hand.
If you seriously need a reprex I am sure that can be produced, but obviously it's merely a formality at this point since we already have a diff.
Hello,
Instead of going through the process of creating a reproducible example, can you just look at this diff?
Unfortunately the tests cannot be run for some reason, so if there are any regressions that is possibly going to need someone to look at the tests themselves.
Here is the output of the tests:
Code created by my friend
_@thomaslevine.comHe prefers to not use proprietary software so I am giving him a hand.If you seriously need a reprex I am sure that can be produced, but obviously it's merely a formality at this point since we already have a diff.