Skip to content

Commit

Permalink
Test case showing inter-function dependencies
Browse files Browse the repository at this point in the history
I think this is already implicitly done within the code deps checking,
but this is nice to have.  Motivated by question from @aammd
  • Loading branch information
richfitz committed Sep 3, 2015
1 parent e9c7149 commit eb2d2a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/remake_dependncies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sources:
- dependencies.R

targets:
all:
command: bar()
22 changes: 22 additions & 0 deletions tests/testthat/test-remake.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,25 @@ test_that("ggplot targets", {
file.remove("plot_auto.png")
}
})

## Courtesy of Andrew:
test_that("Function dependencies", {
code <- c('foo <- function() "A"',
'bar <- function() foo()')
filename <- "dependencies.R"
writeLines(code, filename)
on.exit(file.remove(filename))

res <- make("all", remake_file="remake_dependncies.yml")
expect_that(res, equals("A"))
expect_that(is_current("all", remake_file="remake_dependncies.yml"),
is_true())

code[[1]] <- sub("A", "B", code[[1]])
writeLines(code, filename)

expect_that(is_current("all", remake_file="remake_dependncies.yml"),
is_false())
res <- make("all", remake_file="remake_dependncies.yml")
expect_that(res, equals("B"))
})

0 comments on commit eb2d2a5

Please sign in to comment.