Skip to content

Tests on Windows: test:changed runs, and the RTP tests stay out of APPDATA - #104

Open
Xehanort88 wants to merge 1 commit into
Psychronic-Games:mainfrom
Xehanort88:fix/windows-test-runner
Open

Xehanort88 wants to merge 1 commit into
Psychronic-Games:mainfrom
Xehanort88:fix/windows-test-runner

Conversation

@Xehanort88

Copy link
Copy Markdown
Contributor

Two test-harness problems on Windows. No product code changes.

npm run test:changed could not start on Windows

editor/tests/run-tier.cjs failed before running a single test, for two reasons:

  • The time reporter was named by a bare path. --test-reporter=D:\…\file-times-reporter.mjs is loaded as an ES module, and Node reads D: as a URL scheme: ERR_UNSUPPORTED_ESM_URL_SCHEME. It is now pathToFileURL(…).href, which Node accepts on every platform.
  • A whole run's file list did not fit on one command line. 1,046 test files exceed Windows' 32,767-character limit: spawnSync … ENAMETOOLONG. A list that does not fit now runs in batches, one after another, with the same flags each time. Passes go to the same journal and are read once at the end, and each batch's times are merged as it ends (the next batch writes over the file; --measure gets the merged set). Where the list fits, which is any list on Linux, it is one process as before. The limit is 30,000 on win32 (room for quoting), unlimited elsewhere.

Exit status is the first non-zero batch's status, else 0.

The RTP tests wrote into the real %APPDATA%

legacy-rtp-archives and legacy-rtp-title redirected HOME and XDG_DATA_HOME, but RtpManager.downloadFolder uses APPDATA on win32 (src/legacy/RtpManager.js:30). So every Windows run unpacked fixture RTPs (1-byte files) into the user's real %APPDATA%\RPG Reactor\RTP, where the editor then lists them as installed RTPs. The four tests that assert XDG paths also failed on Windows, the leaked folders making two of them fail a second way (a "none found" case found the leaked one).

New tests/helpers/user-folders.cjs, userFoldersIn(root), points HOME, XDG_DATA_HOME and APPDATA into the test's own folder and clears RPG2K_RTP_PATH / RPG2K3_RTP_PATH, returning the undo. The five tests that set these by hand use it. The expected folders now come from RM.downloadFolder(...) (XDG on Linux, APPDATA on Windows, HOME/Library on macOS) instead of the Linux layout, and the archive test asserts the folder is inside the test's root.

Verification (Windows 11, Git Bash, Node 24.14)

  • legacy-rtp-archives, legacy-rtp-title, test-tiers: 24 tests, 23 pass, 1 skipped (the existing skip when no real RTP installer is at hand), 0 fail. Before: 4 failures. The existing leaked folders in %APPDATA%\RPG Reactor\RTP kept their timestamps through the run; before, each run rewrote them.
  • tests-run-anywhere: passes.
  • npm run test:changed -- --only=legacy-rtp --limit=3 runs and records its passes, which it could not do before. Two new test-tiers tests: the batching keeps every file once, in order, each batch within the limit, one batch with no limit; and the reporter is named by a file URL.
  • With the reporter fix alone applied by hand, a whole test:changed on Windows ran all 1,046 files in --limit=270 slices.

Limits

  • The batching was not run against a full list in one call on Windows, only through its unit test and the sliced runs above. Not run on Linux or macOS; there the list always fits, so the code path is the old one, with the reporter named by a file URL.
  • Already-leaked RTP folders are not removed: they are in the user's own data, and deleting them is the user's call.

🤖 Generated with Claude Code

…PDATA

run-tier.cjs could not start a run on Windows. It named the time reporter
by a bare path, which Node loads as an ES module URL and refuses for a
drive letter (ERR_UNSUPPORTED_ESM_URL_SCHEME); it is now a file URL. A
whole run's list of 1,046 files was also too long for one Windows command
line (ENAMETOOLONG); a list that does not fit now runs in batches one
after another, each with the same flags, passes read from the shared
journal once at the end and times merged as each batch ends. Where the
list fits (any list on Linux) it is one process, as before.

legacy-rtp-archives and legacy-rtp-title redirected HOME and
XDG_DATA_HOME but not APPDATA, which is where downloadFolder keeps an RTP
on Windows. Every Windows run unpacked fixture RTPs into the real
%APPDATA%\RPG Reactor\RTP, and the editor then listed them as installed
RTPs. tests/helpers/user-folders.cjs points all three into the test's own
folder, and the expected folders come from downloadFolder instead of the
Linux layout. The four tests that failed on Windows for this now pass.

test-tiers: the batching (every file once, in order, each batch within the
limit) and the reporter URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant