Skip to content

Commit

Permalink
tests: add additional conditions for extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Oct 10, 2023
1 parent 2cd2ea0 commit b1e3e3f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Suggests:
testthat (>= 3.0.0),
mzR,
chromConverterExtraTests
Config/reticulate: list( packages = list( list(package = "scipy"),
Config/reticulate: list( packages = list(list(package = "scipy"),
list(package="numpy"),
list(package = "pandas"),
list(package="aston", pip = TRUE),
Expand Down
2 changes: 1 addition & 1 deletion inst/shell/path_to_openchrom_commandline.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NULL
/Applications/Eclipse.app/Contents/MacOS/openchrom
9 changes: 3 additions & 6 deletions tests/testthat/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
elementwise.all.equal <- Vectorize(function(x, y, ...) {isTRUE(all.equal(x, y, ...))})

# helper function to skip tests if we don't have the right python dependencies
skip_if_missing_dependecies <- function() {
reqs <- c("scipy","numpy", "aston", "pandas")
skip_if_missing_dependecies <- function(reqs = c("scipy","numpy", "aston", "pandas", "olefile")) {
have_reqs <- sapply(reqs, reticulate::py_module_available)
if (mean(have_reqs) < 1)
skip(paste("required packages", reqs[!have_reqs],
Expand All @@ -21,15 +20,13 @@ skip_if_missing_thermorawfileparser <- function() {
}
have_reqs <- fs::file_exists(path)
if (mean(have_reqs) < 1)
skip(paste("required packages", reqs[!have_reqs],
"not available for testing"))
skip("ThermoRawFileParser could not be found.")
}

skip_if_missing_openchrom <- function() {
have_openchrom_cli <- switch(configure_openchrom(cli="status"), true = TRUE,
false = FALSE)
if (!have_openchrom_cli){
skip(paste("required packages", reqs[!have_reqs],
"not available for testing"))
skip("OpenChrom could not be found.")
}
}
6 changes: 4 additions & 2 deletions tests/testthat/test-extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ test_that("read_chroms can read 'Chromeleon' period-separated files", {

test_that("read_peaklist can read `Shimadzu` PDA files", {
skip_on_cran()
skip_if_missing_dependecies()
skip_if_not_installed("chromConverterExtraTests")

path <- system.file("shimadzuDAD_Anthocyanin.txt",
package = "chromConverterExtraTests")

Expand Down Expand Up @@ -238,6 +238,7 @@ test_that("read_chroms can read 'Agilent' dx files", {

test_that("read_chroms can read 'Thermo' RAW files", {
skip_on_cran()
skip_on_ci()
skip_if_not_installed("chromConverterExtraTests")
skip_if_missing_thermorawfileparser()

Expand All @@ -259,6 +260,7 @@ test_that("read_chroms can read 'Thermo' RAW files", {

test_that("read_chroms can use 'OpenChrom' parsers", {
skip_on_cran()
skip_on_ci()
skip_if_not_installed("chromConverterExtraTests")
skip_if_missing_openchrom()

Expand Down Expand Up @@ -286,8 +288,8 @@ test_that("read_varian_peaklist function works", {

test_that("read_cdf function can read peak tables", {
skip_on_cran()
skip_if_not_installed("ncdf4")
skip_if_not_installed("chromConverterExtraTests")

path <- system.file("VARIAN1.CDF", package = "chromConverterExtraTests")
x <- read_cdf(path, what = "peak_table")
expect_s3_class(x, "data.frame")
Expand Down

0 comments on commit b1e3e3f

Please sign in to comment.