Skip to content

Commit 26f7790

Browse files
committed
test fixups
1 parent 9274c79 commit 26f7790

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

R/renvignore.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ renv_renvignore_parse_impl <- function(entries, prefix = "") {
154154
# prepend prefix
155155
entries <- sprintf("^\\Q%s/\\E%s", prefix, entries)
156156

157-
# remove \\Q\\E
157+
# remove \\Q\\E, \\E\\Q
158158
entries <- gsub("\\Q\\E", "", entries, fixed = TRUE)
159+
entries <- gsub("\\E\\Q", "", entries, fixed = TRUE)
159160

160161
# all done!
161162
entries

tests/testthat/test-renvignore.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_that(".renvignore ignores files, directories", {
2020
expect_setequal(deps$Package, "oatmeal")
2121

2222
deps <- dependencies("scripts", root = getwd())
23-
expect_true(NROW(deps) == 0)
23+
expect_true(NROW(deps) == 0L)
2424

2525
})
2626

@@ -35,30 +35,30 @@ test_that("ignore patterns are constructed correctly", {
3535
# ignore data directory at root of project
3636
expect_equal(
3737
renv_renvignore_parse_impl("/data", "/project"),
38-
"^\\Q/project/\\E\\Qdata\\E(?:/)?$"
38+
"^\\Q/project/data\\E(?:/)?$"
3939
)
4040

4141
# multiple ignores are parsed separately
4242
expect_equal(
4343
renv_renvignore_parse_impl(c("/data1", "/data2"), "/project"),
4444
c(
45-
"^\\Q/project/\\E\\Qdata1\\E(?:/)?$",
46-
"^\\Q/project/\\E\\Qdata2\\E(?:/)?$"
45+
"^\\Q/project/data1\\E(?:/)?$",
46+
"^\\Q/project/data2\\E(?:/)?$"
4747
)
4848
)
4949

5050
# sub-directory ignores are handled
5151
expect_equal(
5252
renv_renvignore_parse_impl("data/internal", "/project"),
53-
"^\\Q/project/\\E\\Qdata/internal\\E(?:/)?$"
53+
"^\\Q/project/data/internal\\E(?:/)?$"
5454
)
5555

5656
# negations are handled
5757
expect_equal(
5858
renv_renvignore_parse(c("abc.R", "!def.R")),
5959
list(
6060
exclude = "^\\Q/\\E(?:.*/)?\\Qabc.R\\E(?:/)?$",
61-
include = "^\\Q/\\E\\Qdef.R\\E(?:/)?$"
61+
include = "^\\Q/\\E(?:.*/)?\\Qdef.R\\E(?:/)?$"
6262
)
6363
)
6464

0 commit comments

Comments
 (0)