testthat
testthat copied to clipboard
Silently ignoring syntax error in test file?
To replicate, run the "numbers" tests in https://github.com/r-lib/pillar/commit/3611c62369a51541137e7d1c584cd3386b40f64b via testthat::test_local(filter = "numbers"). Can't (easily) create a reprex here.
The syntax error is tibble::tibble::tibble, which is rejected by the parser in a clean session.
It is a bug in parallel testthat.
❯ Sys.setenv(TESTTHAT_PARALLEL = "FALSE")
❯ testthat::test_local(filter = "numbers")
✔ | OK F W S | Context
⠏ | 0 | numbers
Error in parse(con, n = -1, srcfile = srcfile, encoding = "UTF-8") :
test-numbers.R:17:19: unexpected '::'
16: # FIXME: Use fixed digits
17: tibble::tibble::
I have a bug where a syntax error in a file causes testthat parallel to hang forever. The issue was a missing parenthesis, and there was no notification in the main process.
Is that the same as this?
@billdenney Possibly.
@gaborcsardi , I just tried to make a reprex, and I got this behavior. So, I think that either my issue was the same or it's fixed.
I have just been bitten by this. It seems that testthat::test_local() ignores all files with syntax errors when running in parallel. To reproduce, run the following in an empty directory:
usethis::create_package(".")
usethis::use_testthat(parallel = TRUE)
usethis::use_test("syntax")
# Whatever to create a syntax error
write("@", "tests/testthat/test-syntax.R", append = TRUE)
# Suceeds
testthat::test_local()
Tested with testthat 3.2.1.