Skip to content

Commit

Permalink
skip more tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkliming committed Oct 9, 2024
1 parent fe9af7c commit 0bcd2ca
Show file tree
Hide file tree
Showing 48 changed files with 134 additions and 14 deletions.
5 changes: 4 additions & 1 deletion tests/testthat/test-ael01_nollt.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ael01_nollt ----

test_that("ael01_nollt works with admh dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael01_nollt, syn_data, dataset = "admh", key_cols = c("MHBODSYS", "MHDECOD"), disp_cols = "MHTERM")
)
Expand All @@ -10,6 +9,7 @@ test_that("ael01_nollt works with admh dataset", {


test_that("ael01_nollt works with non-default label", {
skip_on_os("windows")
proc_data <- syn_data
attr(proc_data$adae$AETERM, "label") <- "Investigator-Specified\n Adverse Event Term"
res <- expect_silent(
Expand All @@ -22,6 +22,7 @@ test_that("ael01_nollt works with non-default label", {
})

test_that("ael01_nollt can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -35,6 +36,7 @@ test_that("ael01_nollt can handle all missing values", {
})

test_that("ael01_nollt can handle some missing values", {
skip_on_os("windows")
new_aebodsys <- c(NA, "", as.character(syn_data$adae$AEBODSYS[-c(1, 2)]))
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))

Expand All @@ -50,6 +52,7 @@ test_that("ael01_nollt can handle some missing values", {
})

test_that("ael01_nollt listing can be split by an additional variable", {
skip_on_os("windows")
res <- expect_silent(
run(
ael01_nollt,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-ael02.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ael02 ----

test_that("ael02 works with adae dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael02, syn_data, dataset = "adae")
)
Expand All @@ -11,6 +10,7 @@ test_that("ael02 works with adae dataset", {
})

test_that("ael02 can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-ael03.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ael03 ----

test_that("ael03 works with adae dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael03, syn_data, dataset = "adae")
)
Expand All @@ -11,6 +10,7 @@ test_that("ael03 works with adae dataset", {
})

test_that("ael03 can handle all missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet01.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test_that("aet01 can use custom anl_vars", {
})

test_that("aet01 fails on incomplete data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(AESER = NULL)
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-aet01_aesi.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# aet01_aesi ----

test_that("aet01_aesi can handle all NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand Down Expand Up @@ -33,12 +32,14 @@ test_that("aet01_aesi can handle some NA values", {
})

test_that("aet01_aesi works with `ALL` argument", {
skip_on_os("windows")
proc_data <- syn_data
res <- expect_silent(run(aet01_aesi, proc_data, aesi_vars = c("ALL")))
expect_snapshot(cat(export_as_txt(res, lpp = 100, cpp = 200)))
})

test_that("aet01_aesi_check fails on incomplete data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(AEOUT = NULL)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet02.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test_that("aet02 fails on incomplete data input", {
})

test_that("aet02 handle empty data input", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
filter(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-aet03.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test_that("aet03 can handle NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -12,6 +11,7 @@ test_that("aet03 can handle NA values", {
})

test_that("aet03 can handle some NA values", {
skip_on_os("windows")
new_aebodsys <- c(NA, "", as.character(syn_data$adae$AEBODSYS[-c(1, 2)]))
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))
new_asev <- c(NA, "", as.character(syn_data$adae$ASEV[-c(1, 2)]))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-aet04.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("aet04 can handle NA values", {

res1 <- expect_silent(run(aet04, proc_data))
expect_snapshot(cat(export_as_txt(res1, lpp = 100)))

skip_on_os("windows")
grade_groups <- list(
"Grade 1-2" = c("1", "2"),
"Grade 3-4" = c("3", "4"),
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet05.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("aet05 can handle NA values", {
})

test_that("aet05 can handle some NA values", {
skip_on_os("windows")
new_paramcd <- c(
as.character(syn_data$adsaftte$PARAMCD[1:4]), NA, "",
as.character(syn_data$adsaftte$PARAMCD[-rep(1:6)])
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet05_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("aet05_all can handle NA values", {
})

test_that("aet05_all can handle some NA values", {
skip_on_os("windows")
new_paramcd <- c(NA, "", as.character(syn_data$adsaftte$PARAMCD[-c(1, 2)]))

proc_data <- syn_data
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet10.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_that("aet10 can handle NA values", {
})

test_that("aet10 can handle some NA values", {
skip_on_os("windows")
new_aedecod <- c(NA, "", as.character(syn_data$adae$AEDECOD[-c(1, 2)]))

proc_data <- syn_data
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-cfbt01.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# cfbt01 functions ----

test_that("cfbt01 functions with default argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- cfbt01_pre(syn_data, dataset = "advs")
raw_res <- cfbt01_main(pre_data, dataset = "advs")
res <- cfbt01_post(raw_res)
Expand Down
23 changes: 22 additions & 1 deletion tests/testthat/test-chevron_tlg-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ syn_adv <- syn_data[c("adsl", "adae")]
syn_adv$adae <- syn_adv$adae[syn_adv$adae$AEBODSYS %in% c("cl A.1", "cl B.1", "cl B.2"), ]

test_that("run works as expected for chevron_t object", {
skip_on_os("windows")
res <- run(aet04, syn_adv, prune_0 = TRUE)
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})

test_that("run works as expected for chevron_t object when auto_pre = FALSE", {
skip_on_os("windows")
proc_data <- syn_adv
proc_data$adsl <- proc_data$adsl %>%
mutate(DOMAIN = "ADSL")
Expand All @@ -18,19 +18,22 @@ test_that("run works as expected for chevron_t object when auto_pre = FALSE", {
})

test_that("run works as expected with argument printed", {
skip_on_os("windows")
res <- capture_output(tbl <- run(aet02, syn_adv, prune_0 = TRUE, verbose = TRUE))
expect_snapshot(cat(res))
expect_snapshot(cat(export_as_txt(tbl, lpp = 100)))
})

test_that("run works as expected with argument printed if the user argument is complicated", {
skip_on_os("windows")
user_args <- list(prune_0 = TRUE, not_used = iris, lbl_overall = "All Patients", row_split_var = "AEHLT")
res <- capture_output(tbl <- run(aet02, syn_adv, user_args = user_args, verbose = TRUE))
expect_snapshot(cat(res))
expect_snapshot(cat(export_as_txt(tbl, lpp = 100)))
})

test_that("run uses the argument passed through the ellipsis in priority", {
skip_on_os("windows")
user_args <- list(prune_0 = TRUE, not_used = iris, lbl_overall = "All Patients", row_split_var = "AEHLT")
res <- capture_output(
tbl <- run(
Expand All @@ -48,12 +51,14 @@ test_that("run uses the argument passed through the ellipsis in priority", {
})

test_that("run works as expected with partial match argument", {
skip_on_os("windows")
res <- capture_output(tbl <- run(aet02, syn_adv, prune_0 = TRUE, verbose = TRUE, arm_var = "ARM"))
expect_snapshot(cat(res))
expect_snapshot(cat(export_as_txt(tbl, lpp = 100)))
})

test_that("run displays the symbols when available", {
skip_on_os("windows")
user_args <- list(prune_0 = TRUE, not_used = iris, lbl_overall = "All Patients", row_split_var = "AEHLT")
arm_param <- "ARM"
res <- capture_output(
Expand All @@ -75,12 +80,14 @@ test_that("run displays the symbols when available", {
# args_ls ----

test_that("args_ls works as expected", {
skip_on_os("windows")
res <- expect_silent(args_ls(aet04))
expect_list(res, len = 3, names = "named")
expect_names(names(res), identical.to = c("main", "preprocess", "postprocess"))
})

test_that("args_ls works as expected when simplify is TRUE", {
skip_on_os("windows")
res <- expect_silent(args_ls(aet04, simplify = TRUE))
expect_list(res, len = 7, names = "named")
expect_names(
Expand All @@ -92,6 +99,7 @@ test_that("args_ls works as expected when simplify is TRUE", {
})

test_that("args_ls works as expected with custom chevron_tlg object", {
skip_on_os("windows")
obj <- aet04
preprocess(obj) <- function(adam_db, arm_var = "overwritten", new_arg = "NEW", ...) {
adam_db
Expand All @@ -111,12 +119,14 @@ test_that("args_ls works as expected with custom chevron_tlg object", {
# main ----

test_that("main works as expected", {
skip_on_os("windows")
skip_on_covr()
res <- main(aet04)
expect_identical(res, aet04_main)
})

test_that("main setter works as expected", {
skip_on_os("windows")
func <- function(adam_db, ...) {
build_table(basic_table(), adam_db)
}
Expand All @@ -126,6 +136,7 @@ test_that("main setter works as expected", {
})

test_that("main setter throw an error as expected", {
skip_on_os("windows")
func <- function(adam_db) {
build_table(basic_table(), adam_db)
}
Expand All @@ -138,19 +149,22 @@ test_that("main setter throw an error as expected", {
# preprocess ----

test_that("preprocess works as expected", {
skip_on_os("windows")
skip_on_covr()
res <- preprocess(aet04)
expect_identical(res, aet04_pre)
})

test_that("preprocess setter works as expected", {
skip_on_os("windows")
func <- function(adam_db, ...) adam_db
obj <- aet04
preprocess(obj) <- func
expect_identical(obj@preprocess, func)
})

test_that("preprocess sends an error as expected", {
skip_on_os("windows")
func <- function(adam_db) adam_db
obj <- aet04
expect_error(preprocess(obj) <- func, "Variable 'object@preprocess': Must have formal arguments: ....",
Expand All @@ -161,18 +175,21 @@ test_that("preprocess sends an error as expected", {
# postprocess ----

test_that("postprocess works as expected", {
skip_on_os("windows")
res <- postprocess(aet04)
expect_identical(res, aet04@postprocess)
})

test_that("postprocess setter works as expected", {
skip_on_os("windows")
func <- function(tlg, ...) tlg
obj <- aet04
postprocess(obj) <- func
expect_identical(obj@postprocess, func)
})

test_that("postprocess sends an error as expected", {
skip_on_os("windows")
func <- function(tlg) tlg
obj <- aet04
expect_error(postprocess(obj) <- func, "Variable 'object@postprocess': Must have formal arguments: ....",
Expand All @@ -183,18 +200,21 @@ test_that("postprocess sends an error as expected", {
# script_funs ----

test_that("script_funs works as expected in interactive mode", {
skip_on_os("windows")
skip_if(!interactive())
res <- expect_silent(script_funs(aet04, adam_db = "data", args = "args_ls"))
expect_snapshot(res)
})

test_that("script_funs works as expected", {
skip_on_os("windows")
res <- expect_silent(script_funs(aet04, adam_db = "data", args = "args_ls"))
expect_character(res)
})


test_that("script_funs generates a valid script", {
skip_on_os("windows")
withr::with_tempfile("tmp", fileext = ".R", {
args_list <- list(
arm_var = "ARM"
Expand All @@ -211,6 +231,7 @@ test_that("script_funs generates a valid script", {
})

test_that("script_funs works for simple template", {
skip_on_os("windows")
res <- expect_silent(script_funs(chevron_simple(), adam_db = "syn_adv"))
expect_character(res)
})
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-cml02a_gl.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_that("cml02a_gl works with adcm dataset", {
})

test_that("cml02a_gl works with missing data", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adcm$ATC2 <- NA_character_
expect_silent(res <- run(cml02a_gl, proc_data))
Expand All @@ -15,6 +16,7 @@ test_that("cml02a_gl works with missing data", {
# cml02a_gl functions ----

test_that("cml02a_gl functions work as expected", {
skip_on_os("windows")
expect_silent(
res <- cml02a_gl_pre(syn_data) %>%
cml02a_gl_main()
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-cmt01a.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_that("cmt01a functions with default argument value return expected result w
})

test_that("cmt01a functions with custom argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- cmt01a_pre(syn_data)
raw_res <- cmt01a_main(pre_data, summary_labels = list(
TOTAL = c(
Expand All @@ -22,6 +23,7 @@ test_that("cmt01a functions with custom argument value return expected result wi
# cmt01a ----

test_that("cmt01a can handle all NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adcm <- proc_data$adcm %>%
mutate(
Expand All @@ -34,6 +36,7 @@ test_that("cmt01a can handle all NA values", {
})

test_that("cmt01a can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adcm$ATC2[1:2] <- NA
proc_data$adcm$CMDECOD[1:2] <- NA
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-cmt02_pt.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("cmt02_pt can handle all NA values", {
})

test_that("cmt02_pt can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adcm[1:2, c("CMDECOD")] <- NA

Expand Down
Loading

0 comments on commit 0bcd2ca

Please sign in to comment.