diff --git a/tests/testthat/test-is.R b/tests/testthat/test-is.R index 822fbd3..653e4c0 100644 --- a/tests/testthat/test-is.R +++ b/tests/testthat/test-is.R @@ -1,15 +1,8 @@ test_that("is.rpi confirms/denies RPi", { - expect_true( - # if /etc/os-release exists, - # ...and it contains "Raspbian" - # then is.rpi() should == TRUE - # else !is.rpi() should == TRUE - if (file.exists("/etc/os-release")) { - if (any(grepl("Raspbian", readLines("/etc/os-release")))) { - is.rpi() - } - } else { - !is.rpi() - } - ) + skip_on_os("mac", message = "This is a mac") + skip_on_os("windows", message = "this is windows") + skip_if_not( file.exists("/etc/os-release"), message = "missing /etc/os-release") + skip_if_not( any(grepl("Raspbian", readLines("/etc/os-release"))), + message = "Raspbian is not in /etc/os-release") + expect_true( is.rpi() ) }) diff --git a/tests/testthat/test-rpi_get.R b/tests/testthat/test-rpi_get.R index 8849056..60421c7 100644 --- a/tests/testthat/test-rpi_get.R +++ b/tests/testthat/test-rpi_get.R @@ -1,3 +1,4 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("rpi_get", { + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") + skip("skip") }) diff --git a/tests/testthat/test-rpi_i2c_dump.R b/tests/testthat/test-rpi_i2c_dump.R index 8849056..0f58c4f 100644 --- a/tests/testthat/test-rpi_i2c_dump.R +++ b/tests/testthat/test-rpi_i2c_dump.R @@ -1,3 +1,4 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("rpi_i2c_dump", { + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") + skip("skip") }) diff --git a/tests/testthat/test-rpi_i2c_get.R b/tests/testthat/test-rpi_i2c_get.R index 1b2d30b..d82a76b 100644 --- a/tests/testthat/test-rpi_i2c_get.R +++ b/tests/testthat/test-rpi_i2c_get.R @@ -1,5 +1,5 @@ test_that("rpi_i2c_get works", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_no_error(rpi_i2c_get( chip_address = 0x77, data_address = 0xf0, @@ -8,7 +8,7 @@ test_that("rpi_i2c_get works", { }) test_that("rpi_i2c_get err chip address", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_error(rpi_i2c_get( chip_address = 0x07, data_address = 0xf0, @@ -17,7 +17,7 @@ test_that("rpi_i2c_get err chip address", { }) test_that("rpi_i2c_get err data address", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_error(rpi_i2c_get( chip_address = 0x77, data_address = 0xFFF, diff --git a/tests/testthat/test-rpi_i2c_set.R b/tests/testthat/test-rpi_i2c_set.R index 8849056..f2d9446 100644 --- a/tests/testthat/test-rpi_i2c_set.R +++ b/tests/testthat/test-rpi_i2c_set.R @@ -1,3 +1,4 @@ -test_that("multiplication works", { - expect_equal(2 * 2, 4) +test_that("rpi_i2c_set", { + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") + skip("skip") }) diff --git a/tests/testthat/test-rpi_monitor.R b/tests/testthat/test-rpi_monitor.R index d7c1bae..c46b3e3 100644 --- a/tests/testthat/test-rpi_monitor.R +++ b/tests/testthat/test-rpi_monitor.R @@ -1,4 +1,4 @@ -test_that("rpi_monitor works", { - skip_if_not(is.rpi()) - expect_true(TRUE) +test_that("test rpi_monitor", { + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") + skip("skip") }) diff --git a/tests/testthat/test-rpi_pwm.R b/tests/testthat/test-rpi_pwm.R index d371ada..0e24a9a 100644 --- a/tests/testthat/test-rpi_pwm.R +++ b/tests/testthat/test-rpi_pwm.R @@ -1,20 +1,20 @@ test_that("is pin_number valid for use with PWM?", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_error(rpi_pwm(30, pwm_debug = TRUE)) }) test_that("Do two PWM pins collide?", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_error(rpi_pwm(c(12, 32), pwm_debug = TRUE)) }) test_that("length(pin_number) > 3", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_error(rpi_pwm(c(12, 32, 33), pwm_debug = TRUE)) }) test_that("real world test of pwm", { - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") message("Testing PWM in real world") testPWM <- function() { rpi_pwm(pin_number = 12, pwm_period = 50000, pwm_dutycycle = 10000) diff --git a/tests/testthat/test-rpi_set.R b/tests/testthat/test-rpi_set.R index 7802821..b7b18bc 100644 --- a/tests/testthat/test-rpi_set.R +++ b/tests/testthat/test-rpi_set.R @@ -1,6 +1,6 @@ test_that("Can we set a pin", { message("Real world test of setting board pin 11") - skip_if_not(is.rpi()) + skip_if_not(is.rpi(), message = "Not a Raspberry Pi") expect_silent({ rpi_set(11, 1) Sys.sleep(1)