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

let skip()s inside describe() only have scope inside describe() #2007

Open
maxheld83 opened this issue Nov 3, 2024 · 0 comments
Open

let skip()s inside describe() only have scope inside describe() #2007

maxheld83 opened this issue Nov 3, 2024 · 0 comments

Comments

@maxheld83
Copy link
Member

maxheld83 commented Nov 3, 2024

I assumed

  1. that it's fine to mix describe() and test_that() in a single test-*.R, as per:

    Use describe to verify that you implement the right things and use test_that() to ensure you do the things right.
    testthat docs

  2. that skip()s would have scope only inside any given describe(), just as is the case (and documented) for test_that():

    skip_if() and skip_if_not() allow you to skip tests, immediately concluding a test_that() block without executing any further expectations.
    testthat docs

so I wrote this:

test_that("foo", {
  skip()
  stop()
})
# this is *not* skipped, as expected
describe("bar", {
  it("bars", expect_true(TRUE))
})
describe("baz", {
  skip()
  it("bazs", expect_true(TRUE))
})
# below are all skipped, which is not expected
test_that("qux", expect_true(FALSE))
describe("quux", it("quuxs", expect_true(FALSE)))

expecting that all except foo and baz would be run.

However, devtools::test() yields:

✔ |      2   1 | test  

so only bar is run, and only foo and baz are skipped, the remaining qux and quux aren't even listed as skipped.

I'm guessing this is because skip_*()s inside describe() have higher (= file) scope than those inside test_that().

Based on my above assumptions 1) and 2) I assumed that skip_*()s would behave equally inside describe() and `test_that().

If 1) and 2) is intended, I'm guessing this behavior is a bug.

If 1) and/or 2) are wrong, I'd be happy to add some explanation to the docs in a PR.

session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.2 (2024-10-31)
 os       macOS Sequoia 15.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    UTF-8
 tz       Europe/Berlin
 date     2024-11-03
 pandoc   3.5 @ /opt/homebrew/bin/pandoc

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version    date (UTC) lib source
   backports     1.5.0      2024-05-23 [1] CRAN (R 4.4.0)
   brio          1.1.5      2024-04-24 [1] RSPM
   cachem        1.1.0      2024-05-16 [1] RSPM
   callr         3.7.6      2024-03-25 [1] CRAN (R 4.4.0)
   checkmate     2.3.2      2024-07-29 [1] CRAN (R 4.4.0)
   cli           3.6.3      2024-06-21 [1] CRAN (R 4.4.0)
   commonmark    1.9.2      2024-10-04 [1] CRAN (R 4.4.1)
   crayon        1.5.3      2024-06-20 [1] CRAN (R 4.4.0)
   desc          1.4.3      2023-12-10 [1] RSPM
   devtools    * 2.4.5      2022-10-11 [1] RSPM
   digest        0.6.37     2024-08-19 [1] CRAN (R 4.4.1)
   ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.4.0)
   evaluate      1.0.1      2024-10-10 [1] CRAN (R 4.4.1)
   fansi         1.0.6      2023-12-08 [1] CRAN (R 4.4.0)
   fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.4.0)
   fs            1.6.5      2024-10-30 [1] CRAN (R 4.4.1)
   glue          1.8.0      2024-09-30 [1] CRAN (R 4.4.1)
   highr         0.11       2024-05-26 [1] CRAN (R 4.4.0)
   htmltools     0.5.8.1    2024-04-04 [1] CRAN (R 4.4.0)
   htmlwidgets   1.6.4      2023-12-06 [1] CRAN (R 4.4.0)
   httpuv        1.6.15     2024-03-26 [1] RSPM
   jsonlite      1.8.9      2024-09-20 [1] CRAN (R 4.4.1)
   knitr         1.48       2024-07-07 [1] CRAN (R 4.4.0)
   later         1.3.2      2023-12-06 [1] RSPM
   lifecycle     1.0.4      2023-11-07 [1] RSPM
   magick        2.8.5      2024-09-20 [1] RSPM
   magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.4.0)
   memoise       2.0.1      2021-11-26 [1] RSPM
   mime          0.12       2021-09-28 [1] CRAN (R 4.4.0)
   miniUI        0.1.1.1    2018-05-18 [1] RSPM
 P niffler     * 0.0.0.9000 2024-11-03 [?] local
   pak         * 0.8.0      2024-08-26 [1] CRAN (R 4.4.1)
   pillar        1.9.0      2023-03-22 [1] CRAN (R 4.4.0)
   pkgbuild      1.4.5      2024-10-28 [1] CRAN (R 4.4.1)
   pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.4.0)
   pkgload       1.4.0      2024-06-28 [1] CRAN (R 4.4.0)
   png           0.1-8      2022-11-29 [1] CRAN (R 4.4.0)
   processx      3.8.4      2024-03-16 [1] CRAN (R 4.4.0)
   profvis       0.4.0      2024-09-20 [1] CRAN (R 4.4.1)
   promises      1.3.0      2024-04-05 [1] CRAN (R 4.4.0)
   ps            1.8.1      2024-10-28 [1] CRAN (R 4.4.1)
   purrr         1.0.2      2023-08-10 [1] CRAN (R 4.4.0)
   R6            2.5.1      2021-08-19 [1] CRAN (R 4.4.0)
   Rcpp          1.0.13     2024-07-17 [1] RSPM
   remotes       2.5.0      2024-03-17 [1] CRAN (R 4.4.0)
   reprex      * 2.1.1      2024-07-06 [1] RSPM
   rlang         1.1.4      2024-06-04 [1] CRAN (R 4.4.0)
   roxygen2      7.3.2      2024-06-28 [1] CRAN (R 4.4.0)
   rprojroot   * 2.0.4      2023-11-05 [1] CRAN (R 4.4.0)
   rstudioapi    0.17.1     2024-10-22 [1] CRAN (R 4.4.1)
   sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.4.0)
   shiny         1.9.1      2024-08-01 [1] RSPM
   shinytest2    0.3.2      2024-04-28 [1] RSPM
   showimage     1.0.0      2018-01-24 [1] CRAN (R 4.4.0)
   stringi       1.8.4      2024-05-06 [1] RSPM
   stringr       1.5.1      2023-11-14 [1] RSPM
   testthat    * 3.2.1.1    2024-04-14 [1] RSPM
   tibble        3.2.1      2023-03-20 [1] RSPM (R 4.4.0)
   urlchecker    1.0.1      2021-11-30 [1] RSPM
   usethis     * 3.0.0      2024-07-29 [1] CRAN (R 4.4.0)
   utf8          1.2.4      2023-10-22 [1] RSPM
   vctrs         0.6.5      2023-12-01 [1] CRAN (R 4.4.0)
   vdiffr        1.0.7      2023-09-22 [1] RSPM (R 4.4.0)
   waldo         0.5.3      2024-08-23 [1] RSPM
   withr         3.0.2      2024-10-28 [1] CRAN (R 4.4.1)
   xfun          0.49       2024-10-31 [1] CRAN (R 4.4.1)
   xml2          1.3.6      2023-12-04 [1] RSPM
   xtable        1.8-4      2019-04-21 [1] RSPM
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

1 participant