-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Summary
Some tests fail when running with Armadillo (and certain R/locale configurations) because error messages use Unicode smart quotes (‘ ’) instead of ASCII single quotes ('), causing strict expect_error(..., fixed = TRUE) comparisons to fail even though the correct error is thrown.
Failing Test Example
expect_error(
datashield.aggregate(conns = NULL, expr = calltext),
"unable to find an inherited method for function 'dsIsAsync' for signature 'conn = \"NULL\"'",
fixed = TRUE
)Observed failure:
- Expected:
'dsIsAsync' - Actual:
‘dsIsAsync’
Error message received:
unable to find an inherited method for function ‘dsIsAsync’ for signature ‘conn = "NULL"’
Root Cause
The difference is purely typographical:
- ASCII quotes:
' - Unicode smart quotes:
‘ ’
This variation depends on:
- R version
- system locale (e.g. UTF-8 vs C)
- platform/container environment
- upstream package message formatting (S4 dispatch errors)
Since the test uses fixed = TRUE, it performs an exact byte match and fails despite the semantic message being identical.
Why This Is Problematic
- Makes tests locale-dependent and non-portable
- Causes false negatives in CI and Docker environments
- Fails on systems that default to UTF-8 smart quotes
- The underlying functionality is correct, but the test is overly strict
Suggested Fix
Replace strict fixed-string matching with a more robust pattern, for example:
expect_error(
datashield.aggregate(conns = NULL, expr = calltext),
"dsIsAsync"
)or remove fixed = TRUE and match a stable substring.
Alternatively:
- Normalise quotes before comparison, or
- Avoid matching the full error string from S4 dispatch (which is not guaranteed to be stable across R builds)
Environment Where Observed
- Backend: ArmadilloDriver
- Docker-based test environment
- UTF-8 locale
- R producing Unicode curly quotes in S4 error messages
Workaround
Setting locale to C avoids the issue:
Sys.setlocale("LC_ALL", "C")However, tests should ideally be locale-agnostic rather than requiring environment-specific configuration.