Skip to content

Commit

Permalink
add a test case for #1224 and #1288 (Travis should fail for this commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Dec 6, 2018
1 parent a0c0c68 commit 9b609e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/rmd/output_dir.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Warning in file.rename(from, to)"
---

See https://github.com/rstudio/rmarkdown/issues/1224 for details.

```{r}
plot(1)
```
12 changes: 12 additions & 0 deletions tests/testrmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ if (.Platform$OS.type == 'unix' && !is.na(Sys.getenv('CI', NA))) {
system2(rmarkdown::pandoc_exec(), '--print-default-data-file reference.docx', stdout = 'rmd/template.docx')
rmarkdown::render('rmd/word.Rmd', intermediates_dir = 'tmp')

# use an absolute output_dir should not trigger a file.rename() warning
# (https://github.com/rstudio/rmarkdown/issues/1224)
withCallingHandlers(
rmarkdown::render(
'rmd/output_dir.Rmd', output_dir = file.path(tempdir(), 'output'),
intermediates_dir = file.path(tempdir(), 'tmp')
), warning = function(e) {
if (identical(deparse(e$call), 'file.rename(from, to)') || grepl('cannot rename file', e$message)) {
stop(e)
}
}
)
}

0 comments on commit 9b609e7

Please sign in to comment.