r-lib / httr

httr: a friendly http package for R
https://httr.r-lib.org
Other
986 stars 1.99k forks source link

R CMD check failure on musl-based systems #733

Closed bastistician closed 1 year ago

bastistician commented 1 year ago

The test "encoding guessed from type"

https://github.com/r-lib/httr/blob/93a7e96dd5dc6882240f08ce5ec8b0b54f8f4865/tests/testthat/test-content-parse.r#L17

fails if the "latin1" alias is not in iconvlist(), for example with musl's minimal iconv as used on Alpine Linux:

httr:::guess_encoding(NULL, "text/plain; charset=latin1")
## Invalid encoding latin1: defaulting to UTF-8.
## [1] "UTF-8"

iconvlist()
##  [1] "..."       "ISO8859-1" "ISO8859-2" "ISO8859-3" "ISO8859-4" "ISO8859-5"
##  [7] "ISO8859-6" "ISO8859-7" "UCS-2BE"   "UCS-2LE"   "US_ASCII"  "UTF-16BE" 
## [13] "UTF-16LE"  "UTF-32BE"  "UTF-8"     "UTF32-LE"  "WCHAR_T"  

This is the only failing test (see output below) and it would be nice if it could be skipped under these circumstances. Thanks!

R CMD check (tests) output ``` * checking tests ... Running ‘testthat.R’ [5s/16s] [5s/16s] ERROR Running the tests in 'tests/testthat.R' failed. Last 13 lines of output: ══ Skipped tests ═══════════════════════════════════════════════════════════════ • Currently broken (1) • On CRAN (6) ══ Failed tests ════════════════════════════════════════════════════════════════ ── Failure ('test-content-parse.r:17'): encoding guessed from type ───────────── guess_encoding(NULL, "text/plain; charset=latin1") not equal to "latin1". 1/1 mismatches x[1]: "UTF-8" y[1]: "latin1" [ FAIL 1 | WARN 0 | SKIP 7 | PASS 157 ] Error: Test failures Execution halted ```
sessionInfo() ``` > sessionInfo() R Under development (unstable) (2023-02-09 r83794) Platform: x86_64-pc-linux-musl (64-bit) Running under: Alpine Linux v3.17 Matrix products: default BLAS: /home/smeyer/QA/R-83794/build/lib/libRblas.so LAPACK: /home/smeyer/QA/R-83794/build/lib/libRlapack.so; LAPACK version 3.11.0 locale: [1] C.UTF-8 C C C C C time zone: Europe/Berlin tzcode source: internal ```
bastistician commented 1 year ago

Thanks! I can confirm that the patch 404d0b1 fixes R CMD checking httr 1.4.4 in my test bed.