Skip to content

Commit

Permalink
[#7] better guess os
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarbone committed Nov 11, 2022
1 parent c7f42a2 commit 37a9971
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions tests/testthat/test-os.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
test_that("windows", {
skip_if_not(startsWith(Sys.getenv("GH_ACTIONS_OS"), "windows"))
expect_true(is_windows())
expect_false(is_macos())
expect_false(is_linux())
})

test_that("macos", {
skip_if_not(startsWith(Sys.getenv("GH_ACTIONS_OS"), "macos"))
expect_false(is_windows())
expect_true(is_macos())
expect_false(is_linux())
})

test_that("linux (ubuntu)", {
skip_if_not(startsWith(Sys.getenv("GH_ACTIONS_OS"), "ubuntu"))
expect_false(is_windows())
expect_false(is_macos())
expect_true(is_linux())
test_that("os", {
env <- Sys.getenv("GH_ACTIONS_OS")
env <- regmatches(env, regexpr("[a-z]+", env))
switch(
env,
windows = {
expect_true(is_windows())
expect_false(is_macos())
expect_false(is_linux())
},
macos = {
expect_false(is_windows())
expect_true(is_macos())
expect_false(is_linux())
},
ubuntu = {
expect_false(is_windows())
expect_false(is_macos())
expect_true(is_linux())
}
)
})

0 comments on commit 37a9971

Please sign in to comment.