-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# todo() errors and messages | ||
|
||
Code | ||
todos(path = path) | ||
Output | ||
Found 2 TODO: | ||
scripts/todos.R | ||
[3] make x longer | ||
[7] add another example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is a file that doesn't do much | ||
|
||
# TODO make x longer | ||
x <- 1:10 | ||
length(x) | ||
|
||
# TODO add another example | ||
|
||
# FIXME This is a fixme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
test_that("todos() works", { | ||
path <- test_path("scripts") | ||
file <- test_path("scripts/todos.R") | ||
|
||
res <- todos(path = path) | ||
exp <- struct( | ||
list( | ||
line = c(3L, 7L), | ||
file = rep(file, 2), | ||
todo = c("make x longer", "add another example") | ||
), | ||
c("todos_df", "data.frame"), | ||
todos_type = "todo", | ||
row.names = 1:2, | ||
.keep_attr = TRUE | ||
) | ||
|
||
expect_identical(res, exp) | ||
|
||
res <- todos(pattern = "example", path = path) | ||
exp <- struct( | ||
list( | ||
line = 7L, | ||
file = file, | ||
todo = "add another example" | ||
), | ||
c("todos_df", "data.frame"), | ||
todos_type = "todo", | ||
row.names = 1L, | ||
.keep_attr = TRUE | ||
) | ||
|
||
expect_identical(res, exp) | ||
|
||
res <- fixmes(path = path) | ||
exp <- struct( | ||
list( | ||
line = 9L, | ||
file = file, | ||
fixme = "This is a fixme" | ||
), | ||
c("todos_df", "data.frame"), | ||
todos_type = "fixme", | ||
row.names = 1L, | ||
.keep_attr = TRUE | ||
) | ||
|
||
expect_identical(res, exp) | ||
}) | ||
|
||
test_that("todo() errors and messages", { | ||
path <- test_path("scripts") | ||
|
||
err <- "path must be a character vector of length 1L" | ||
expect_error(todos(path = 1), err) | ||
expect_error(todos(path = c("a", "b")), err) | ||
expect_error(todos(path = "zzz"), "path not found: zzz") | ||
expect_error(do_todo(c("todo", "fixme"), path = "."), "Length of text must be 1") | ||
|
||
expect_message(res <- todos("zzzzzz", path = path), "No todos found") | ||
expect_null(res) | ||
|
||
expect_snapshot(todos(path = path)) | ||
}) |