Skip to content

Commit

Permalink
Skip tests when not running via testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Dec 29, 2023
1 parent b1586e8 commit da8b0b1
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 20 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* *action.yml*
- `repository: ${{ github.repository }}` --> `repository: ${{ env.packageName }}`
* CRAN:
- Add convenient `testthat` functions `skip_on_cran()` and `skip_if_offline`.
- Add convenient `testthat` function `skip_if_offline`.
* Reduce package size by making vignettes `rmarkdown::html_vignette`
instead of `BiocStyle::html_document`.
* URL: https://github.com/runforesight/workflow-telemetry-action (moved to https://github.com/catchpoint/workflow-telemetry-action)

* Skip tests that are sensitive to working directory location
(which can cause issues when running `devtools::test_coverage()` in the terminal) #112

# rworkflows 1.0.0

Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-bioc_r_versions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("bioc_r_versions works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

ver1 <- bioc_r_versions(bioc_version="devel")
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-check_cont.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("check_cont works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

testthat::expect_no_warning(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-check_r_version.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("check_r_version works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

testthat::expect_equal(
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-construct_conda_yml.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ test_that("construct_conda_yml works", {
testthat::expect_true(file.exists(path2))

## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

# conda <- conda_path()
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-construct_cont.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test_that("construct_cont works", {
testthat::expect_null(cont3[[3]])

## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

cont4 <- construct_cont(default_tag = "release",
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-construct_runners.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("construct_runners works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

#### Set up tests ####
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test_that("get_description works", {
testthat::expect_equal(d7[[1]],
d1[[1]])
} else{
testthat::expect_null(d7[[1]])
message("Skipping test.")
}

#### Search CRAN/Bioc repos ####
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_hex.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_that("get_hex works", {
testthat::expect_equal(hex3[[1]],
hex1[[1]])
} else {
testthat::expect_null(hex3[[1]])
message("Skipping test.")
}
#### When neither refs nor paths provided ####
hex4 <- get_hex(refs=NULL,
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-gha_python_versions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("gha_python_versions works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

testthat::expect_equal(gha_python_versions(python_version = "3.11"),"3.11")
Expand Down
13 changes: 5 additions & 8 deletions tests/testthat/test-infer_biocviews.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
test_that("infer_biocviews works", {

# Don't run simply bc biocViews::recommendBiocViews is unable
## to find the DESCRIPTION file when running examples.
# biocviews1 <- infer_biocviews(pkgdir = "../../")
# testthat::expect_equal(biocviews1,"Software")

#
if(testthat::is_testing() &&
!is_gha()){
testthat::expect_error(
infer_biocviews(include_branch = FALSE)
)
message("Skipping test.")
} else {
testthat::expect_equal(infer_biocviews(include_branch = FALSE),
c("Software","WorkflowManagement"))
}
biocviews_manual = c("Software","Genetics","Transcriptomics")
if(testthat::is_testing() && !is_gha()){
testthat::expect_error(
infer_biocviews(biocviews = biocviews_manual)
)
if(testthat::is_testing() &&
!is_gha()){
message("Skipping test.")
} else {
testthat::expect_equal(infer_biocviews(biocviews = biocviews_manual),
c(biocviews_manual,"WorkflowManagement"))
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-url_exists.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
test_that("url_exists works", {
## Don't run on CRAN servers due to ongoing internet connectivity issues
testthat::skip_on_cran()
testthat::skip_if_offline()

testthat::expect_true(
Expand Down

0 comments on commit da8b0b1

Please sign in to comment.