Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release of {knitr} is causing tests to fail #389

Closed
zkamvar opened this issue Jan 25, 2023 · 1 comment · Fixed by #387
Closed

New release of {knitr} is causing tests to fail #389

zkamvar opened this issue Jan 25, 2023 · 1 comment · Fixed by #387

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Jan 25, 2023

Let this be a lesson to you kids about writing tests based on expectations of messages from other packages.

Consider this test:

test_that("Lessons built for the first time are noisy", {
skip_if_not(rmarkdown::pandoc_available("2.11"))
# It's noisy at first
suppressMessages({
expect_output(build_lesson(tmp, preview = FALSE, quiet = FALSE),
"ordinary text without R code")
})

We expect knitr to produce output that says "ordinary text without R code" like this:

> knitr::knit(text = "hello there!\n\n```{r rversion}\nR.version.string\n```\n") |> writeLines
  ()                                                                                          
  |............................                                                        |  33%
  ordinary text without R code

  |........................................................                            |  67%
label: rversion
  |....................................................................................| 100%
  ordinary text without R code


hello there!


```r
R.version.string
```

```
## [1] "R version 4.2.2 Patched (2022-11-10 r83330)"
```

Well.... I should have really paid attention because this progress bar has been a thorn in Hadley's craw for a WHILE: yihui/knitr#1880

With {knitr} version 1.42, the printing is now completely changed:

> knitr::knit(text = "hello there!\n\n```{r rversion}\nR.version.string\n```\n") |> writeLines
  ()                                                                                         
  |                                                                         |   0%
  |........................                                                 |  33%           
  |.................................................                        |  67% (rversion)                                                                               
  |.........................................................................| 100%           
                                                                                                                                                                

hello there!


```r
R.version.string
```

```
## [1] "R version 4.2.2 Patched (2022-11-10 r83330)"
```

Which means that, while there is output, it's no longer the output we expect and thus it breaks our tests 😢

@zkamvar zkamvar changed the title New release of {knitr} is causing my tests to fail New release of {knitr} is causing tests to fail Jan 25, 2023
@zkamvar
Copy link
Contributor Author

zkamvar commented Jan 25, 2023

The good thing is that I now have a pathway to improve the progress bars if I wanted to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant