Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform tests in different operative systems #125

Merged
merged 9 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ jobs:
fail-fast: false
matrix:
config:
# - {os: macos-latest, r: 'release'}
# - {os: windows-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ testdata <- get_ifadv()
with_save <- function(plot_function, path, width=800, height=350) {

decorated <- function(...) {

png(path, width, height) # Create a file placeholder for the plot,
p <- plot_function(...) # generate the plot...
dev.off() # ... export it as png and close connection
Expand All @@ -46,7 +47,24 @@ with_save <- function(plot_function, path, width=800, height=350) {
return(decorated)
}

#' Skip if not linux
#'
#' Plot saving is OS dependent. For the sake of sanity, we'll test the plot
#' snapshots only in Linux
#'
#' @return Nothing
#'
skip_if_not_linux <- function() {
if(Sys.info()["sysname"] == "Linux") {
# Do nothing
} else {
skip("This test is designed to run on Linux machines only")
}
}

test_that("Plot quality", {
skip_if_not_linux()

path <- "plot_quality.png"
plot_quality_with_save <- with_save(plot_quality, path)

Expand All @@ -57,3 +75,4 @@ test_that("Plot quality", {

on.exit(file.remove(path)) # Clean afterwards
})

Loading