Skip to content

Commit

Permalink
tests: Skip 'parse_known_intermixed_args()' tests on Debian on CRAN
Browse files Browse the repository at this point in the history
* Skips two `parse_known_intermixed_args()` tests on CRAN on Debian Testing
  to avoid raising an ERROR due to a bug in Debian Testing's version of python:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087681

closes #53
  • Loading branch information
trevorld committed Nov 19, 2024
1 parent de5626c commit e2d01ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Depends:
Imports:
findpython,
jsonlite,
R6
R6,
utils
SystemRequirements: python (>= 3.2)
Suggests:
knitr (>= 1.15.19),
Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Based on code from Dirk Eddelbuettel
# https://fosstodon.org/@[email protected]/113499555242268476
get_linux_flavor <- function() {
flavor <- NA_character_
osrel <- "/etc/os-release"
if (isTRUE(file.exists(osrel))) { # on (at least) Debian, Ubuntu, Fedora
x <- utils::read.table(osrel, sep = "=", row.names = 1L,
col.names = c("","Val"), header = FALSE)
flavor <- tolower(x["ID", "Val"])
}
flavor
}
8 changes: 6 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Notes

* Skips two `parse_known_intermixed_args()` tests on CRAN on Debian Testing
to avoid raising an ERROR due to a bug in Debian Testing's version of python:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087681

* As in previous uploads while in a non-interactive session (i.e. in an
Rscript) if ``parse_args()`` observes a help flag it will print a usage
message and then call ``quit()``. Additionally if a user specifically adds
Expand All @@ -12,7 +16,7 @@

## Test environments

* local (linux), R 4.3.3
* local (linux), R 4.4.2
* win-builder (windows), R devel
* Github Actions (linux), R devel, release, oldrel
* Github Actions (windows), R release
Expand All @@ -24,7 +28,7 @@ Status: OK

## revdepcheck results

We checked 3 reverse dependencies (0 from CRAN + 3 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package.
We checked 4 reverse dependencies (0 from CRAN + 4 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
11 changes: 11 additions & 0 deletions tests/testthat/test-argparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,18 @@ test_that("parse_intermixed_args() works as expected", {
expect_equal(args$cmd, 'doit')
expect_equal(args$foo, 'bar')
expect_equal(args$rest, 1:3)
})

test_that("parse_known_intermixed_args() works as expected", {
skip_if_not(detects_python(minimum_version = '3.7'))
# Bug in Debian Testing's version of python causes CRAN ERROR
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087681
if (isTRUE(get_linux_flavor() == "debian"))
skip_on_cran()
parser <- ArgumentParser()
parser$add_argument('--foo')
parser$add_argument('cmd')
parser$add_argument('rest', nargs='*', type='integer')
args <- strsplit('doit 1 --foo bar 2 3 -n 4', ' ')[[1]]
a_r <- parser$parse_known_intermixed_args(args)
expect_equal(a_r[[1]]$cmd, 'doit')
Expand Down

0 comments on commit e2d01ee

Please sign in to comment.