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

Is check-test-warnings broken? #47

Closed
etiennebacher opened this issue Oct 12, 2023 · 3 comments
Closed

Is check-test-warnings broken? #47

etiennebacher opened this issue Oct 12, 2023 · 3 comments

Comments

@etiennebacher
Copy link
Member

etiennebacher commented Oct 12, 2023

Following easystats/datawizard#465, I removed all tests but one in datawizard and put a warning() call inside:

test_that("standardize.lm", {
  warning("foo")
  expect_equal(1+1, 2)
})

Then I ran:

options(crayon.enabled = TRUE, warn = 2L)
devtools::test()

and it showed a test warning but not a failure:

ℹ Testing datawizard
Starting 1 test process
✔ | F W  S  OK | Context
✔ |   1      1 | standardize_models                                                                                     
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning (test-standardize_models.R:3:3): standardize.lm
foo
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                                        
══ Results ═════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 1.6 s

[ FAIL 0 | WARN 1 | SKIP 0 | PASS 1 ]

Replacing warning() by stop() correctly shows a test failure.

IndrajeetPatil added a commit that referenced this issue Oct 13, 2023
@IndrajeetPatil
Copy link
Member

I can confirm that this workflow is broken. The way to make this work is to use testthat::test_dir() with options(warn = 2L). But this causes problems if parallel testing is turned on, which I suspect is a bug in {testthat}.

@IndrajeetPatil
Copy link
Member

Bug report filed upstream r-lib/testthat#1912

IndrajeetPatil added a commit that referenced this issue May 26, 2024
@IndrajeetPatil
Copy link
Member

Closed in daf6ede

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

No branches or pull requests

2 participants