brodieG / unitizer

Easy R Unit Tests
Other
39 stars 6 forks source link

Make Sure `unitizer` works with `tools::testInstalledPackage` #248

Closed brodieG closed 3 years ago

brodieG commented 6 years ago

Seemingly having some working directory issues with early tests (@dirk).

brodieG commented 3 years ago

Here the tests work, but the vignette working directory doesn't seem to:

> install.packages('vetr_0.2.12.tar.gz', INSTALL_opts="--install-tests")
inferring 'repos = NULL' from 'pkgs'
* installing *source* package ‘vetr’ ...
** using staged installation
** libs
... snip ...
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (vetr)
> testthat::test_package('vetr')
No installed testthat tests found for vetr
> tools::testInstalledPackage('vetr')
Testing examples for package ‘vetr’
Running specific tests for package ‘vetr’
  Running ‘run.R’
Running vignettes for package ‘vetr’
  Running ‘alike.Rmd’
File styles.css not found in resource path
  Running ‘vetr.Rmd’

*** Tangle Errors ***

File vetr.Rmd:
cannot open the connection

*** Weave Errors ***

File alike.Rmd:
pandoc document conversion failed with error 99
File vetr.Rmd:
cannot open the connection
Warning messages:
1: In file(con, "r") :
  cannot open file '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/vetr/doc/./rmdhunks/trust-but-verify.Rmd': No such file or directory
2: In file(con, "r") :
  cannot open file '././rmdhunks/trust-but-verify.Rmd': No such file or directory
brodieG commented 3 years ago

Conclusion so far is that it seems that tests work fine, but that vignettes cannot be re-run once they are installed because the required support files (styles.css, rmd hunks) are not being copied over. Solution is to manually copy the supporting files to inst/doc, after which we get:

> tools::testInstalledPackage('unitizer')
Testing examples for package ‘unitizer’
Running specific tests for package ‘unitizer’
  Running ‘aunitizer.R’
  Running ‘runtt.R’
  Running ‘testpkg1.R’
Running vignettes for package ‘unitizer’
  Running ‘u0_unitizer_index.Rmd’
  Running ‘u1_intro.Rmd’
  Running ‘u2_tests.Rmd’
  Running ‘u3_interactive-env.Rmd’
  Running ‘u4_reproducible-tests.Rmd’
  Running ‘u5_miscellaneous.Rmd’