Skip to content

Commit a4ffca8

Browse files
authored
Merge pull request #72 from metrumresearchgroup/render-relpath-fix
render_scorecard: fix recent regression in relative path handling
2 parents fb4dda3 + d7f0808 commit a4ffca8

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: mpn.scorecard
22
Title: Generate a scorecard with various measures of R package quality and risk
3-
Version: 0.4.1
3+
Version: 0.4.1.8000
44
Authors@R:
55
c(person(given = "Kyle",
66
family = "Barrett",

R/render-scorecard.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ render_scorecard <- function(
3939
} else {
4040
param_fn <- get_render_params
4141
}
42+
# Note: this should be evaluated outside of the rmarkdown::render() call
43+
# because render() changes the directory before evaluating its params
44+
# argument, breaking relative path handling.
45+
pars <- param_fn(results_dir, risk_breaks, add_traceability)
4246

4347
rendered_file <- rmarkdown::render(
4448
system.file(SCORECARD_RMD_TEMPLATE, package = "mpn.scorecard", mustWork = TRUE), # TODO: do we want to expose this to users, to pass their own custom template?
4549
output_dir = results_dir,
4650
output_file = basename(out_file),
4751
quiet = TRUE,
48-
params = param_fn(results_dir, risk_breaks, add_traceability)
52+
params = pars
4953
)
5054

5155
return(invisible(rendered_file))

tests/testthat/test-render-scorecard.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ describe("render scorecard and scorecard summary reports", {
2929
}
3030
})
3131

32+
it("render_scorecard - relative path", {
33+
rdir <- result_dirs_select[1]
34+
withr::with_dir(dirname(rdir), {
35+
pdf_path <- render_scorecard(basename(rdir), overwrite = TRUE)
36+
on.exit(fs::file_delete(fs::path_abs(pdf_path)), add = TRUE)
37+
})
38+
})
39+
3240
it("render_scorecard - with traceability matrix", {
3341

3442
# `result_dirs_select` defined in tests/testthat/setup.R

0 commit comments

Comments
 (0)