From d12e379b66dd799167e1a5ee1f640c796bc74f69 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 22 Feb 2024 13:19:50 -0800 Subject: [PATCH 01/16] package has no data --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c8d534b..c574168 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,6 @@ Description: Automate the steps necessary to create a validation ready package situations to provide documentation for validation. License: MIT + file LICENSE Encoding: UTF-8 -LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 Suggests: From 434f3e95d590cc67ef3b9b52553c21684428f664 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 22 Feb 2024 13:21:24 -0800 Subject: [PATCH 02/16] adjust dependencies for R CMD check --- DESCRIPTION | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c574168..d790fcd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,14 +47,14 @@ Suggests: bookdown, here, xml2, - rvest + rvest, + fs Imports: desc, devtools, R6, roxygen2, lubridate, - fs, rlang, yaml, whoami, @@ -68,7 +68,8 @@ Imports: knitr, kableExtra, testthat, - tidyselect + tidyselect, + rstudioapi VignetteBuilder: knitr SystemRequirements: lua From 878830613cc55cf5e3fdbd326e3fcdc8985dc0c0 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 22 Feb 2024 13:23:21 -0800 Subject: [PATCH 03/16] roxygen2 version bump and document --- DESCRIPTION | 2 +- man/val_init.Rd | 8 ++++---- man/vt_dynamic_referencer.Rd | 30 +++++++++++++++--------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d790fcd..ac4ee57 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,7 @@ Description: Automate the steps necessary to create a validation ready package License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.1 Suggests: covr, XML, diff --git a/man/val_init.Rd b/man/val_init.Rd index b3422fe..6c113c4 100644 --- a/man/val_init.Rd +++ b/man/val_init.Rd @@ -35,10 +35,10 @@ vt_create_packet( \item{fields}{A named list of fields to add to \code{DESCRIPTION}, potentially overriding default values. See \code{\link[usethis:use_description]{use_description()}} for how you can set -personalized defaults using package options} +personalized defaults using package options.} \item{rstudio}{If \code{TRUE}, calls \code{\link[usethis:use_rstudio]{use_rstudio()}} to make the new package or -project into an \href{https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects}{RStudio Project}. +project into an \href{https://r-pkgs.org/workflow101.html#sec-workflow101-rstudio-projects}{RStudio Project}. If \code{FALSE} and a non-package project, a sentinel \code{.here} file is placed so that the directory can be recognized as a project by the \href{https://here.r-lib.org}{here} or @@ -47,11 +47,11 @@ that the directory can be recognized as a project by the \item{roxygen}{Do you plan to use roxygen2 to document your package?} \item{check_name}{Whether to check if the name is valid for CRAN and throw an -error if not} +error if not.} \item{open}{If \code{TRUE}, \link[usethis:proj_activate]{activates} the new project: \itemize{ -\item If RStudio desktop, the package is opened in a new session. +\item If using RStudio desktop, the package is opened in a new session. \item If on RStudio server, the current RStudio project is activated. \item Otherwise, the working directory and active project is changed. }} diff --git a/man/vt_dynamic_referencer.Rd b/man/vt_dynamic_referencer.Rd index 07a1fe7..15d3192 100644 --- a/man/vt_dynamic_referencer.Rd +++ b/man/vt_dynamic_referencer.Rd @@ -74,16 +74,16 @@ ref$list_references() \section{Methods}{ \subsection{Public methods}{ \itemize{ -\item \href{#method-scrape_references}{\code{vt_dynamic_referencer$scrape_references()}} -\item \href{#method-reference_insertion}{\code{vt_dynamic_referencer$reference_insertion()}} -\item \href{#method-list_references}{\code{vt_dynamic_referencer$list_references()}} -\item \href{#method-new}{\code{vt_dynamic_referencer$new()}} -\item \href{#method-clone}{\code{vt_dynamic_referencer$clone()}} +\item \href{#method-vt_dynamic_referencer-scrape_references}{\code{vt_dynamic_referencer$scrape_references()}} +\item \href{#method-vt_dynamic_referencer-reference_insertion}{\code{vt_dynamic_referencer$reference_insertion()}} +\item \href{#method-vt_dynamic_referencer-list_references}{\code{vt_dynamic_referencer$list_references()}} +\item \href{#method-vt_dynamic_referencer-new}{\code{vt_dynamic_referencer$new()}} +\item \href{#method-vt_dynamic_referencer-clone}{\code{vt_dynamic_referencer$clone()}} } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-scrape_references}{}}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-vt_dynamic_referencer-scrape_references}{}}} \subsection{Method \code{scrape_references()}}{ collect references from text. \subsection{Usage}{ @@ -113,8 +113,8 @@ ref$list_references() } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-reference_insertion}{}}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-vt_dynamic_referencer-reference_insertion}{}}} \subsection{Method \code{reference_insertion()}}{ replace references in text with values \subsection{Usage}{ @@ -142,8 +142,8 @@ ref$reference_insertion("This is my ##new_reference") } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-list_references}{}}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-vt_dynamic_referencer-list_references}{}}} \subsection{Method \code{list_references()}}{ list references available and their value \subsection{Usage}{ @@ -163,8 +163,8 @@ ref$list_references() } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-new}{}}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-vt_dynamic_referencer-new}{}}} \subsection{Method \code{new()}}{ create a new dynamic reference object \subsection{Usage}{ @@ -188,8 +188,8 @@ a new \code{vt_dynamic_reference} object } } \if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-clone}{}}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-vt_dynamic_referencer-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ From 880f38f0a31949b92aa5e814839b23f0c0bb6cdb Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 22 Feb 2024 13:45:28 -0800 Subject: [PATCH 04/16] test fix, create package first in tempdir --- tests/testthat/test-add_file.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-add_file.R b/tests/testthat/test-add_file.R index c1d6bc1..dd22522 100644 --- a/tests/testthat/test-add_file.R +++ b/tests/testthat/test-add_file.R @@ -1,8 +1,14 @@ test_that("validation file path finds files within the validation infrastructure, throws error otherwise", { withr::with_tempdir({ - vt_use_validation() - vt_use_req("example_req.md",username = "sample") + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) + vt_use_req("example_req.md", username = "sample", open = FALSE) fp <- validation_file_path( file = "example_req.md", From 7aa5e4fd8f3d2b3a2758feecdf2aa64c84130aba Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Thu, 22 Feb 2024 15:55:55 -0800 Subject: [PATCH 05/16] fix tests to run non-interactively --- tests/testthat/test-change_log_handlers.R | 55 ++++++++++++++++------- tests/testthat/test-child_files.R | 39 +++++++++++++--- 2 files changed, 71 insertions(+), 23 deletions(-) diff --git a/tests/testthat/test-change_log_handlers.R b/tests/testthat/test-change_log_handlers.R index 1dd5205..1fb7ac5 100644 --- a/tests/testthat/test-change_log_handlers.R +++ b/tests/testthat/test-change_log_handlers.R @@ -1,10 +1,14 @@ test_that("create change log from template", { withr::with_tempdir({ - captured_output <- capture.output(vt_create_package("myTestPkg", open = FALSE)) - setwd("myTestPkg") - - vt_use_change_log(date = "2021-01-01") + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) + vt_use_change_log(date = "2021-01-01", open = FALSE) expect_true(file.exists("vignettes/validation/change_log.md")) expect_equal(readLines("vignettes/validation/change_log.md")[1], @@ -13,9 +17,14 @@ test_that("create change log from template", { }) withr::with_tempdir({ - captured_output <- capture.output(vt_create_package("myTestPkg", open = FALSE)) - setwd("myTestPkg") - vt_use_change_log() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) + vt_use_change_log(open = FALSE) expect_true(file.exists("vignettes/validation/change_log.md")) expect_equal(readLines("vignettes/validation/change_log.md")[1], paste("# 0.0.0.9000",format(Sys.Date(), "%Y-%m-%d"))) @@ -27,10 +36,15 @@ test_that("change log not in a package", { withr::with_tempdir({ - file.create(".here") - vt_use_validation() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) - vt_use_change_log(date = "2021-01-01", version = "0.0.0.9000") + vt_use_change_log(date = "2021-01-01", version = "0.0.0.9000", open = FALSE) expect_equal( vt_scrape_change_log(), @@ -43,10 +57,14 @@ test_that("change log not in a package", { withr::with_tempdir({ - file.create(".here") - vt_use_validation() - - vt_use_change_log() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) + vt_use_change_log(open = FALSE, version = "1.0") expect_equal( vt_scrape_change_log(), data.frame(version = "1.0", @@ -62,8 +80,13 @@ test_that("Throw informative error when change log does not exist", { withr::with_tempdir({ - file.create(".here") - vt_use_validation() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) expect_error( vt_scrape_change_log(), diff --git a/tests/testthat/test-child_files.R b/tests/testthat/test-child_files.R index 9f5cc91..95e5c2c 100644 --- a/tests/testthat/test-child_files.R +++ b/tests/testthat/test-child_files.R @@ -1,6 +1,12 @@ test_that("child files in pkg", { withr::with_tempdir({ - capture_output <- capture.output({vt_create_package(open = FALSE)}) + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) vt_use_req("req1", username = "a user", open = FALSE) vt_use_test_case("testcase1", username = "a user", open = FALSE) @@ -42,7 +48,13 @@ test_that("child files in pkg", { test_that("child files outside pkg", { withr::with_tempdir({ - vt_use_validation() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) vt_use_test_code("testcode1", username = "another user", open = FALSE) @@ -63,7 +75,13 @@ test_that("child files outside pkg", { test_that("incomplete set", { withr::with_tempdir({ - vt_use_validation() + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_test_case("testcase2", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) @@ -87,7 +105,13 @@ test_that("incomplete set", { test_that("compatibility between vt_get_child_files and vt_files", { withr::with_tempdir({ - captured_output <- capture.output({vt_create_package(open = FALSE)}) + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_test_case("testcase2", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) @@ -97,11 +121,12 @@ test_that("compatibility between vt_get_child_files and vt_files", { setwd(file.path("vignettes", "validation")) knitr::opts_knit$set("output.dir"= ".") + rmd_asis <- capture.output({vt_file(child_files)}) - testthat::expect_equal(rmd_asis[9], - "+ Setup: DOCUMENT ANY SETUP THAT NEEDS TO BE DONE FOR TESTING") + testthat::expect_in("+ Setup: DOCUMENT ANY SETUP THAT NEEDS TO BE DONE FOR TESTING", + rmd_asis) - suppressWarnings(testthat::expect_error(vt_file(basename(child_files)))) + testthat::expect_error(suppressWarnings(vt_file(basename(child_files)))) }) }) From 38570d3720a5b900d6cad7a2e4e34e372dd53a79 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 08:38:30 -0800 Subject: [PATCH 06/16] fix more tests, use helper fn --- tests/testthat/helper.R | 10 ++++++ tests/testthat/test-add_file.R | 8 +---- tests/testthat/test-change_log_handlers.R | 40 +++-------------------- tests/testthat/test-child_files.R | 32 +++--------------- tests/testthat/test-create_item.R | 2 +- 5 files changed, 21 insertions(+), 71 deletions(-) create mode 100644 tests/testthat/helper.R diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R new file mode 100644 index 0000000..a57221e --- /dev/null +++ b/tests/testthat/helper.R @@ -0,0 +1,10 @@ +#' Create vt test package silently and non-interactively +make_vt_test_package <- function(){ + withr::with_options( + list( + usethis.quiet = TRUE + ), + { + vt_create_package(rstudio = FALSE, open = FALSE) + }) +} diff --git a/tests/testthat/test-add_file.R b/tests/testthat/test-add_file.R index dd22522..01e437f 100644 --- a/tests/testthat/test-add_file.R +++ b/tests/testthat/test-add_file.R @@ -1,13 +1,7 @@ test_that("validation file path finds files within the validation infrastructure, throws error otherwise", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_req("example_req.md", username = "sample", open = FALSE) fp <- validation_file_path( diff --git a/tests/testthat/test-change_log_handlers.R b/tests/testthat/test-change_log_handlers.R index 1fb7ac5..c60bf83 100644 --- a/tests/testthat/test-change_log_handlers.R +++ b/tests/testthat/test-change_log_handlers.R @@ -1,13 +1,7 @@ test_that("create change log from template", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_change_log(date = "2021-01-01", open = FALSE) expect_true(file.exists("vignettes/validation/change_log.md")) @@ -17,13 +11,7 @@ test_that("create change log from template", { }) withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_change_log(open = FALSE) expect_true(file.exists("vignettes/validation/change_log.md")) expect_equal(readLines("vignettes/validation/change_log.md")[1], @@ -36,13 +24,7 @@ test_that("change log not in a package", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_change_log(date = "2021-01-01", version = "0.0.0.9000", open = FALSE) @@ -57,13 +39,7 @@ test_that("change log not in a package", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_change_log(open = FALSE, version = "1.0") expect_equal( vt_scrape_change_log(), @@ -80,13 +56,7 @@ test_that("Throw informative error when change log does not exist", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() expect_error( vt_scrape_change_log(), diff --git a/tests/testthat/test-child_files.R b/tests/testthat/test-child_files.R index 95e5c2c..dcdfa78 100644 --- a/tests/testthat/test-child_files.R +++ b/tests/testthat/test-child_files.R @@ -1,12 +1,6 @@ test_that("child files in pkg", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_req("req1", username = "a user", open = FALSE) vt_use_test_case("testcase1", username = "a user", open = FALSE) @@ -48,13 +42,7 @@ test_that("child files in pkg", { test_that("child files outside pkg", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) vt_use_test_code("testcode1", username = "another user", open = FALSE) @@ -75,13 +63,7 @@ test_that("child files outside pkg", { test_that("incomplete set", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_test_case("testcase2", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) @@ -105,13 +87,7 @@ test_that("incomplete set", { test_that("compatibility between vt_get_child_files and vt_files", { withr::with_tempdir({ - withr::with_options( - list( - usethis.quiet = TRUE - ), - { - vt_create_package(rstudio = FALSE, open = FALSE) - }) + make_vt_test_package() vt_use_test_case("testcase1", username = "a user", open = FALSE) vt_use_test_case("testcase2", username = "a user", open = FALSE) vt_use_req("req1", username = "a user", open = FALSE) diff --git a/tests/testthat/test-create_item.R b/tests/testthat/test-create_item.R index 6e3121e..4f59540 100644 --- a/tests/testthat/test-create_item.R +++ b/tests/testthat/test-create_item.R @@ -68,7 +68,7 @@ test_that("vt_use_ family works nicely with simple item creation", { withr::with_tempdir({ # set up validation infrastructure - vt_use_validation() + make_vt_test_package() ## create items spec_path <- create_item( From b22bd2320aee7b22ed88644a727aa8d4b8743f94 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 08:46:31 -0800 Subject: [PATCH 07/16] update paths for non-interactive setup --- tests/testthat/test-create_item.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-create_item.R b/tests/testthat/test-create_item.R index 4f59540..4a54361 100644 --- a/tests/testthat/test-create_item.R +++ b/tests/testthat/test-create_item.R @@ -84,13 +84,13 @@ test_that("vt_use_ family works nicely with simple item creation", { type = "test_code") expect_true( - file.exists("validation/requirements/new_dir/new_specification") + file.exists("vignettes/validation/requirements/new_dir/new_specification") ) expect_true( - file.exists("validation/test_cases/new_dir/new_test_case") + file.exists("vignettes/validation/test_cases/new_dir/new_test_case") ) expect_true( - file.exists("validation/test_code/new_dir/new_test_code") + file.exists("vignettes/validation/test_code/new_dir/new_test_code") ) }) From 381a7610295fb8edda8e6d4bdc4acbba56dd5ddb Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 15:10:12 -0800 Subject: [PATCH 08/16] fix pesky kable test failure --- tests/testthat/test-evaluate_test_code.R | 28 ++++++++++-------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-evaluate_test_code.R b/tests/testthat/test-evaluate_test_code.R index b579e96..7f6e9fd 100644 --- a/tests/testthat/test-evaluate_test_code.R +++ b/tests/testthat/test-evaluate_test_code.R @@ -375,29 +375,23 @@ test_that("vt_kable_test_code_results returns formatted kable object",{ ),position = "center"), latex_options = "hold_position") ) - output_empty <- vt_kable_test_code_results(data.frame( + output_empty_df <- data.frame( Test = character(), Results = character(), Pass_Fail = character(), stringsAsFactors = FALSE - )) - - expect_equal( - output_empty, - kable_styling( - kable_styling( - kable( - data.frame( - Test = character(), - Results = character(), - Pass_Fail = character(), - stringsAsFactors = FALSE - ), - escape = FALSE, - col.names = c("Test", "Results", "Pass/Fail") - ),position = "center"), latex_options = "hold_position") ) + output_empty <- vt_kable_test_code_results(output_empty_df) + + output_empty2 <- + dplyr::rename(output_empty_df, `Pass/Fail` = `Pass_Fail`) %>% + kable(format = 'html') %>% + kable_styling(position = "center") %>% + kable_styling(latex_options = "hold_position") + + expect_equal(output_empty, output_empty2) + skip_on_cran() withr::with_tempfile( From 9d035bfa28fade78cb5d4a3e76504964674bc5dd Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 15:39:42 -0800 Subject: [PATCH 09/16] make more tests non-interactive and fix --- tests/testthat/test-scrape_authors.R | 198 +++++++++++++-------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/tests/testthat/test-scrape_authors.R b/tests/testthat/test-scrape_authors.R index 020b9da..33576fd 100644 --- a/tests/testthat/test-scrape_authors.R +++ b/tests/testthat/test-scrape_authors.R @@ -3,31 +3,32 @@ test_that("Scrape roxygen tags from reqs works", { withr::with_tempdir({ ## test setup - vt_use_validation( - username_list = list( - vt_user( - username = "user1", - name = "Test User", - role = "sample", - title = "Req Writer" - ), - vt_user( - username = "user2", - name = "Test User 2", - role = "sample", - title = "Req Writer" - ) - )) - - vt_use_req("req001.md",username = "Test User") - vt_use_req("req002.md",username = "Test User") - vt_use_req("req003.md",username = "Test User 2") + make_vt_test_package() + # vt_use_validation( + # username_list = list( + # vt_user( + # username = "user1", + # name = "Test User", + # role = "sample", + # title = "Req Writer" + # ), + # vt_user( + # username = "user2", + # name = "Test User 2", + # role = "sample", + # title = "Req Writer" + # ) + # )) + + vt_use_req("req001.md",username = "Test User", open = FALSE) + vt_use_req("req002.md",username = "Test User", open = FALSE) + vt_use_req("req003.md",username = "Test User 2", open = FALSE) ## scrape tag_list <- vt_scrape_tags_from( type = "requirements", tags = c("editor","editDate"), - ref = "validation") + ref = file.path("vignettes", "validation")) ## check values @@ -62,31 +63,32 @@ test_that("Scrape roxygen tags from test cases works", { withr::with_tempdir({ ## test setup - vt_use_validation( - username_list = list( - vt_user( - username = "user1", - name = "Test User", - role = "sample", - title = "Req Writer" - ), - vt_user( - username = "user2", - name = "Test User 2", - role = "sample", - title = "Req Writer" - ) - )) - - vt_use_test_case("test_case_001.md",username = "Test User") - vt_use_test_case("test_case_002.md",username = "Test User") - vt_use_test_case("test_case_003.md",username = "Test User 2") + make_vt_test_package() + # vt_use_validation( + # username_list = list( + # vt_user( + # username = "user1", + # name = "Test User", + # role = "sample", + # title = "Req Writer" + # ), + # vt_user( + # username = "user2", + # name = "Test User 2", + # role = "sample", + # title = "Req Writer" + # ) + # )) + + vt_use_test_case("test_case_001.md",username = "Test User", open = FALSE) + vt_use_test_case("test_case_002.md",username = "Test User", open = FALSE) + vt_use_test_case("test_case_003.md",username = "Test User 2", open = FALSE) ## scrape tag_list <- vt_scrape_tags_from( type = "test_cases", tags = c("editor","editDate"), - ref = "validation") + ref = file.path("vignettes", "validation")) ## check values @@ -121,51 +123,52 @@ test_that("Scrape roxygen tags from test code works", { withr::with_tempdir({ ## test setup - vt_use_validation( - username_list = list( - vt_user( - username = "user1", - name = "Test User", - role = "sample", - title = "Req Writer" - ), - vt_user( - username = "user2", - name = "Test User 2", - role = "sample", - title = "Req Writer" - ), - vt_user( - username = "user3", - name = "Test User 3", - role = "sample", - title = "Test Code Writer" - ), - vt_user( - username = "user4", - name = "Test User 4", - role = "sample", - title = "Test Code Writer" - ) - )) + make_vt_test_package() + # vt_use_validation( + # username_list = list( + # vt_user( + # username = "user1", + # name = "Test User", + # role = "sample", + # title = "Req Writer" + # ), + # vt_user( + # username = "user2", + # name = "Test User 2", + # role = "sample", + # title = "Req Writer" + # ), + # vt_user( + # username = "user3", + # name = "Test User 3", + # role = "sample", + # title = "Test Code Writer" + # ), + # vt_user( + # username = "user4", + # name = "Test User 4", + # role = "sample", + # title = "Test Code Writer" + # ) + # )) vt_use_test_code("test_code_001",username = "Test User 3") - text <- readLines("validation/test_code/test_code_001.R") - writeLines(gsub("TESTNUMBER","1.1", text),"validation/test_code/test_code_001.R") + text <- readLines("vignettes/validation/test_code/test_code_001.R") + writeLines(gsub("TESTNUMBER","1.1", text),"vignettes/validation/test_code/test_code_001.R") vt_use_test_code("test_code_002",username = "Test User 4") - text <- readLines("validation/test_code/test_code_002.R") - writeLines(gsub("TESTNUMBER","2.1", text),"validation/test_code/test_code_002.R") + text <- readLines("vignettes/validation/test_code/test_code_002.R") + writeLines(gsub("TESTNUMBER","2.1", text),"vignettes/validation/test_code/test_code_002.R") vt_use_test_code("test_code_003",username = "Test User 4") - text <- readLines("validation/test_code/test_code_003.R") - writeLines(gsub("TESTNUMBER","3.1", text),"validation/test_code/test_code_003.R") + text <- readLines("vignettes/validation/test_code/test_code_003.R") + writeLines(gsub("TESTNUMBER","3.1", text),"vignettes/validation/test_code/test_code_003.R") ## scrape tag_list <- vt_scrape_tags_from( type = "test_code", tags = c("editor","editDate"), - ref = "validation") + ref = file.path("vignettes", "validation")) ## check values expect_equal( @@ -198,13 +201,9 @@ test_that("scrape functions from external dir", { withr::with_tempdir({ - capture_output <- capture.output({ - usethis::create_package(path = "example.package" , open = FALSE,rstudio = TRUE) - }) + make_vt_test_package() - vt_use_validation() - - this_file1 <- file.path("example.package", "R/hello_world.R") + this_file1 <- file.path("R", "hello_world.R") fs::file_create(path = this_file1) cat(file = this_file1, append = FALSE,c( "#' @title Hello World!", @@ -222,7 +221,7 @@ test_that("scrape functions from external dir", { # ignores extra spaces # accommodates minor variation in date format # accommodates minor variation in formatting of last update date - this_file2 <- file.path("example.package", "R/second_func.R") + this_file2 <- file.path("R", "second_func.R") fs::file_create(path = this_file2) cat( file = this_file2, @@ -257,7 +256,7 @@ test_that("scrape functions from external dir", { # pulls function authorship from roxygen2 block, even if no function included # ignores stray comments - this_file3 <- file.path("example.package", "R/null_doc.R") + this_file3 <- file.path("R", "null_doc.R") fs::file_create(path = this_file3) cat(file = this_file3, append = FALSE,c( "#' @title Fourth_Function", @@ -286,7 +285,7 @@ test_that("scrape functions from external dir", { tag_list <- vt_scrape_tags_from( type = "functions", tags = c("editor", "editDate"), - src = "example.package", + src = ".", ref = "vignettes/validation" ) }) @@ -331,21 +330,22 @@ test_that("Scrape roxygen tags and specific tags are missing throws warnings", { withr::with_tempdir({ ## test setup - vt_use_validation( - username_list = list( - vt_user( - username = "user1", - name = "Test User", - role = "sample", - title = "Req Writer" - ), - vt_user( - username = "user2", - name = "Test User 2", - role = "sample", - title = "Req Writer" - ) - )) + make_vt_test_package() + # vt_use_validation( + # username_list = list( + # vt_user( + # username = "user1", + # name = "Test User", + # role = "sample", + # title = "Req Writer" + # ), + # vt_user( + # username = "user2", + # name = "Test User 2", + # role = "sample", + # title = "Req Writer" + # ) + # )) vt_use_test_case("test_case_001.md",username = "Test User") @@ -354,7 +354,7 @@ test_that("Scrape roxygen tags and specific tags are missing throws warnings", { tag_list <- vt_scrape_tags_from( type = "test_cases", tags = c("fake_tag"), - ref = "validation") + ref = file.path("vignettes", "validation")) }) From 397818fc876d95ce0e6978a67d53f8dbd80eb2ef Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 16:09:59 -0800 Subject: [PATCH 10/16] fix pkg name from temp pkg for test --- tests/testthat/test-validate_sequence.R | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/testthat/test-validate_sequence.R b/tests/testthat/test-validate_sequence.R index 7d30e38..def5bd5 100644 --- a/tests/testthat/test-validate_sequence.R +++ b/tests/testthat/test-validate_sequence.R @@ -3,19 +3,11 @@ test_that("test running validation.Rmd from source", { withr::with_tempdir({ ## create blank package - quiet <- capture.output({ - usethis::create_package("example.package") - }) - - setwd("example.package") - - ## make vignette and validation dir - dir.create("vignettes") - dir.create("vignettes/validation") + make_vt_test_package() ## create config file writeLines(text = c( - "package: example.package", + paste0('package: ', basename(getwd())), "working_dir: vignettes", "output_dir: inst", "report_rmd_name: validation.Rmd", @@ -54,7 +46,7 @@ test_that("test running validation.Rmd from source", { normalizePath(validation_report_output,winslash = "/"), normalizePath(file.path( getwd(), - paste0("inst/validation/Validation_Report_example.package_v0.0.0.9000_",format(Sys.Date(),"%Y%m%d.pdf"))), + paste0("inst/validation/Validation_Report_", basename(getwd()), "_v0.0.0.9000_",format(Sys.Date(),"%Y%m%d.pdf"))), winslash = "/") ) From 71d3f27ef38aafc7471aa697a77adcd4ed02cab7 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 16:21:49 -0800 Subject: [PATCH 11/16] rm dplyr dependency from edited test --- tests/testthat/test-evaluate_test_code.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-evaluate_test_code.R b/tests/testthat/test-evaluate_test_code.R index 7f6e9fd..a136a67 100644 --- a/tests/testthat/test-evaluate_test_code.R +++ b/tests/testthat/test-evaluate_test_code.R @@ -384,8 +384,9 @@ test_that("vt_kable_test_code_results returns formatted kable object",{ output_empty <- vt_kable_test_code_results(output_empty_df) - output_empty2 <- - dplyr::rename(output_empty_df, `Pass/Fail` = `Pass_Fail`) %>% + output_empty_df2 <- output_empty_df + names(output_empty_df2) <- c('Test', 'Results', 'Pass/Fail') + output_empty2 <- output_empty_df2 %>% kable(format = 'html') %>% kable_styling(position = "center") %>% kable_styling(latex_options = "hold_position") From 9e92a033fff3a2539f18e7ae50ffc1ea71222f88 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Fri, 23 Feb 2024 16:27:35 -0800 Subject: [PATCH 12/16] fix test comparison to new actual --- tests/testthat/test-validation_config.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-validation_config.R b/tests/testthat/test-validation_config.R index 4d588b0..ba1d0d7 100644 --- a/tests/testthat/test-validation_config.R +++ b/tests/testthat/test-validation_config.R @@ -110,7 +110,7 @@ test_that("Test creation of the config file without passed values in a non-inter expect_equal( add_user_message, - "User `test` added to validation config file.\n", + "User `test` added to validation config file.", ) expect_equal( @@ -137,7 +137,7 @@ test_that("Test creation of the config file without passed values in a non-inter expect_equal( add_user_message2, - "User `test2` added to validation config file.\n", + "User `test2` added to validation config file.", ) expect_equal( @@ -212,7 +212,7 @@ test_that("Test creation of the config file without passed values in a non-inter expect_equal( add_user_message, - "User `test` information updated in the validation config file.\n", + "User `test` information updated in the validation config file.", ) expect_equal( From cb5244f3e53b217c10f56e0dcb5a74a0d6b1eb4a Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Sun, 25 Feb 2024 11:48:24 -0800 Subject: [PATCH 13/16] new regex to fix scrape check --- tests/testthat/test-lua_dynamic_referencing.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-lua_dynamic_referencing.R b/tests/testthat/test-lua_dynamic_referencing.R index d8f6b3f..1a217bc 100644 --- a/tests/testthat/test-lua_dynamic_referencing.R +++ b/tests/testthat/test-lua_dynamic_referencing.R @@ -114,7 +114,7 @@ test_that("lua numbering for html", { pattern = "Later\\sreference\\sto\\s\\((\\d)\\)\\s-\\s(\\d)", replacement = "\\1"))) expect_equal(c(1, 1, 2, 2, 1, 3, 2), - as.numeric(unlist(lapply(strsplit(list_rendered, ": "), FUN = function(x){x[2]})))) + as.integer(sub(".*(\\d{1})$", "\\1", list_rendered))) }) From de9420bd0ec42dad4bd14f08e8c1625bfa7a33bf Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Sun, 25 Feb 2024 11:58:08 -0800 Subject: [PATCH 14/16] fix automated tests and paths --- tests/testthat/test-vt_file.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-vt_file.R b/tests/testthat/test-vt_file.R index ed3b559..84e47c0 100644 --- a/tests/testthat/test-vt_file.R +++ b/tests/testthat/test-vt_file.R @@ -445,7 +445,7 @@ test_that("evaluating default files works", { test_that("rendered report is as expected using vt_file", { withr::with_tempdir({ - vt_use_validation() + make_vt_test_package() vt_use_req("example_req.md",username = "sample") vt_use_test_case("example_test_case.md",username = "sample") @@ -514,7 +514,7 @@ test_that("rendered report is as expected using vt_file", { test_that("rendered report works using file.path inside vt_file", { withr::with_tempdir({ - vt_use_validation() + make_vt_test_package() vt_use_req("example_req.md",username = "sample") vt_use_test_case("example_test_case.md",username = "sample") @@ -537,15 +537,15 @@ test_that("rendered report works using file.path inside vt_file", { "---", "", "```{r rando-file, echo = FALSE, results = 'asis'}", - "vt_file(file=file.path(\"validation\",\"rando_file.Rmd\"))", + "vt_file(file=file.path(\"vignettes\",\"validation\",\"rando_file.Rmd\"))", "```", "", "```{r example-req, echo = FALSE, results = 'asis'}", - "vt_file(file=file.path(\"validation\",\"requirements\",\"example_req.md\"))", + "vt_file(file=file.path(\"vignettes\",\"validation\",\"requirements\",\"example_req.md\"))", "```", "", "```{r example-test-case, echo = FALSE, results = 'asis'}", - "vt_file(file=file.path(\"validation\",\"test_cases\",\"example_test_case.md\"))", + "vt_file(file=file.path(\"vignettes\",\"validation\",\"test_cases\",\"example_test_case.md\"))", "```" ), con = "report.Rmd" ) @@ -583,7 +583,7 @@ test_that("rendered report works using file.path inside vt_file", { test_that("rendered report works using file.path inside vt_file - vectorized", { withr::with_tempdir({ - vt_use_validation() + make_vt_test_package() vt_use_req("example_req.md",username = "sample") vt_use_test_case("example_test_case.md",username = "sample") vt_use_test_code("example_test_code.r",username = "sample") From 9825511d99577c06e58a0b8327dd901e524c2af2 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Sun, 25 Feb 2024 12:04:32 -0800 Subject: [PATCH 15/16] fix paths for test package --- tests/testthat/test-vt_path.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-vt_path.R b/tests/testthat/test-vt_path.R index ac2138c..985fbaa 100644 --- a/tests/testthat/test-vt_path.R +++ b/tests/testthat/test-vt_path.R @@ -2,11 +2,11 @@ test_that("vt_path returns expected path", { withr::with_tempdir({ ## setup - vt_use_validation() - actual_dir <- file.path(getwd(),"validation") + make_vt_test_package() + actual_dir <- file.path(getwd(), "vignettes", "validation") path_check <- vt_path() - setwd("validation/") + setwd(file.path("vignettes", "validation")) path_check2 <- vt_path() From d41254ba99a32e8c835bf376f682c26eac2c5eb7 Mon Sep 17 00:00:00 2001 From: Dave Slager Date: Sun, 25 Feb 2024 12:31:15 -0800 Subject: [PATCH 16/16] rm commented old code --- tests/testthat/test-scrape_authors.R | 72 ---------------------------- 1 file changed, 72 deletions(-) diff --git a/tests/testthat/test-scrape_authors.R b/tests/testthat/test-scrape_authors.R index 33576fd..225bbd3 100644 --- a/tests/testthat/test-scrape_authors.R +++ b/tests/testthat/test-scrape_authors.R @@ -4,21 +4,6 @@ test_that("Scrape roxygen tags from reqs works", { ## test setup make_vt_test_package() - # vt_use_validation( - # username_list = list( - # vt_user( - # username = "user1", - # name = "Test User", - # role = "sample", - # title = "Req Writer" - # ), - # vt_user( - # username = "user2", - # name = "Test User 2", - # role = "sample", - # title = "Req Writer" - # ) - # )) vt_use_req("req001.md",username = "Test User", open = FALSE) vt_use_req("req002.md",username = "Test User", open = FALSE) @@ -64,21 +49,6 @@ test_that("Scrape roxygen tags from test cases works", { ## test setup make_vt_test_package() - # vt_use_validation( - # username_list = list( - # vt_user( - # username = "user1", - # name = "Test User", - # role = "sample", - # title = "Req Writer" - # ), - # vt_user( - # username = "user2", - # name = "Test User 2", - # role = "sample", - # title = "Req Writer" - # ) - # )) vt_use_test_case("test_case_001.md",username = "Test User", open = FALSE) vt_use_test_case("test_case_002.md",username = "Test User", open = FALSE) @@ -124,33 +94,6 @@ test_that("Scrape roxygen tags from test code works", { ## test setup make_vt_test_package() - # vt_use_validation( - # username_list = list( - # vt_user( - # username = "user1", - # name = "Test User", - # role = "sample", - # title = "Req Writer" - # ), - # vt_user( - # username = "user2", - # name = "Test User 2", - # role = "sample", - # title = "Req Writer" - # ), - # vt_user( - # username = "user3", - # name = "Test User 3", - # role = "sample", - # title = "Test Code Writer" - # ), - # vt_user( - # username = "user4", - # name = "Test User 4", - # role = "sample", - # title = "Test Code Writer" - # ) - # )) vt_use_test_code("test_code_001",username = "Test User 3") text <- readLines("vignettes/validation/test_code/test_code_001.R") @@ -331,21 +274,6 @@ test_that("Scrape roxygen tags and specific tags are missing throws warnings", { ## test setup make_vt_test_package() - # vt_use_validation( - # username_list = list( - # vt_user( - # username = "user1", - # name = "Test User", - # role = "sample", - # title = "Req Writer" - # ), - # vt_user( - # username = "user2", - # name = "Test User 2", - # role = "sample", - # title = "Req Writer" - # ) - # )) vt_use_test_case("test_case_001.md",username = "Test User")