From 3392e04fcae0f9b2b757ca0b51fc0f7e5d83bcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 12 Dec 2024 11:37:09 +0100 Subject: [PATCH 1/3] Check if tibble is available --- tests/testthat/test-default_split_funs.R | 3 +++ tests/testthat/test-lyt-tabulation.R | 3 +++ tests/testthat/test-printing.R | 3 +++ tests/testthat/test-subset-access.R | 3 +++ 4 files changed, 12 insertions(+) diff --git a/tests/testthat/test-default_split_funs.R b/tests/testthat/test-default_split_funs.R index d4c31703d..bc27f3107 100644 --- a/tests/testthat/test-default_split_funs.R +++ b/tests/testthat/test-default_split_funs.R @@ -249,6 +249,9 @@ test_that("drop_and_remove_levels also works with character variables", { }) test_that("trim_levels_to_map split function works", { + skip_if_not_installed("tibble") + require(tibble, quietly = TRUE) + map <- data.frame( LBCAT = c("CHEMISTRY", "CHEMISTRY", "CHEMISTRY", "IMMUNOLOGY"), PARAMCD = c("ALT", "CRP", "CRP", "IGA"), diff --git a/tests/testthat/test-lyt-tabulation.R b/tests/testthat/test-lyt-tabulation.R index 578638e99..1ef19932f 100644 --- a/tests/testthat/test-lyt-tabulation.R +++ b/tests/testthat/test-lyt-tabulation.R @@ -237,6 +237,9 @@ test_that("labelkids parameter works", { test_that("ref_group comparisons work", { + skip_if_not_installed("tibble") + require(tibble, quietly = TRUE) + blthing <- basic_table() %>% split_cols_by("ARM", ref_group = "ARM1") %>% analyze("AGE", show_labels = "hidden") %>% diff --git a/tests/testthat/test-printing.R b/tests/testthat/test-printing.R index 74b4ca3b5..d9334087f 100644 --- a/tests/testthat/test-printing.R +++ b/tests/testthat/test-printing.R @@ -801,6 +801,9 @@ test_that("horizontal separator is propagated from table to print and export", { ## higher-level showing ncols works: test_that("showing higher-level ncols works", { + skip_if_not_installed("tibble") + require(tibble, quietly = TRUE) + mydat <- subset(ex_adsl, SEX %in% c("M", "F")) mydat$SEX2 <- factor( ifelse( diff --git a/tests/testthat/test-subset-access.R b/tests/testthat/test-subset-access.R index c56f297eb..f41a28c09 100644 --- a/tests/testthat/test-subset-access.R +++ b/tests/testthat/test-subset-access.R @@ -136,6 +136,9 @@ test_rowpaths <- function(tt, visonly = TRUE) { test_that("make_row_df, make_col_df give paths which all work", { + skip_if_not_installed("tibble") + require(tibble, quietly = TRUE) + lyt <- basic_table() %>% split_cols_by("ARM") %>% split_cols_by("SEX", ref_group = "F") %>% From 6a332da83d6be55b412cbcdf2b31d8abe20637f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Thu, 12 Dec 2024 11:38:46 +0100 Subject: [PATCH 2/3] Skip tests with testthat if not available --- tests/testthat.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/testthat.R b/tests/testthat.R index 889790f0b..b4b1f6613 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,2 +1,5 @@ -library(testthat) -test_check("rtables", reporter = "check") +if (requireNamespace("testthat", quietly = TRUE)) { + library(testthat) + library(rtables) + test_check("rtables", reporter = "check") +} From f5aa17434e345a8f15c67de3c8b9b08e98aa1f97 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:47:11 +0000 Subject: [PATCH 3/3] [skip style] [skip vbump] Restyle files --- tests/testthat/test-default_split_funs.R | 2 +- tests/testthat/test-lyt-tabulation.R | 2 +- tests/testthat/test-printing.R | 2 +- tests/testthat/test-subset-access.R | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-default_split_funs.R b/tests/testthat/test-default_split_funs.R index bc27f3107..168ba34ba 100644 --- a/tests/testthat/test-default_split_funs.R +++ b/tests/testthat/test-default_split_funs.R @@ -251,7 +251,7 @@ test_that("drop_and_remove_levels also works with character variables", { test_that("trim_levels_to_map split function works", { skip_if_not_installed("tibble") require(tibble, quietly = TRUE) - + map <- data.frame( LBCAT = c("CHEMISTRY", "CHEMISTRY", "CHEMISTRY", "IMMUNOLOGY"), PARAMCD = c("ALT", "CRP", "CRP", "IGA"), diff --git a/tests/testthat/test-lyt-tabulation.R b/tests/testthat/test-lyt-tabulation.R index 1ef19932f..154ec2eca 100644 --- a/tests/testthat/test-lyt-tabulation.R +++ b/tests/testthat/test-lyt-tabulation.R @@ -239,7 +239,7 @@ test_that("labelkids parameter works", { test_that("ref_group comparisons work", { skip_if_not_installed("tibble") require(tibble, quietly = TRUE) - + blthing <- basic_table() %>% split_cols_by("ARM", ref_group = "ARM1") %>% analyze("AGE", show_labels = "hidden") %>% diff --git a/tests/testthat/test-printing.R b/tests/testthat/test-printing.R index d9334087f..148f8f250 100644 --- a/tests/testthat/test-printing.R +++ b/tests/testthat/test-printing.R @@ -803,7 +803,7 @@ test_that("horizontal separator is propagated from table to print and export", { test_that("showing higher-level ncols works", { skip_if_not_installed("tibble") require(tibble, quietly = TRUE) - + mydat <- subset(ex_adsl, SEX %in% c("M", "F")) mydat$SEX2 <- factor( ifelse( diff --git a/tests/testthat/test-subset-access.R b/tests/testthat/test-subset-access.R index f41a28c09..f136dc6ef 100644 --- a/tests/testthat/test-subset-access.R +++ b/tests/testthat/test-subset-access.R @@ -138,7 +138,7 @@ test_rowpaths <- function(tt, visonly = TRUE) { test_that("make_row_df, make_col_df give paths which all work", { skip_if_not_installed("tibble") require(tibble, quietly = TRUE) - + lyt <- basic_table() %>% split_cols_by("ARM") %>% split_cols_by("SEX", ref_group = "F") %>%