From d61679f4e4d192a01532b0205b65bd8b23d7ac48 Mon Sep 17 00:00:00 2001 From: "Glauss,Isabel (MED BDS) BIP-DE-B" Date: Tue, 2 Jul 2024 10:55:29 +0200 Subject: [PATCH] update QC report to latest template files --- inst/validation/run_validation.R | 44 ++++++ inst/validation/utils-validation.R | 87 ++++++------ inst/validation/val_report.Rmd | 1 + inst/validation/val_report_child.Rmd | 162 +++++++++------------- tests/testthat.R | 5 +- tests/testthat/_snaps/04-generate_plot.md | 2 +- tests/testthat/_snaps/05-mod_edish.md | 4 +- tests/testthat/setup.R | 16 ++- 8 files changed, 171 insertions(+), 150 deletions(-) create mode 100644 inst/validation/run_validation.R diff --git a/inst/validation/run_validation.R b/inst/validation/run_validation.R new file mode 100644 index 0000000..465c65c --- /dev/null +++ b/inst/validation/run_validation.R @@ -0,0 +1,44 @@ +pkg_name <- read.dcf("DESCRIPTION")[, "Package"] +pkg_version <- read.dcf("DESCRIPTION")[, "Version"] +test_results <- tibble::as_tibble(devtools::test()) + +local({ + # This is evaluated inside a local because, otherwise, all the variables created in the chunks of the rendered + # document leak into the environment + + validation_root <- "./inst/validation" + validation_report_rmd <- file.path(validation_root, "val_report.Rmd") + validation_report_html <- "val_report.html" + validation_results <- file.path(validation_root, "results") + val_param_rds <- file.path(validation_results, "val_param.rds") + + stopifnot(dir.exists(validation_root)) + stopifnot(file.exists(validation_report_rmd)) + + stopifnot(dir.exists(validation_results)) + unlink(list.files(validation_results)) + + saveRDS( + list( + package = pkg_name, + tests = test_results, + version = pkg_version + ), + val_param_rds + ) + + rmarkdown::render( + input = validation_report_rmd, + params = list( + package = pkg_name, + tests = test_results, + version = pkg_version + ), + output_dir = validation_results, + output_file = validation_report_html + ) + + # We use one of the leaked variables, created inside the validation report to asses if the validation is + # succesful or not + VALIDATION_PASSED +}) diff --git a/inst/validation/utils-validation.R b/inst/validation/utils-validation.R index 27fa6be..c2b58f2 100644 --- a/inst/validation/utils-validation.R +++ b/inst/validation/utils-validation.R @@ -1,32 +1,18 @@ #' Setting up the validation -#' -#' 1. Add package_name -#' 2. Copy that variable and the contents of if block to tests/testthat/setup.R -#' (If you are using the template this may already be in place for you) - -package_name <- "dv.edish" -if (FALSE) { - # validation (S) - vdoc <- source( - system.file("validation", "utils-validation.R", package = package_name, mustWork = TRUE), - local = TRUE - )[["value"]] - specs <- vdoc[["specs"]] - # validation (F) -} +if (!exists("package_name")) stop("package name must be in the environment when this script is sourced") -#' 2. For those tests that cover an specific spec +#' How to link tests and specs if (FALSE) { test_that( - vdoc[["add_spec"]](specs$my$hier$spec, "my test description"), + vdoc[["add_spec"]]("my test description", specs$a_spec), { expect_true(TRUE) } ) } -#' The specs variable on the call references the one declared in point 1 +#' The specs variable on the call references the one declared in specs.R #' 3. For those tests covering more than one spec. #' NOTE: It must be c() and not list() @@ -34,7 +20,7 @@ if (FALSE) { if (FALSE) { test_that( - vdoc[["add_spec"]](c(specs$my$hier$spec, vdoc_specs$my$hier$other_spec), "my test_description"), + vdoc[["add_spec"]]("my test_description", c(specs$my$hier$spec, vdoc_specs$my$hier$other_spec)), { expect_true(TRUE) } @@ -47,7 +33,11 @@ if (FALSE) { if (FALSE) { my_spec <- specs$my$hier$spec - test_that(vdoc$parse_spec(my_spec, "my test_description"), { + test_that(vdoc[["add_spec"]]("my test_description", my_spec), { + ... + }) + + test_that(vdoc[["add_spec"]]("my test_description", specs[["my"]][["hier"]][["spec"]]), { ... }) } @@ -66,7 +56,7 @@ if (FALSE) { } # Validation code - +# nolint start cyclocomp_linter local({ specs <- source( system.file("validation", "specs.R", package = package_name, mustWork = TRUE), @@ -122,27 +112,44 @@ local({ } # This should be covered by pack of constants but just in case } else { spec_id_chr <- spec_id - } - structure(desc, spec_id = spec_id_chr, spec = spec) + } + paste0(desc, "__spec_ids{", paste0(spec_id_chr, collapse = ";"), "}") }, - get_spec = function(result) { - lapply( - result, - function(x) { - first_result <- try( - x[[1]][["test"]], - silent = TRUE - ) - if (inherits(first_result, "try-error")) { - list(spec_id = NULL, desc = NULL) - } else { - list( - spec_id = attr(first_result, "spec_id", exact = TRUE), - spec = attr(first_result, "spec", exact = TRUE) - ) + get_spec = function(test, specs) { + spec_ids <- utils::strcapture( + pattern = "__spec_ids\\{(.*)\\}", + x = test, + proto = list(spec = character()) + )[["spec"]] + + spec_ids <- strsplit(spec_ids, split = ";") + + specs_and_id <- list() + + for (idx in seq_along(spec_ids)) { + ids <- spec_ids[[idx]] + if (all(!is.na(ids))) { + this_specs <- list() + for (sub_idx in seq_along(ids)) { + id <- ids[[sub_idx]] + this_specs[[sub_idx]] <- eval(str2expression(paste0("specs$", id))) } - } - ) + specs_and_id[[idx]] <- list( + spec_id = ids, + spec = this_specs + ) + } else { + specs_and_id[[idx]] <- list( + spec_id = NULL, + spec = NULL + ) + } + } + specs_and_id } + + ) }) + +# nolint end cyclocomp_linter \ No newline at end of file diff --git a/inst/validation/val_report.Rmd b/inst/validation/val_report.Rmd index dec608b..26a97e9 100644 --- a/inst/validation/val_report.Rmd +++ b/inst/validation/val_report.Rmd @@ -1,4 +1,5 @@ --- +title: "Quality Control" output: html_document: toc: true diff --git a/inst/validation/val_report_child.Rmd b/inst/validation/val_report_child.Rmd index b9972d3..bf7f1bc 100644 --- a/inst/validation/val_report_child.Rmd +++ b/inst/validation/val_report_child.Rmd @@ -14,80 +14,78 @@ ```{r setup, message = FALSE} # Import vdoc functions ---- -vdoc <- source( - system.file("validation", "utils-validation.R", package = params[["package"]], mustWork = TRUE), - local = TRUE -)[["value"]] +vdoc <- local({ + # ########## + # package_name is used # INSIDE # the sourced file below + # ########## + package_name <- params[["package"]] + utils_file_path <- system.file("validation", "utils-validation.R", package = package_name, mustWork = TRUE) + source(utils_file_path, local = TRUE)[["value"]] +}) # Set required packages ---- -suppressPackageStartupMessages(stopifnot(requireNamespace("tibble"))) suppressPackageStartupMessages(stopifnot(requireNamespace("DT"))) -suppressPackageStartupMessages(stopifnot(require(dplyr))) suppressPackageStartupMessages(stopifnot(requireNamespace("devtools"))) # Parse tests ---- -tests <- tibble::as_tibble(params[["tests"]]) %>% - # tests <- tibble::as_tibble(x) %>% - dplyr::mutate( - validation_data = vdoc[["get_spec"]](result), - spec_id = sapply(validation_data, function(x) { - x[["spec_id"]] - }), - spec = sapply(validation_data, function(x) { - x[["spec"]] - }), - spec_id_paste = vapply(spec_id, function(x) paste(x, collapse = "\n"), FUN.VALUE = character(1)), - spec_paste = vapply(spec, function(x) paste(x, collapse = "\n"), FUN.VALUE = character(1)), - desc = paste0("(#", seq_len(dplyr::n()), "): ", test), - with_spec = vapply(spec_id, Negate(is.null), FUN.VALUE = logical(1)) - ) +tests <- as.data.frame(params[["tests"]]) +tests[["validation_data"]] <- vdoc[["get_spec"]](tests[["test"]], vdoc[["specs"]]) +tests[["spec_id"]] <- sapply(tests[["validation_data"]], function(x) x[["spec_id"]]) +tests[["spec"]] <- sapply(tests[["validation_data"]], function(x) x[["spec"]]) +tests[["spec_id_paste"]] <- vapply(tests[["spec_id"]], function(x) paste(x, collapse = "\n"), FUN.VALUE = character(1)) +tests[["spec_paste"]] <- vapply(tests[["spec"]], function(x) paste(x, collapse = "\n"), FUN.VALUE = character(1)) +tests[["desc"]] <- paste0("(#", seq_len(nrow(tests)), "): ", tests[["test"]]) +tests[["with_spec"]] <- vapply(tests[["spec_id"]], Negate(is.null), FUN.VALUE = logical(1)) -spec_tests <- dplyr::filter(tests, with_spec) -no_spec_tests <- dplyr::filter(tests, !with_spec) +spec_tests <- tests[tests[["with_spec"]], ] +no_spec_tests <- tests[!tests[["with_spec"]], ] declared_spec <- vdoc[["spec_id_list"]] tested_spec <- unique(unlist(tests[["spec_id"]])) uncovered_spec <- declared_spec[!declared_spec %in% tested_spec] undeclared_spec <- tested_spec[!tested_spec %in% declared_spec] -spec_tests <- dplyr::mutate( - spec_tests, - are_declared = sapply(spec_id, function(x) { - all(x %in% declared_spec) - }) -) +spec_tests[["are_declared"]] <- sapply(spec_tests[["spec_id"]], function(x) all(x %in% declared_spec)) # Count tests in the different categories ---- - -n_pass_dec <- spec_tests %>% - dplyr::filter(failed == 0, skipped == 0, are_declared) %>% - nrow() -n_fail_dec <- spec_tests %>% - tibble::as_tibble() %>% - dplyr::filter(failed > 0, are_declared) %>% - nrow() -n_skip_dec <- spec_tests %>% - tibble::as_tibble() %>% - dplyr::filter(skipped > 0, are_declared) %>% - nrow() +mask_failed <- !!spec_tests[["failed"]] | spec_tests[["error"]] +mask_skipped <- !!spec_tests[["skipped"]] +mask_declared <- spec_tests[["are_declared"]] +n_pass_dec <- sum(!mask_failed & !mask_skipped & mask_declared) +n_fail_dec <- sum(mask_failed & mask_declared) +n_skip_dec <- sum(mask_skipped & mask_declared) n_uncov <- length(uncovered_spec) -n_undec <- spec_tests %>% - dplyr::filter(!are_declared) %>% - nrow() +n_undec <- sum(!mask_declared) + +render_spec_table <- function(t) { + t <- t[trac_matrix_col] + colnames(t) <- names(trac_matrix_col) + t <- t[order(t[["Spec ID"]]), ] + DT::datatable(t, options = list(dom = "ltp"), filter = list(position = "top")) +} + +data_frame_by_row <- function(colnames, data) { + n <- length(data) + n_cols <- length(colnames) + stopifnot(n %% n_cols == 0) + columns <- vector("list", length = n_cols) + for (i in 1:n_cols) columns[[i]] <- unlist(data[seq(i, n, n_cols)]) + do.call(data.frame, setNames(columns, colnames)) +} # Select columns to be included in the tables ---- trac_matrix_col <- c("Spec ID" = "spec_id_paste", "Spec" = "spec_paste", "Test Desc" = "desc", "File" = "file") # Check that validation passes and set title ---- -VALIDATION_PASSED <- n_fail_dec == 0 && n_uncov == 0 && n_undec == 0 && n_uncov == 0 #nolint +VALIDATION_PASSED <- n_fail_dec == 0 && n_uncov == 0 && n_undec == 0 && n_uncov == 0 # nolint result_symbol <- if (VALIDATION_PASSED) "\U02705" else "\U274C" -title <- paste(result_symbol, "Quality control (QC) report for", params[["package"]], params[["version"]]) +title <- paste(result_symbol, params[["package"]], params[["version"]]) ``` ---- -title: `r title #Title is placed in here because we need the result of validation first` ---- + +## `r title` +Date: `r format(Sys.time(), "%Y-%b-%d %H:%M:%S")` The following document generates a report for R packages, to satisfy the criteria of a "Released" status under the **Non-GxP** project. The QC report contains the following information: @@ -120,19 +118,21 @@ A test can be both **failed** and **skipped**. ## Summary ```{r summary} -tibble::tribble( - ~"Spec Exists", ~Test, ~Count, ~color, - "Yes", "Pass", n_pass_dec, "white", - "Yes", "Failed", n_fail_dec, if (n_fail_dec > 0) "red" else "green", - "Yes", "Skipped", n_skip_dec, if (n_skip_dec > 0) "red" else "green", - "Yes", "No Test", n_uncov, if (n_uncov > 0) "red" else "green", - "No", "NA", n_undec, if (n_undec > 0) "red" else "green" -) %>% +data_frame_by_row( + colnames = c("Spec Exists", "Test", "Count", "color"), + data = list( + "Yes", "Pass", n_pass_dec, "white", + "Yes", "Failed", n_fail_dec, if (n_fail_dec > 0) "red" else "green", + "Yes", "Skipped", n_skip_dec, if (n_skip_dec > 0) "red" else "green", + "Yes", "No Test", n_uncov, if (n_uncov > 0) "red" else "green", + "No", "NA", n_undec, if (n_undec > 0) "red" else "green" + ) +) |> DT::datatable( rownames = FALSE, options = list(columnDefs = list(list(visible = FALSE, targets = c(3))), dom = "tp"), filter = list(position = "top") - ) %>% + ) |> DT::formatStyle( c("Count"), valueColumns = "color", @@ -143,48 +143,25 @@ tibble::tribble( ## Passed tests ```{r passed_test} -spec_tests %>% - dplyr::filter(failed == 0, skipped == 0, are_declared) %>% - dplyr::select(dplyr::all_of(trac_matrix_col)) %>% - dplyr::arrange(.data[["Spec ID"]]) %>% - DT::datatable( - options = list(dom = "ltp"), - filter = list(position = "top") - ) +render_spec_table(spec_tests[!mask_failed & !mask_skipped & mask_declared, ]) ``` ## Failed tests ```{r failed_test} -spec_tests %>% - tibble::as_tibble() %>% - dplyr::filter(failed > 0, are_declared) %>% - dplyr::select(dplyr::all_of(trac_matrix_col)) %>% - dplyr::arrange(.data[["Spec ID"]]) %>% - DT::datatable( - options = list(dom = "ltp"), - filter = list(position = "top") - ) +render_spec_table(spec_tests[mask_failed & mask_declared, ]) ``` ## Skipped tests ```{r skipped_test} -spec_tests %>% - tibble::as_tibble() %>% - dplyr::filter(skipped > 0, are_declared) %>% - dplyr::select(dplyr::all_of(trac_matrix_col)) %>% - dplyr::arrange(.data[["Spec ID"]]) %>% - DT::datatable( - options = list(dom = "ltp"), - filter = list(position = "top") - ) +render_spec_table(spec_tests[mask_skipped & mask_declared, ]) ``` ## Uncovered specifications ```{r uncovered_spec, echo=FALSE} -tibble::tibble("Uncovered Specifications" = uncovered_spec) %>% +data.frame("Uncovered Specifications" = uncovered_spec) |> DT::datatable( options = list(dom = "ltp"), filter = list(position = "top") @@ -196,14 +173,7 @@ tibble::tibble("Uncovered Specifications" = uncovered_spec) %>% This should always be empty, as non existant specs are controlled during test execution. ```{r undeclared_spec, echo=FALSE, results = "asis"} -spec_tests %>% - dplyr::filter(!are_declared) %>% - dplyr::select(dplyr::all_of(trac_matrix_col)) %>% - dplyr::arrange(.data[["Spec ID"]]) %>% - DT::datatable( - options = list(dom = "ltp"), - filter = list(position = "top") - ) +render_spec_table(spec_tests[!mask_declared, ]) ``` # Session Info and System Configuration @@ -224,10 +194,10 @@ j <- vapply( ) }, FUN.VALUE = character(1) -) %>% - gsub("\n", "
", x = ., fixed = TRUE) +) |> + gsub("\n", "
", x = _, fixed = TRUE) -tibble::tibble(spec_id = names(j), spec = j) %>% +data.frame(spec_id = names(j), spec = j) |> DT::datatable( rownames = FALSE, options = list( diff --git a/tests/testthat.R b/tests/testthat.R index 0d4a740..606cdf9 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,6 +1,3 @@ pkg_name <- "dv.edish" - -library(testthat) library(pkg_name, character.only = TRUE) - -test_check(pkg_name) +testthat::test_check(pkg_name) diff --git a/tests/testthat/_snaps/04-generate_plot.md b/tests/testthat/_snaps/04-generate_plot.md index 67e6d77..75ed76c 100644 --- a/tests/testthat/_snaps/04-generate_plot.md +++ b/tests/testthat/_snaps/04-generate_plot.md @@ -1,4 +1,4 @@ -# the resulting plot object includes the correct hovertext (snapshot test) +# the resulting plot object includes the correct hovertext (snapshot test)__spec_ids{plot_specs$hovering} Code actual diff --git a/tests/testthat/_snaps/05-mod_edish.md b/tests/testthat/_snaps/05-mod_edish.md index 9b691b9..1661212 100644 --- a/tests/testthat/_snaps/05-mod_edish.md +++ b/tests/testthat/_snaps/05-mod_edish.md @@ -1,4 +1,4 @@ -# the app displays the correct plot at app launch (snapshot test) +# the app displays the correct plot at app launch (snapshot test)__spec_ids{plot_specs$data} Code app$get_values(input = TRUE, output = TRUE) @@ -126,7 +126,7 @@ $output$`edish-plot` - {"x":{"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"xaxis":{"domain":[0,1],"automargin":true,"title":"test 1/ULN"},"yaxis":{"domain":[0,1],"automargin":true,"title":"test 2/ULN"},"shapes":[{"type":"line","y0":0,"y1":1,"yref":"paper","x0":3,"x1":3,"line":{"color":"gray","dash":"dot"}},{"type":"line","x0":0,"x1":1,"xref":"paper","y0":2,"y1":2,"line":{"color":"gray","dash":"dot"}}],"hovermode":"closest","showlegend":true},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"mode":"markers","type":"scatter","name":"arm1","marker":{"color":"rgba(252,141,98,1)","line":{"color":"rgba(252,141,98,1)"}},"textfont":{"color":"rgba(252,141,98,1)"},"error_y":{"color":"rgba(252,141,98,1)"},"error_x":{"color":"rgba(252,141,98,1)"},"line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null},{"mode":"markers","type":"scatter","x":[0.34734910411925335,0.54197535764588034,0.29432554882307305],"y":[0.74028746015250968,0.82460470462819024,0.03048746625449824],"hovertext":["Subject: 01
Arm: arm1
Visit: visit 1
x-axis: 0.347
y-axis: 0.74","Subject: 01
Arm: arm1
Visit: visit 2
x-axis: 0.542
y-axis: 0.825","Subject: 01
Arm: arm1
Visit: visit 3
x-axis: 0.294
y-axis: 0.03"],"hoverinfo":["text","text","text"],"name":"arm1","marker":{"color":"rgba(252,141,98,1)","line":{"color":"rgba(252,141,98,1)"}},"textfont":{"color":"rgba(252,141,98,1)"},"error_y":{"color":"rgba(252,141,98,1)"},"error_x":{"color":"rgba(252,141,98,1)"},"line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[],"deps":[{"name":"setprototypeof","version":"0.1","src":{"href":"setprototypeof-0.1"},"meta":null,"script":"setprototypeof.js","stylesheet":null,"head":null,"attachment":null,"all_files":false},{"name":"typedarray","version":"0.1","src":{"href":"typedarray-0.1"},"meta":null,"script":"typedarray.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":false},{"name":"jquery","version":"3.5.1","src":{"href":"jquery-3.5.1"},"meta":null,"script":"jquery.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":true},{"name":"crosstalk","version":"1.2.1","src":{"href":"crosstalk-1.2.1"},"meta":null,"script":"js/crosstalk.min.js","stylesheet":"css/crosstalk.min.css","head":null,"attachment":null,"all_files":true},{"name":"plotly-htmlwidgets-css","version":"2.11.1","src":{"href":"plotly-htmlwidgets-css-2.11.1"},"meta":null,"script":null,"stylesheet":"plotly-htmlwidgets.css","head":null,"attachment":null,"all_files":false},{"name":"plotly-main","version":"2.11.1","src":{"href":"plotly-main-2.11.1"},"meta":null,"script":"plotly-latest.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":false}]} + {"x":{"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"xaxis":{"domain":[0,1],"automargin":true,"title":"test 1/ULN"},"yaxis":{"domain":[0,1],"automargin":true,"title":"test 2/ULN"},"shapes":[{"type":"line","y0":0,"y1":1,"yref":"paper","x0":3,"x1":3,"line":{"color":"gray","dash":"dot"}},{"type":"line","x0":0,"x1":1,"xref":"paper","y0":2,"y1":2,"line":{"color":"gray","dash":"dot"}}],"hovermode":"closest","showlegend":true},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"mode":"markers","type":"scatter","name":"arm1","marker":{"color":"rgba(252,141,98,1)","line":{"color":"rgba(252,141,98,1)"}},"textfont":{"color":"rgba(252,141,98,1)"},"error_y":{"color":"rgba(252,141,98,1)"},"error_x":{"color":"rgba(252,141,98,1)"},"line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null},{"mode":"markers","type":"scatter","x":[0.34734910411925335,0.54197535764588034,0.29432554882307305],"y":[0.74028746015250968,0.82460470462819024,0.03048746625449824],"hovertext":["Subject: 01
Arm: arm1
Visit: visit 1
x-axis: 0.347
y-axis: 0.74","Subject: 01
Arm: arm1
Visit: visit 2
x-axis: 0.542
y-axis: 0.825","Subject: 01
Arm: arm1
Visit: visit 3
x-axis: 0.294
y-axis: 0.03"],"hoverinfo":["text","text","text"],"name":"arm1","marker":{"color":"rgba(252,141,98,1)","line":{"color":"rgba(252,141,98,1)"}},"textfont":{"color":"rgba(252,141,98,1)"},"error_y":{"color":"rgba(252,141,98,1)"},"error_x":{"color":"rgba(252,141,98,1)"},"line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[],"deps":[{"name":"setprototypeof","version":"0.1","src":{"href":"setprototypeof-0.1"},"meta":null,"script":"setprototypeof.js","stylesheet":null,"head":null,"attachment":null,"all_files":false},{"name":"typedarray","version":"0.1","src":{"href":"typedarray-0.1"},"meta":null,"script":"typedarray.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":false},{"name":"jquery","version":"3.5.1","src":{"href":"jquery-3.5.1"},"meta":null,"script":"jquery.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":true},{"name":"crosstalk","version":"1.2.0","src":{"href":"crosstalk-1.2.0"},"meta":null,"script":"js/crosstalk.min.js","stylesheet":"css/crosstalk.min.css","head":null,"attachment":null,"all_files":true},{"name":"plotly-htmlwidgets-css","version":"2.11.1","src":{"href":"plotly-htmlwidgets-css-2.11.1"},"meta":null,"script":null,"stylesheet":"plotly-htmlwidgets.css","head":null,"attachment":null,"all_files":false},{"name":"plotly-main","version":"2.11.1","src":{"href":"plotly-main-2.11.1"},"meta":null,"script":"plotly-latest.min.js","stylesheet":null,"head":null,"attachment":null,"all_files":false}]} diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index a19cd0b..c3e3334 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,11 +1,13 @@ is_CI <- isTRUE(as.logical(Sys.getenv("CI"))) # nolint -package_name <- "dv.edish" - # validation (S) -vdoc <- source( - system.file("validation", "utils-validation.R", package = package_name, mustWork = TRUE), - local = TRUE -)[["value"]] +vdoc <- local({ + # ########## + # package_name is used # INSIDE # the sourced file below + # ########## + package_name <- read.dcf("../../DESCRIPTION")[, "Package"] + utils_file_path <- system.file("validation", "utils-validation.R", package = package_name, mustWork = TRUE) + source(utils_file_path, local = TRUE)[["value"]] +}) specs <- vdoc[["specs"]] -# validation (F) +# validation (F)