[R-pkg-team] Bug#999870: r-cran-vctrs: autopkgtests fail on s390x due to invalid test data

Steve Langasek steve.langasek at canonical.com
Wed Nov 17 23:34:49 GMT 2021


Package: r-cran-vctrs
Version: 0.3.8-1
Severity: important
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu jammy ubuntu-patch

Hi Andreas,

In Debian and Ubuntu, the r-cran-vctrs autopkgtests are failing on s390x
because the test data depends on output that varies between little and big
endian architectures.

In https://github.com/r-lib/vctrs/issues/1353#issuecomment-814097160
upstream states that BE archs are not supported, but I don't see any problem
here with the portability of the code, it's only the test cases that are
incompatible on BE because there are assumptions about the stringification
of the data types, which depends on the behavior of the
architecture-dependent hash library.  Rather than regressing s390x support
(or test coverage) for a library that seems to work just fine, I've uploaded
the attached patch to Ubuntu to make the tests pass on BE archs.  Please
consider whether this could also be included in Debian.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
diff -Nru r-cran-vctrs-0.3.8/debian/patches/s390x-tests.patch r-cran-vctrs-0.3.8/debian/patches/s390x-tests.patch
--- r-cran-vctrs-0.3.8/debian/patches/s390x-tests.patch	1969-12-31 16:00:00.000000000 -0800
+++ r-cran-vctrs-0.3.8/debian/patches/s390x-tests.patch	2021-11-17 15:28:31.000000000 -0800
@@ -0,0 +1,297 @@
+Description: handle differing test-case output on big-endian architectures
+ In https://github.com/r-lib/vctrs/issues/1353#issuecomment-814097160
+ upstream asserts that big-endian architectures are not supported.  In
+ practice this code seems to work fine on big-endian, it just has different
+ stringification of the types due to arch-dependent behavior of the hash
+ library; and rather than regressing test coverage wrt the 4000+ passing
+ tests by ignoring these failures, it seems worthwhile to make the tests
+ pass on big-endian platforms with a special-case.
+Author: Steve Langasek <steve.langasek at ubuntu.com>
+Last-Update: 2021-11-17
+
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor.R
+===================================================================
+--- r-cran-vctrs-0.3.8.orig/tests/testthat/test-partial-factor.R
++++ r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor.R
+@@ -1,15 +1,23 @@
+ 
+ test_that("has ok print method", {
++  if (.Platform$endian == "big") {
++    variant <- "-be"
++  } else {
++    variant <- ""
++  }
++
+   partial <- partial_factor("x")
+   expect_known_output(
+     print(partial),
+-    test_path("test-partial-factor-print-partial.txt")
++    test_path(paste("test-partial-factor-print-partial", variant, ".txt",
++                    sep = ""))
+   )
+ 
+   both <- vec_ptype2(partial, factor("y"))
+   expect_known_output(
+     print(both),
+-    test_path("test-partial-factor-print-both.txt")
++    test_path(paste("test-partial-factor-print-both", variant, ".txt",
++                    sep = ""))
+   )
+ 
+   empty <- partial_factor()
+@@ -21,7 +29,8 @@ test_that("has ok print method", {
+   learned <- vec_ptype2(empty, factor("y"))
+   expect_known_output(
+     print(learned),
+-    test_path("test-partial-factor-print-learned.txt")
++    test_path(paste("test-partial-factor-print-learned", variant, ".txt",
++                    sep = ""))
+   )
+ 
+   expect_equal(vec_ptype_abbr(partial), "prtl_fctr")
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-partial-be.txt
+===================================================================
+--- /dev/null
++++ r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-partial-be.txt
+@@ -0,0 +1,3 @@
++partial_factor<
++  fa16b {partial}
++>
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-both-be.txt
+===================================================================
+--- /dev/null
++++ r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-both-be.txt
+@@ -0,0 +1,4 @@
++partial_factor<
++  fa16b {partial}
++  31927
++>
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-learned-be.txt
+===================================================================
+--- /dev/null
++++ r-cran-vctrs-0.3.8/tests/testthat/test-partial-factor-print-learned-be.txt
+@@ -0,0 +1,3 @@
++partial_factor<
++  31927
++>
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-cast-error-nested-be.txt
+===================================================================
+--- /dev/null
++++ r-cran-vctrs-0.3.8/tests/testthat/test-cast-error-nested-be.txt
+@@ -0,0 +1,25 @@
++
++vec_cast("foo", 10):
++
++Can't convert <character> to <double>. 
++
++
++vec_cast(factor("foo"), 10):
++
++Can't convert <factor<76c17>> to <double>. 
++
++
++vec_cast(x, y):
++
++Can't convert `a$b` <character> to match type of `a$b` <double>. 
++
++
++vec_cast(x, y):
++
++Can't convert `a$b` <factor<76c17>> to match type of `a$b` <double>. 
++
++
++vec_cast_common(x, y):
++
++Can't combine `..1$a$b` <factor<76c17>> and `..2$a$b` <double>. 
++
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-cast.R
+===================================================================
+--- r-cran-vctrs-0.3.8.orig/tests/testthat/test-cast.R
++++ r-cran-vctrs-0.3.8/tests/testthat/test-cast.R
+@@ -1,4 +1,10 @@
+ 
++if (.Platform$endian == "big") {
++  variant <- "-be"
++} else {
++  variant <- ""
++}
++
+ test_that("vec_cast() has helpful error messages", {
+   verify_output(test_path("error", "test-cast.txt"), {
+     "# Casting to named argument mentions 'match type <foo>'"
+@@ -54,8 +60,11 @@ test_that("cast common preserves names",
+   expect_identical(vec_cast_common(foo = 1, bar = 2L), list(foo = 1, bar = 2))
+ })
+ 
++
++file = paste("test-cast-error-nested", variant, ".txt", sep = "")
++
+ test_that("cast errors create helpful messages (#57, #225)", {
+-  expect_known_output(file = test_path("test-cast-error-nested.txt"), {
++  expect_known_output(file = file, {
+     # Lossy cast
+     try2(vec_cast("foo", 10))
+ 
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-assert-explanations-be.txt
+===================================================================
+--- /dev/null
++++ r-cran-vctrs-0.3.8/tests/testthat/test-assert-explanations-be.txt
+@@ -0,0 +1,138 @@
++> vec_assert(lgl(), chr()):
++
++Error: `lgl()` must be a vector with type <character>.
++Instead, it has type <logical>.
++
++
++
++> vec_assert(lgl(), factor()):
++
++Error: `lgl()` must be a vector with type <factor<>>.
++Instead, it has type <logical>.
++
++
++
++> vec_assert(lgl(), factor(levels = "foo")):
++
++Error: `lgl()` must be a vector with type <factor<76c17>>.
++Instead, it has type <logical>.
++
++
++
++> vec_assert(factor(levels = "bar"), factor(levels = "foo")):
++
++Error: `factor(levels = "bar")` must be a vector with type <factor<76c17>>.
++Instead, it has type <factor<54b1d>>.
++
++
++
++> vec_assert(factor(), chr()):
++
++Error: `factor()` must be a vector with type <character>.
++Instead, it has type <factor<>>.
++
++
++
++> vec_assert(lgl(), data.frame()):
++
++Error: `lgl()` must be a vector with type <data.frame<>>.
++Instead, it has type <logical>.
++
++
++
++> vec_assert(lgl(), data.frame(x = 1)):
++
++Error: `lgl()` must be a vector with type <data.frame<x:double>>.
++Instead, it has type <logical>.
++
++
++
++> vec_assert(lgl(), data.frame(x = 1, y = 2)):
++
++Error: `lgl()` must be a vector with type:
++
++  <data.frame<
++    x: double
++    y: double
++  >>
++
++Instead, it has type <logical>.
++
++
++
++> vec_assert(data.frame(), chr()):
++
++Error: `data.frame()` must be a vector with type <character>.
++Instead, it has type <data.frame<>>.
++
++
++
++> vec_assert(data.frame(x = 1), chr()):
++
++Error: `data.frame(x = 1)` must be a vector with type <character>.
++Instead, it has type <data.frame<x:double>>.
++
++
++
++> vec_assert(data.frame(x = 1), data.frame(x = "foo")):
++
++Error: `data.frame(x = 1)` must be a vector with type <data.frame<x:character>>.
++Instead, it has type <data.frame<x:double>>.
++
++
++
++> vec_assert(data.frame(x = 1), data.frame(x = "foo", y = 2)):
++
++Error: `data.frame(x = 1)` must be a vector with type:
++
++  <data.frame<
++    x: character
++    y: double
++  >>
++
++Instead, it has type <data.frame<x:double>>.
++
++
++
++> vec_assert(data.frame(x = 1, y = 2), chr()):
++
++Error: `data.frame(x = 1, y = 2)` must be a vector with type <character>.
++Instead, it has type:
++
++  <data.frame<
++    x: double
++    y: double
++  >>
++
++
++
++> vec_assert(data.frame(x = 1, y = 2), data.frame(x = "foo")):
++
++Error: `data.frame(x = 1, y = 2)` must be a vector with type <data.frame<x:character>>.
++Instead, it has type:
++
++  <data.frame<
++    x: double
++    y: double
++  >>
++
++
++
++> vec_assert(data.frame(x = 1, y = 2), data.frame(x = "foo", y = 2)):
++
++Error: `data.frame(x = 1, y = 2)` must be a vector with type:
++
++  <data.frame<
++    x: character
++    y: double
++  >>
++
++Instead, it has type:
++
++  <data.frame<
++    x: double
++    y: double
++  >>
++
++
++
+Index: r-cran-vctrs-0.3.8/tests/testthat/test-assert.R
+===================================================================
+--- r-cran-vctrs-0.3.8.orig/tests/testthat/test-assert.R
++++ r-cran-vctrs-0.3.8/tests/testthat/test-assert.R
+@@ -191,7 +191,14 @@ test_that("unspecified is finalised befo
+ })
+ 
+ test_that("assertion failures are explained", {
+-  expect_known_output(file = test_path("test-assert-explanations.txt"), {
++  if (.Platform$endian == "big") {
++    variant <- "-be"
++  } else {
++    variant <- ""
++  }
++  file <- paste("test-assert-explanations", variant, ".txt", sep = "")
++
++  expect_known_output(file = test_path(file), {
+     local_no_stringsAsFactors()
+     local_options(rlang_backtrace_on_error = "none")
+ 
diff -Nru r-cran-vctrs-0.3.8/debian/patches/series r-cran-vctrs-0.3.8/debian/patches/series
--- r-cran-vctrs-0.3.8/debian/patches/series	1969-12-31 16:00:00.000000000 -0800
+++ r-cran-vctrs-0.3.8/debian/patches/series	2021-11-17 15:29:20.000000000 -0800
@@ -0,0 +1 @@
+s390x-tests.patch


More information about the R-pkg-team mailing list