diff --git a/tests/testthat/test-box-R6.R b/tests/testthat/test-box-R6.R index 27664b6a..b50b8408 100644 --- a/tests/testthat/test-box-R6.R +++ b/tests/testthat/test-box-R6.R @@ -1,20 +1,21 @@ -context("box") +context("box-R6") loaded_mods <- loadNamespace("box")$loaded_mods rm(list = ls(loaded_mods), envir = loaded_mods) test_that("R6 box module coverage is reported", { + # Similar to test-R6.R, there is some sort of bug that causes this test + # to fail during R CMD check in R-devel, not sure why, and can't reproduce + # it interactively skip_if(is_r_devel()) withr::with_dir("Testbox_R6", { cov <- as.data.frame(file_coverage( source_files = "app/app.R", test_files = list.files("tests/testthat", full.names = TRUE))) - expect_equal(cov$value, c(5, 2, 3, 3, 1, 1)) - expect_equal(cov$first_line, c(5, 6, 8, 13, 5, 8)) - expect_equal(cov$last_line, c(5, 6, 8, 13, 5, 8)) - expect_true("a" %in% cov$functions) - expect_true("private_function" %in% cov$functions) + expect_equal(cov$value, c(1, 1)) + expect_equal(cov$first_line, c(5, 8)) + expect_equal(cov$last_line, c(5, 8)) expect_true("show" %in% cov$functions) }) }) diff --git a/tests/testthat/test-box.R b/tests/testthat/test-box.R index 2948f4e0..9ee174a0 100644 --- a/tests/testthat/test-box.R +++ b/tests/testthat/test-box.R @@ -9,11 +9,10 @@ test_that("box module coverage is reported", { source_files = "app/app.R", test_files = list.files("tests/testthat", full.names = TRUE))) - expect_equal(cov$value, c(5, 2, 3, 3, 1, 1)) - expect_equal(cov$first_line, c(5, 6, 8, 13, 5, 8)) - expect_equal(cov$last_line, c(5, 6, 8, 13, 5, 8)) + expect_equal(cov$value, c(5, 2, 3, 3)) + expect_equal(cov$first_line, c(5, 6, 8, 13)) + expect_equal(cov$last_line, c(5, 6, 8, 13)) expect_true("a" %in% cov$functions) expect_true("private_function" %in% cov$functions) - expect_true("show" %in% cov$functions) }) }) diff --git a/tests/testthat/test-box_attached_modules_functions-R6.R b/tests/testthat/test-box_attached_modules_functions-R6.R index 03f91725..ba491dc8 100644 --- a/tests/testthat/test-box_attached_modules_functions-R6.R +++ b/tests/testthat/test-box_attached_modules_functions-R6.R @@ -1,20 +1,21 @@ -context("box-attached-modules-functions") +context("box-attached-modules-functions-R6") loaded_mods <- loadNamespace("box")$loaded_mods rm(list = ls(loaded_mods), envir = loaded_mods) test_that("R6 box attached module coverage is reported", { + # Similar to test-R6.R, there is some sort of bug that causes this test + # to fail during R CMD check in R-devel, not sure why, and can't reproduce + # it interactively skip_if(is_r_devel()) - withr::with_dir("Testbox_attached_modules_functions", { + withr::with_dir("Testbox_attached_modules_functions_R6", { cov <- as.data.frame(file_coverage( source_files = "app/app.R", test_files = list.files("tests/testthat", full.names = TRUE))) - expect_equal(cov$value, c(20, 8, 12, 3, 0, 1, 1)) - expect_equal(cov$first_line, c(5, 6, 8, 14, 18, 5, 8)) - expect_equal(cov$last_line, c(5, 6, 8, 14, 18, 5, 8)) - expect_true("a" %in% cov$functions) - expect_true("private_function" %in% cov$functions) + expect_equal(cov$value, c(1, 1)) + expect_equal(cov$first_line, c(5, 8)) + expect_equal(cov$last_line, c(5, 8)) expect_true("show" %in% cov$functions) }) diff --git a/tests/testthat/test-box_attached_modules_functions.R b/tests/testthat/test-box_attached_modules_functions.R index bec3813d..06064083 100644 --- a/tests/testthat/test-box_attached_modules_functions.R +++ b/tests/testthat/test-box_attached_modules_functions.R @@ -9,12 +9,11 @@ test_that("box attached module coverage is reported", { source_files = "app/app.R", test_files = list.files("tests/testthat", full.names = TRUE))) - expect_equal(cov$value, c(20, 8, 12, 3, 0, 1, 1)) - expect_equal(cov$first_line, c(5, 6, 8, 14, 18, 5, 8)) - expect_equal(cov$last_line, c(5, 6, 8, 14, 18, 5, 8)) + expect_equal(cov$value, c(20, 8, 12, 3, 0)) + expect_equal(cov$first_line, c(5, 6, 8, 14, 18)) + expect_equal(cov$last_line, c(5, 6, 8, 14, 18)) expect_true("a" %in% cov$functions) expect_true("private_function" %in% cov$functions) - expect_true("show" %in% cov$functions) }) })