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

Avoid partial matching when extracting metadata element #526

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

Bisaloo
Copy link
Contributor

@Bisaloo Bisaloo commented Sep 26, 2023

This removes the partial matching warnings I was seeing.

I'm seeing some test failures locally but it looks like it's because I'm missing some files or because I'm using different system library versions. Let's try it on CI.

Fix #525

@zkamvar
Copy link
Contributor

zkamvar commented Sep 26, 2023

Thank you!

I'm seeing some test failures locally but it looks like it's because I'm missing some files or because I'm using different system library versions.

I would be interested to get output of what is going wrong for you and what your build system is. There is a known bug with running the tests in RStudio because of the differen pandoc versions (we officially use 2.19.2, but RStudio is at 3.1 I think) and I really just need to suck it up and implement snapshot test versioning for pandoc.

@zkamvar
Copy link
Contributor

zkamvar commented Sep 26, 2023

@Bisaloo can you add yourself as a contributor to the DESCRIPTION?

@Bisaloo
Copy link
Contributor Author

Bisaloo commented Sep 26, 2023

Here what I get outside of RStudio:

Test results
── Failed tests ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Error (test-build_lesson.R:271:3): single files can be re-built
Error in `normalizePath(path, winslash = "/", mustWork = TRUE)`: path[1]="/tmp/RtmpPWP1ue/file155823e1dd4ae/lesson-example/site/built/second-episode.md": No such file or directory
Backtrace:
     ▆
  1. └─sandpaper:::expect_hashed(tmp, "second-episode.Rmd") at test-build_lesson.R:271:2
  2.   └─sandpaper:::get_hash(fs::path(path_built(path), md)) at tests/testthat/helper-hash.R:8:2
  3.     ├─sandpaper:::get_built_db(db, filter = "*") at sandpaper/R/utils-built-db.R:8:2
  4.     │ └─base::file.exists(db) at sandpaper/R/utils-built-db.R:19:2
  5.     ├─fs::path(path_built(path), "md5sum.txt")
  6.     └─sandpaper:::path_built(path)
  7.       ├─fs::path(path_site(inpath), "built") at sandpaper/R/utils-paths.R:48:2
  8.       └─sandpaper:::path_site(inpath)
  9.         ├─fs::path(root_path(path), "site") at sandpaper/R/utils-paths.R:39:4
 10.         └─sandpaper:::root_path(path)
 11.           └─rprojroot::find_root(criteria, path) at sandpaper/R/utils-paths.R:8:2
 12.             └─rprojroot:::get_start_path(path, criterion$subdir)
 13.               └─base::normalizePath(path, winslash = "/", mustWork = TRUE)

Error (test-build_lesson.R:328:3): Active episode contains sidebar number
Error in `file(con, "r")`: cannot open the connection
Backtrace:
    ▆
 1. └─base::readLines(fs::path(sitepath, "second-episode.html")) at test-build_lesson.R:328:2
 2.   └─base::file(con, "r")

Error (test-overview.R:90:3): Lessons without episodes can be built
Error: Incorrect pandoc version
Backtrace:
    ▆
 1. └─sandpaper::build_lesson(lsn, quiet = TRUE, preview = FALSE) at test-overview.R:90:2
 2.   └─sandpaper:::check_pandoc() at sandpaper/R/build_lesson.R:67:2

Error (test-overview.R:164:3): top level fig, files, and data directories are copied over
Error: Incorrect pandoc version
Backtrace:
    ▆
 1. └─sandpaper::build_lesson(lsn, quiet = TRUE, preview = FALSE) at test-overview.R:164:2
 2.   └─sandpaper:::check_pandoc() at sandpaper/R/build_lesson.R:67:2

Error (test-utils-built-db.R:114:3): get_child_files() will return a list of files that have child documents in lessons
<ENOENT/fs_error/error/condition>
Error: [ENOENT] Failed to copy 'examples/figures.md' to '/tmp/RtmpPWP1ue/file155823e1dd4ae/lesson-example/episodes/files/figures.md': no such file or directory
Backtrace:
    ▆
 1. └─sandpaper:::setup_child_test(res) at test-utils-built-db.R:114:2
 2.   └─fs::file_copy(test_path("examples", "figures.md"), child) at tests/testthat/helper-child.R:9:2

Error (test-utils-built-db.R:129:3): build_status() takes into account child document modifications
<EEXIST/fs_error/error/condition>
Error: [EEXIST] Failed to copy 'examples/child-haver.Rmd' to '/tmp/RtmpPWP1ue/file155823e1dd4ae/lesson-example/episodes/child-haver.Rmd': file already exists
Backtrace:
    ▆
 1. └─sandpaper:::setup_child_test(res) at test-utils-built-db.R:129:2
 2.   └─fs::file_copy(test_path("examples", "child-haver.Rmd"), parent) at tests/testthat/helper-child.R:8:2

[ FAIL 6 | WARN 10 | SKIP 55 | PASS 770 ]

Session info
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.1 (2023-06-16)
 os       Ubuntu 22.04.3 LTS
 system   x86_64, linux-gnu
 ui       X11
 language en_US
 collate  en_GB.UTF-8
 ctype    en_GB.UTF-8
 tz       Europe/Paris
 date     2023-09-26
 pandoc   2.9.2.1 @ /bin/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version    date (UTC) lib source
   askpass       1.2.0      2023-09-03 [1] RSPM (R 4.3.1)
   assertthat    0.2.1      2019-03-21 [1] RSPM (R 4.3.0)
   brio          1.1.3      2021-11-30 [1] RSPM
   bslib         0.5.1      2023-08-11 [1] RSPM (R 4.3.1)
   cachem        1.0.8      2023-05-01 [1] RSPM (R 4.3.0)
   callr         3.7.3      2022-11-02 [1] RSPM
   cli           3.6.1      2023-03-23 [1] RSPM
   commonmark    1.9.0      2023-03-17 [1] RSPM (R 4.3.0)
   covr          3.6.2      2023-03-25 [1] RSPM
   crayon        1.5.2      2022-09-29 [1] RSPM
   credentials   2.0.1      2023-09-06 [1] RSPM (R 4.3.1)
   curl          5.0.2      2023-08-14 [1] RSPM (R 4.3.1)
   desc          1.4.2      2022-09-08 [1] RSPM
   devtools      2.4.5      2022-10-11 [1] RSPM
   diffobj       0.3.5      2021-10-05 [1] RSPM
   digest        0.6.33     2023-07-07 [1] CRAN (R 4.3.1)
   downlit       0.4.3      2023-06-29 [1] RSPM (R 4.3.0)
   dplyr         1.1.3      2023-09-03 [1] RSPM (R 4.3.1)
   ellipsis      0.3.2      2021-04-29 [1] RSPM
   evaluate      0.21       2023-05-05 [1] RSPM (R 4.3.0)
   fansi         1.0.4      2023-01-22 [1] RSPM
   fastmap       1.1.1      2023-02-24 [1] RSPM
   fs            1.6.3      2023-07-20 [1] RSPM (R 4.3.1)
   generics      0.1.3      2022-07-05 [1] RSPM
   gert          1.9.3      2023-08-07 [1] RSPM (R 4.3.1)
   gh            1.4.0      2023-02-22 [1] RSPM
   gitcreds      0.1.2      2022-09-08 [1] RSPM
   glue          1.6.2      2022-02-24 [1] RSPM
   htmltools     0.5.6      2023-08-10 [1] RSPM (R 4.3.1)
   htmlwidgets   1.6.2      2023-03-17 [1] RSPM
   httpuv        1.6.11     2023-05-11 [1] RSPM (R 4.3.0)
   httr2         0.2.3      2023-05-08 [1] RSPM (R 4.3.0)
   jquerylib     0.1.4      2021-04-26 [1] RSPM
   jsonlite      1.8.7      2023-06-29 [1] RSPM (R 4.3.0)
   knitr         1.44.1     2023-09-22 [1] Github (yihui/knitr@42f6b3a)
   later         1.3.1      2023-05-02 [1] RSPM (R 4.3.0)
   lazyeval      0.2.2      2019-03-15 [1] RSPM
   lifecycle     1.0.3      2022-10-07 [1] RSPM
   magrittr      2.0.3      2022-03-30 [1] RSPM
   memoise       2.0.1      2021-11-26 [1] RSPM
   mime          0.12       2021-09-28 [1] RSPM
   miniUI        0.1.1.1    2018-05-18 [1] RSPM
   mockr         0.2.1      2023-02-01 [1] RSPM (R 4.3.1)
   openssl       2.1.0      2023-07-15 [1] RSPM (R 4.3.1)
   pegboard      0.6.1      2023-09-26 [1] Github (carpentries/pegboard@06b4151)
   pillar        1.9.0      2023-03-22 [1] RSPM
   pkgbuild      1.4.2      2023-06-26 [1] RSPM (R 4.3.0)
   pkgconfig     2.0.3      2019-09-22 [1] RSPM
   pkgdown       2.0.7      2022-12-14 [1] RSPM
   pkgload       1.3.2.1    2023-07-08 [1] RSPM (R 4.3.1)
   prettyunits   1.1.1      2020-01-24 [1] RSPM
   processx      3.8.2      2023-06-30 [1] RSPM (R 4.3.0)
   profvis       0.3.8      2023-05-02 [1] RSPM (R 4.3.0)
   promises      1.2.1      2023-08-10 [1] RSPM (R 4.3.1)
   ps            1.7.5      2023-04-18 [1] RSPM
   purrr         1.0.2.9000 2023-09-15 [1] Github (tidyverse/purrr@ac4f5a9)
   R6            2.5.1      2021-08-19 [1] RSPM
   rappdirs      0.3.3      2021-01-31 [1] RSPM
   Rcpp          1.0.11     2023-07-06 [1] RSPM (R 4.3.1)
   rematch2      2.1.2      2020-05-01 [1] RSPM
   remotes       2.4.2.1    2023-07-18 [1] RSPM (R 4.3.1)
   renv          1.0.0      2023-07-07 [1] RSPM (R 4.3.0)
   rex           1.2.1      2021-11-26 [1] RSPM
   rlang         1.1.1      2023-04-28 [1] RSPM (R 4.3.0)
   rmarkdown     2.25       2023-09-18 [1] CRAN (R 4.3.1)
   rprojroot     2.0.3      2022-04-02 [1] RSPM
   rstudioapi    0.15.0     2023-07-07 [1] CRAN (R 4.3.1)
 P sandpaper   * 0.13.3     2023-09-26 [?] Github (Bisaloo/sandpaper@80140d7)
   sass          0.4.7      2023-07-15 [1] CRAN (R 4.3.1)
   servr         0.27       2023-05-02 [1] RSPM (R 4.3.0)
   sessioninfo   1.2.2      2021-12-06 [1] RSPM
   shiny         1.7.5      2023-08-12 [1] RSPM (R 4.3.1)
   stringi       1.7.12     2023-01-11 [1] CRAN (R 4.3.0)
   stringr       1.5.0      2022-12-02 [1] RSPM
   sys           3.4.2      2023-05-23 [1] RSPM (R 4.3.0)
   testthat    * 3.1.10     2023-07-06 [1] RSPM (R 4.3.1)
   tibble        3.2.1      2023-03-20 [1] RSPM
   tidyselect    1.2.0      2022-10-10 [1] RSPM
   tinkr         0.2.0      2023-07-04 [1] https://carpentries.r-universe.dev (R 4.3.0)
   urlchecker    1.0.1      2021-11-30 [1] RSPM
   usethis       2.2.2.9000 2023-09-15 [1] Github (r-lib/usethis@467ff57)
   utf8          1.2.3      2023-01-31 [1] RSPM
   varnish       0.2.17     2023-07-04 [1] https://carpentries.r-universe.dev (R 4.3.0)
   vctrs         0.6.3      2023-06-14 [1] RSPM (R 4.3.0)
   waldo         0.5.1      2023-05-08 [1] RSPM (R 4.3.0)
   whisker       0.4.1      2022-12-05 [1] RSPM
   withr         2.5.0      2022-03-03 [1] RSPM
   xfun          0.40       2023-08-09 [1] RSPM (R 4.3.1)
   xml2          1.3.5      2023-07-06 [1] CRAN (R 4.3.0)
   xslt          1.4.4      2023-02-21 [1] RSPM
   xtable        1.8-4      2019-04-21 [1] RSPM
   yaml          2.3.7      2023-01-23 [1] RSPM (R 4.3.0)

 [1] /home/hugo/.local/share/R/x86_64-pc-linux-gnu-library/4.3
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

 P ── Loaded and on-disk path mismatch.

The warnings are due to more partial matching in pegboard. I can submit a follow up PR there.

Not sure about the errors regarding missing files. I will investigate but posting in case you immediately understand what the issue is.

@Bisaloo
Copy link
Contributor Author

Bisaloo commented Sep 26, 2023

The strangest part is that tests pass when I run test files individually 😮‍💨

@zkamvar zkamvar merged commit 6019cb7 into carpentries:main Sep 26, 2023
12 checks passed
@zkamvar
Copy link
Contributor

zkamvar commented Sep 26, 2023

Thank you for these fixes, @Bisaloo!

For context, this is the reason a lot of the tests were skipped. We built on pandoc 2.11.4

 pandoc   2.9.2.1 @ /bin/ (via rmarkdown)

I suspect that the other tests fail because I have not properly protected them from the absence of the correct pandoc (so they check files that were not created). This interdependence of tests is something I am slowly working on rectifying.

In the meantime, you can use the {pandoc} package to provision the correct version of pandoc:

pandoc::pandoc_activate("2.19.2")

and then I have this in my .bashrc:

# SET PANDOC VERSION
if [ -d "${HOME}/.local/share/r-pandoc/2.19.2" ]; then
    export PATH="${HOME}/.local/share/r-pandoc/2.19.2:${PATH}"
fi

@Bisaloo
Copy link
Contributor Author

Bisaloo commented Sep 26, 2023

For the test interdependence, you might find this PR in lintr useful: r-lib/lintr#1938. Not completely sure if it's overkill in your case but sharing anyway so you can evaluate.

@Bisaloo Bisaloo deleted the partial-matching branch September 26, 2023 18:38
@zkamvar
Copy link
Contributor

zkamvar commented Sep 26, 2023

Thank you! Some of the tests files will hopefully be easy to fix, but others like the tests for git helpers is probably going to be a fix that involves just merging all of the test_that() functions into one because they require on-disk manipulations ☹️

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 this pull request may close these issues.

Warning messages: In page_globals$meta : partial match of 'meta' to 'metadata'
2 participants