Skip to content

[Bug] test_path() doesn't correctly go up directories #2299

@emstruong

Description

@emstruong

Hello,

I can't make a simple reprex, but as far as I can tell, test_path() can't go up directories. It can only see everything within tests/testthat

library(testthat)
testthat::test_path("../data")
#> Error in `testthat::test_path()`:
#> ! Can't find 'tests/testthat'.

Created on 2025-12-02 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.1 (2025-06-13)
#>  os       Ubuntu 22.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       America/Toronto
#>  date     2025-12-02
#>  pandoc   3.6.3 @ /usr/share/positron/resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)
#>  quarto   1.6.33 @ /opt/quarto/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  brio          1.1.5   2024-04-24 [1] RSPM
#>  cli           3.6.5   2025-04-23 [1] RSPM
#>  digest        0.6.39  2025-11-19 [1] RSPM
#>  evaluate      1.0.5   2025-08-27 [1] RSPM
#>  fastmap       1.2.0   2024-05-15 [1] RSPM
#>  fs            1.6.6   2025-04-12 [1] CRAN (R 4.5.1)
#>  glue          1.8.0   2024-09-30 [1] RSPM
#>  htmltools     0.5.8.1 2024-04-04 [1] RSPM
#>  knitr         1.50    2025-03-16 [1] CRAN (R 4.5.1)
#>  lifecycle     1.0.4   2023-11-07 [1] RSPM (R 4.5.0)
#>  magrittr      2.0.4   2025-09-12 [1] RSPM
#>  pillar        1.11.1  2025-09-17 [1] RSPM
#>  pkgload       1.4.1   2025-09-23 [1] RSPM
#>  R6            2.6.1   2025-02-15 [1] CRAN (R 4.5.1)
#>  reprex        2.1.1   2024-07-06 [1] RSPM
#>  rlang         1.1.6   2025-04-11 [1] RSPM
#>  rmarkdown     2.30    2025-09-28 [1] RSPM
#>  sessioninfo   1.2.3   2025-02-05 [1] RSPM
#>  testthat    * 3.3.1   2025-11-25 [1] RSPM
#>  vctrs         0.6.5   2023-12-01 [1] RSPM (R 4.5.0)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.5.1)
#>  xfun          0.54    2025-10-30 [1] RSPM
#>  yaml          2.3.11  2025-11-28 [1] CRAN (R 4.5.1)
#> 
#>  [1] /home/mstruong/R/x86_64-pc-linux-gnu-library/4.5
#>  [2] /opt/R/4.5.1/lib/R/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

If the reprex worked, what you would see returned is this

"tests/testthat/../data"

I would've expected

"tests/data"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions