Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion R/namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ namespace_imports <- function(base_path = ".") {
paths <- package_files(base_path)
parsed <- lapply(paths, parse, keep.source = TRUE)
srcrefs <- lapply(parsed, utils::getSrcref)
blocks <- unlist(lapply(srcrefs, namespace_imports_blocks), recursive = FALSE)
# Ensure parse warnings only fire once during the main parse_package() pass
suppressMessages(
blocks <- unlist(
lapply(srcrefs, namespace_imports_blocks),
recursive = FALSE
)
)

blocks_to_ns(blocks, emptyenv())
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/namespace.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# parsing warnings only fire once

Code
roxygenise(path)
Message
Writing 'NAMESPACE'
i Loading testNamespace
x multiline.R:1: @importFrom must be only 1 line long, not 2.
i The first line is "stats median"

# @exportS3Method generates fully automatically

Code
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ test_that("end-to-end NAMESPACE generation works", {
)
})

test_that("parsing warnings only fire once", {
path <- local_package_copy(test_path("testNamespace"))
write_lines(
c("#' @importFrom stats median", "#' ave", "NULL"),
file.path(path, "R", "multiline.R")
)
withr::defer(pkgload::unload("testNamespace"))

# Warning fires once (during the main parse_package() pass),
# not also during update_namespace_imports()'s early pass.
expect_snapshot(roxygenise(path))
})


# @export -----------------------------------------------------------------

test_that("export quote object name appropriate", {
Expand Down
Loading