From dc4909ff0d9bbc7173d4e7f73ab52b0141e2e6a4 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Wed, 2 Dec 2020 11:17:42 -0500 Subject: [PATCH 1/3] Add test that should fail on windows --- tests/testthat/test-utils.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 6cb7b03e..245060bc 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -93,3 +93,8 @@ test_that("can find three styles of app", { expect_error(app_path(test_path("apps/two-rmd")), "exactly one") expect_error(app_path(test_path("apps/two-rmd/doc1.Rmd")), "only one") }) + + +test_that("app_path works with trailing slash", { + expect_error(app_path("../"), NA) +}) From 4f3ce0f69ae05665ee813d8ff46f0ab8b4450339 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Wed, 2 Dec 2020 11:53:35 -0500 Subject: [PATCH 2/3] Use actual app path (but still end in `/`) --- tests/testthat/test-utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 245060bc..4c058c70 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -96,5 +96,5 @@ test_that("can find three styles of app", { test_that("app_path works with trailing slash", { - expect_error(app_path("../"), NA) + expect_error(app_path("apps/stopApp/"), NA) }) From e3bbd1380aa2dc7f2c4043724c8bddb27ed9459c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Wed, 2 Dec 2020 12:11:47 -0500 Subject: [PATCH 3/3] Windows safe `file.exists(path)` by also checking if `dir.exists(path)` --- R/utils.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 27714366..f5884352 100644 --- a/R/utils.R +++ b/R/utils.R @@ -139,7 +139,8 @@ is_app <- function(path) { } app_path <- function(path, arg = "path") { - if (!file.exists(path)) { + # must also check for dir (windows trailing '/') + if (!(file.exists(path) || dir.exists(path))) { stop(paste0("'", path, "' doesn't exist"), call. = FALSE) }