Skip to content

Accommodate NA behavior on arm64/aarch64 for Linux as well #1379

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

Merged
merged 6 commits into from
May 5, 2025
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
38 changes: 38 additions & 0 deletions .github/workflows/linuxarm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Run CI for R using https://eddelbuettel.github.io/r-ci/

name: linuxarm

on:
#push:
#pull_request:
workflow_dispatch:

env:
_R_CHECK_FORCE_SUGGESTS_: "false"

jobs:
ci:
strategy:
matrix:
include:
#- {os: ubuntu-latest}
- {os: ubuntu-24.04-arm}

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: eddelbuettel/github-actions/r-ci@master

- name: Dependencies
run: ./run.sh install_deps

- name: Test
run: ./run.sh run_tests

#- name: Coverage
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: ./run.sh coverage
1 change: 1 addition & 0 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- {os: macos-latest}
- {os: macos-13}
#- {os: ubuntu-latest}
#- {os: ubuntu-24.04-arm}

runs-on: ${{ matrix.os }}

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2025-05-05 Dirk Eddelbuettel <[email protected]>

* inst/tinytest/test_sugar.R: Condition four NA-related tests away on
arm64 on Linux too

* .github/workflows/linuxarm.yaml (jobs): Add ubuntu-24.04-arm as
optional workflow_dispatch run

2025-04-15 Dirk Eddelbuettel <[email protected]>

* docker/ci-4.4/Dockerfile: Added based on r-base:4.4.3
Expand Down
2 changes: 2 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
\itemize{
\item \code{Rcpp.package.skeleton()} creates \sQuote{URL} and
\sQuote{BugReports} if given a GitHub username (Dirk in \ghpr{1358})
\item Tests involving NA propagation are skipped under linux-arm64 as
they are under macos-arm (Dirk in \ghpr{1379} closing \ghit{1378})
}
}
}
Expand Down
25 changes: 13 additions & 12 deletions inst/tinytest/test_sugar.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

## Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois
## Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
## Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
##
## This file is part of Rcpp.
Expand All @@ -23,7 +23,8 @@ Rcpp::sourceCpp("cpp/sugar.cpp")

## There are some (documented, see https://blog.r-project.org/2020/11/02/will-r-work-on-apple-silicon/index.html)
## issues with NA propagation on arm64 / macOS. We not (yet ?) do anything special so we just skip some tests
isArmMacOs <- Sys.info()[["sysname"]] == "Darwin" && Sys.info()[["machine"]] == "arm64"
## This also seems to hit arm64 on Linux (aka 'aarch64' here)
isArm <- Sys.info()[["machine"]] == "arm64" || Sys.info()[["machine"]] == "aarch64"

## Needed for a change in R 3.6.0 reducing a bias in very large samples
suppressWarnings(RNGversion("3.5.0"))
Expand All @@ -36,8 +37,8 @@ expect_equal( runit_abs(x,y) , list( abs(x), abs(y) ) )
# test.sugar.all.one.less <- function( ){
expect_true( runit_all_one_less( 1 ) )
expect_true( ! runit_all_one_less( 1:10 ) )
if (!isArmMacOs) expect_true( is.na( runit_all_one_less( NA ) ) )
if (!isArmMacOs) expect_true( is.na( runit_all_one_less( c( NA, 1) ) ) )
if (!isArm) expect_true( is.na( runit_all_one_less( NA ) ) )
if (!isArm) expect_true( is.na( runit_all_one_less( c( NA, 1) ) ) )
expect_true( ! runit_all_one_less( c( 6, NA) ) )


Expand All @@ -46,14 +47,14 @@ expect_true( ! runit_all_one_greater( 1 ) )
expect_true( ! runit_all_one_greater( 1:10 ) )
expect_true( runit_all_one_greater( 6:10 ) )
expect_true( ! runit_all_one_greater( c(NA, 1) ) )
if (!isArmMacOs) expect_true( is.na( runit_all_one_greater( c(NA, 6) ) ) )
if (!isArm) expect_true( is.na( runit_all_one_greater( c(NA, 6) ) ) )


# test.sugar.all.one.less.or.equal <- function( ){
expect_true( runit_all_one_less_or_equal( 1 ) )
expect_true( ! runit_all_one_less_or_equal( 1:10 ) )
if (!isArmMacOs) expect_true( is.na( runit_all_one_less_or_equal( NA ) ) )
if (!isArmMacOs) expect_true( is.na( runit_all_one_less_or_equal( c( NA, 1) ) ) )
if (!isArm) expect_true( is.na( runit_all_one_less_or_equal( NA ) ) )
if (!isArm) expect_true( is.na( runit_all_one_less_or_equal( c( NA, 1) ) ) )
expect_true( ! runit_all_one_less_or_equal( c( 6, NA) ) )
expect_true( runit_all_one_less_or_equal( 5 ) )

Expand All @@ -66,15 +67,15 @@ expect_true( ! fx( 1:10 ) )
expect_true( fx( 6:10 ) )
expect_true( fx( 5 ) )
expect_true( ! fx( c(NA, 1) ) )
if (!isArmMacOs) expect_true( is.na( fx( c(NA, 6) ) ) )
if (!isArm) expect_true( is.na( fx( c(NA, 6) ) ) )


# test.sugar.all.one.equal <- function( ){
fx <- runit_all_one_equal
expect_true( ! fx( 1 ) )
expect_true( ! fx( 1:2 ) )
expect_true( fx( rep(5,4) ) )
if (!isArmMacOs) expect_true( is.na( fx( c(5,NA) ) ) )
if (!isArm) expect_true( is.na( fx( c(5,NA) ) ) )
expect_true(! fx( c(NA, 1) ) )


Expand All @@ -83,7 +84,7 @@ fx <- runit_all_not_equal_one
expect_true( fx( 1 ) )
expect_true( fx( 1:2 ) )
expect_true( ! fx( 5 ) )
if (!isArmMacOs) expect_true( is.na( fx( c(NA, 1) ) ) )
if (!isArm) expect_true( is.na( fx( c(NA, 1) ) ) )
expect_true( ! fx( c(NA, 5) ) )


Expand Down Expand Up @@ -1620,8 +1621,8 @@ expect_error(strimws(x[1], "invalid"), info = "strimws -- bad `which` argument")
## min/max
# test.sugar.min.max <- function() {
## min(empty) gives NA for integer, Inf for numeric (#844)
if (!isArmMacOs) expect_true(is.na(intmin(integer(0))), "min(integer(0))")
if (!isArmMacOs) expect_equal(doublemin(numeric(0)), Inf, info = "min(numeric(0))")
if (!isArm) expect_true(is.na(intmin(integer(0))), "min(integer(0))")
if (!isArm) expect_equal(doublemin(numeric(0)), Inf, info = "min(numeric(0))")

## max(empty_ gives NA for integer, Inf for numeric (#844)
expect_true(is.na(intmax(integer(0))), "max(integer(0))")
Expand Down