2222# '
2323# ' * `skip_if_translated("msg")` skips tests if the "msg" is translated.
2424# '
25- # ' * `skip_on_bioc()` skips on Bioconductor (using the `BBS_HOME` env var).
25+ # ' * `skip_on_bioc()` skips on Bioconductor (using the `IS_BIOC_BUILD_MACHINE`
26+ # ' env var).
2627# '
2728# ' * `skip_on_cran()` skips on CRAN (using the `NOT_CRAN` env var set by
2829# ' devtools and friends).
2930# '
3031# ' * `skip_on_covr()` skips when covr is running (using the `R_COVR` env var).
3132# '
3233# ' * `skip_on_ci()` skips on continuous integration systems like GitHub Actions,
33- # ' travis, and appveyor (using the `CI` env var). It supersedes the older
34- # ' `skip_on_travis()` and `skip_on_appveyor()` functions.
34+ # ' travis, and appveyor (using the `CI` env var).
3535# '
3636# ' * `skip_on_os()` skips on the specified operating system(s) ("windows",
3737# ' "mac", "linux", or "solaris").
4848# ' expect_equal(1, 2) # this one skipped
4949# ' expect_equal(1, 3) # this one is also skipped
5050# ' })
51- skip <- function (message ) {
51+ skip <- function (message = " Skipping " ) {
5252 message <- paste0(message , collapse = " \n " )
5353 cond <- structure(
5454 list (message = paste0(" Reason: " , message )),
@@ -76,6 +76,8 @@ skip_if_not <- function(condition, message = NULL) {
7676 }
7777 if (! isTRUE(condition )) {
7878 skip(message )
79+ } else {
80+ invisible ()
7981 }
8082}
8183
@@ -87,6 +89,8 @@ skip_if <- function(condition, message = NULL) {
8789 }
8890 if (isTRUE(condition )) {
8991 skip(message )
92+ } else {
93+ invisible ()
9094 }
9195}
9296
@@ -109,18 +113,18 @@ skip_if_not_installed <- function(pkg, minimum_version = NULL) {
109113 }
110114 }
111115
112- return ( invisible (TRUE ) )
116+ invisible ()
113117}
114118
115119# ' @export
116120# ' @rdname skip
117121skip_if_offline <- function (host = " r-project.org" ) {
118122 skip_on_cran()
119123 skip_if_not_installed(" curl" )
120- has_internet <- ! is.null( curl :: nslookup( host , error = FALSE ) )
121- if ( ! has_internet ) {
122- skip( " offline " )
123- }
124+ skip_if_not( has_internet( host ), " offline " )
125+ }
126+ has_internet <- function ( host ) {
127+ ! is.null( curl :: nslookup( host , error = FALSE ))
124128}
125129
126130# ' @export
@@ -129,8 +133,6 @@ skip_on_cran <- function() {
129133 skip_if(on_cran(), " On CRAN" )
130134}
131135
132- on_cran <- function () ! identical(Sys.getenv(" NOT_CRAN" ), " true" )
133-
134136# ' @export
135137# ' @param os Character vector of one or more operating systems to skip on.
136138# ' Supported values are `"windows"`, `"mac"`, `"linux"`, and `"solaris"`.
@@ -175,62 +177,22 @@ skip_on_os <- function(os, arch = NULL) {
175177system_os <- function () tolower(Sys.info()[[" sysname" ]])
176178system_arch <- function () R.version $ arch
177179
178- # ' @export
179- # ' @rdname skip
180- skip_on_travis <- function () {
181- if (! identical(Sys.getenv(" TRAVIS" ), " true" )) {
182- return (invisible (TRUE ))
183- }
184-
185- skip(" On Travis" )
186- }
187-
188- # ' @export
189- # ' @rdname skip
190- skip_on_appveyor <- function () {
191- if (! identical(Sys.getenv(" APPVEYOR" ), " True" )) {
192- return ()
193- }
194-
195- skip(" On Appveyor" )
196- }
197-
198180# ' @export
199181# ' @rdname skip
200182skip_on_ci <- function () {
201- if (! on_ci()) {
202- return (invisible (TRUE ))
203- }
204-
205- skip(" On CI" )
206- }
207-
208- on_ci <- function () {
209- isTRUE(as.logical(Sys.getenv(" CI" )))
210- }
211-
212- in_covr <- function () {
213- identical(Sys.getenv(" R_COVR" ), " true" )
183+ skip_if(on_ci(), " On CI" )
214184}
215185
216186# ' @export
217187# ' @rdname skip
218188skip_on_covr <- function () {
219- if (! in_covr()) {
220- return (invisible (TRUE ))
221- }
222-
223- skip(" On covr" )
189+ skip_if(in_covr(), " On covr" )
224190}
225191
226192# ' @export
227193# ' @rdname skip
228194skip_on_bioc <- function () {
229- if (identical(Sys.getenv(" BBS_HOME" ), " " )) {
230- return (invisible (TRUE ))
231- }
232-
233- skip(" On Bioconductor" )
195+ skip_if(on_bioc(), " On Bioconductor" )
234196}
235197
236198# ' @export
@@ -239,9 +201,47 @@ skip_on_bioc <- function() {
239201# ' [`R-base.pot`](https://github.com/wch/r-source/blob/master/src/library/base/po/R-base.pot).
240202# ' @rdname skip
241203skip_if_translated <- function (msgid = " '%s' not found" ) {
242- if (gettext(msgid , domain = " R" ) == msgid ) {
243- return (invisible (TRUE ))
244- }
204+ skip_if(
205+ gettext(msgid , domain = " R" ) != msgid ,
206+ paste0(" \" " , msgid , " \" is translated" )
207+ )
208+ }
209+
210+ # ' Superseded skip functions
211+ # '
212+ # ' @description
213+ # ' `r lifecycle::badge("superseded")`
214+ # '
215+ # ' * `skip_on_travis()` and `skip_on_appveyor()` have been superseded by
216+ # ' [skip_on_ci()].
217+ # '
218+ # ' @export
219+ # ' @keywords internal
220+ skip_on_travis <- function () {
221+ skip_if(env_var_is_true(" TRAVIS" ), " On Travis" )
222+ }
223+
224+ # ' @export
225+ # ' @rdname skip_on_travis
226+ skip_on_appveyor <- function () {
227+ skip_if(env_var_is_true(" APPVEYOR" ), " On Appveyor" )
228+ }
229+
230+ # helpers -----------------------------------------------------------------
231+
232+ on_ci <- function () {
233+ env_var_is_true(" CI" )
234+ }
235+ in_covr <- function () {
236+ env_var_is_true(" R_COVR" )
237+ }
238+ on_bioc <- function () {
239+ env_var_is_true(" IS_BIOC_BUILD_MACHINE" )
240+ }
241+ on_cran <- function () {
242+ ! env_var_is_true(" NOT_CRAN" )
243+ }
245244
246- skip(paste0(" \" " , msgid , " \" is translated" ))
245+ env_var_is_true <- function (x ) {
246+ isTRUE(as.logical(Sys.getenv(x , " false" )))
247247}
0 commit comments