Skip to content

Enable the R test suite on Windows (test runner + fixes) - #18069

Merged
gtritchie merged 5 commits into
mainfrom
developer/windows-test-runner-scopes
Jun 25, 2026
Merged

gtritchie merged 5 commits into
mainfrom
developer/windows-test-runner-scopes

Conversation

@gtritchie

@gtritchie gtritchie commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Summary

First step towards solving #17825.

Brings the Windows test runner (src/cpp/rstudio-tests.bat) to parity with the Unix
runner so the same test categories can run in CI, and fixes the issues that surfaced
once the R (testthat) suite actually ran on Windows.

Test runner

  • Rewrite rstudio-tests.bat.in to use the same --scope (core / rserver /
    rsession / r) and --filter interface as rstudio-tests.in. core runs core +
    shared_core (+ server_core when built); rserver is skipped when its binary is not
    built (desktop builds); the new r scope runs the testthat suite. --filter implies
    --scope r. With no arguments, all scopes run.
  • Propagate failures. The batch previously ignored exit codes and always returned 0. It
    now records each suite's exit code (and the testthat failure count for the r scope),
    runs every requested scope, and exits non-zero if any failed.
  • Set the R environment (R_HOME / R_DOC_DIR / R_LIB_DIR) and a fresh temporary
    RSTUDIO_DATA_HOME / RSTUDIO_CONFIG_HOME for the r scope.
  • Jenkinsfile.windows: update the call to rstudio-tests.bat --scope core.

Session changes (required for the R suite to run and pass on Windows)

  • Headless --run-script no longer prompts to save the workspace. On Windows, R's native
    cleanup runs at script end and showed a modal "Save workspace image?" dialog, which
    hangs an unattended/CI run. A headless script run now resolves the save action to
    no-save (saveWorkspaceAction).
  • Theme directory environment variables are read from the live process environment.
    SessionThemes.cpp used std::getenv, which on Windows does not observe Sys.setenv
    from a running R session, so the theme tests' RS_THEME_*_HOME redirection was ignored
    and installs/discovery used the real default directories. Switched to
    core::system::getenv (equivalent on POSIX; reads the live Win32 environment on
    Windows).

Test changes (Windows-only; other platforms unchanged)

  • test-files.R: in a non-UTF-8 (CP1252) Windows session, base R reports non-ASCII names
    in a different encoding and cannot enumerate them, while the RStudio hooks can and differ
    only in path-separator style. On Windows the comparison now normalizes encoding and
    separators and excludes non-ASCII names (base R cannot list them), and separately asserts
    that the hooks do list the non-ASCII entries base R misses. Non-Windows keeps the strict
    comparison.
  • test-themes.R: skip the two POSIX file-permission tests on Windows, where
    Sys.chmod("0555") does not deny writes so the expected error is never raised.

Verification

On Windows: core and rsession pass; --scope r runs 3715 testthat assertions with
no failures or warnings; the full no-argument run exits 0. Failure propagation was
confirmed: a failing suite prints a diagnostic to stderr and the run exits 1 while still
running the remaining suites.

This is a developer / CI tooling change and is not associated with a GitHub issue.

@gtritchie gtritchie added this to the 2026.07 (Pacific Dogwood) milestone Jun 25, 2026
@gtritchie
gtritchie requested a review from kevinushey June 25, 2026 20:25
Comment on lines +81 to +99
# On Windows the dev/test session runs in a non-UTF-8 (CP1252) locale. There,
# base R and our hooks report non-ASCII names with different encodings, our
# hooks differ only cosmetically in path separators (mixed '\' and '/' and
# redundant slashes), and -- most importantly -- base R cannot enumerate
# non-ASCII names at all while our hooks (wide Win32 API) can. So on Windows
# we normalize encoding and separators and drop non-ASCII names before
# comparing; the assertion after the loops confirms the hooks DO surface the
# non-ASCII entries base R misses. Every other platform keeps the strict
# comparison.
normalizeListing <- function(x) {
if (!.rs.platform.isWindows)
return(x)
x <- enc2utf8(x)
x <- chartr("\\", "/", x)
x <- gsub("/+", "/", x)
x <- x[!grepl("[^\x01-\x7f]", x)]
sort(x)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: R 4.2 and newer should default to a UTF-8 locale, so this block is probably only necessary for older R, or if the locale explicitly seems to be non-UTF-8.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also fine to leave as is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using 4.6.0 and for whatever reason it was not using utf8, but a codepage. 🤷‍♂️

@github-actions

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
402 0 18 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit 2e46c7d9c7704fd14d9d72e4e7f127e261d721b6 · Run #186

@github-actions

Copy link
Copy Markdown

🪟 Windows Desktop E2E · Server 2025 x64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
409 0 13 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · Windows Server 2025 x64 · commit 2e46c7d9c7704fd14d9d72e4e7f127e261d721b6 · Run #186

@gtritchie
gtritchie merged commit d6d7cf6 into main Jun 25, 2026
15 checks passed
@gtritchie
gtritchie deleted the developer/windows-test-runner-scopes branch June 25, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants