Skip to content

Make Windows CI green: cross-platform path/regex/separator fixes (28 failures → 0)#65

Merged
thorwhalen merged 3 commits into
masterfrom
claude/windows-ci-portability
Jun 24, 2026
Merged

Make Windows CI green: cross-platform path/regex/separator fixes (28 failures → 0)#65
thorwhalen merged 3 commits into
masterfrom
claude/windows-ci-portability

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Brings dol's Windows CI from 28 failures to 0 (Linux/macOS were already green;
all fixes are no-ops or improvements there). Applies the cross-platform-Python
discipline: abstract over the OS, never hardcode separators, and never route a
path through regex-escaping (or a regex through path-escaping).

Regex ⟷ path conflation (the filter_regex bug class, finished off)

  • naming.py + paths.py: the path-template builders compiled their regexes
    (named capture groups) via safe_compile, which re.escapes on Windows and
    corrupted the groups. Reverted all 7 sites to re.compile (matches the historical
    note in naming.py).
  • naming.template_to_pattern: now re.escapes the literal template segments
    (a template that is/contains a real path has backslashes → re.error: incomplete escape \U). Mirrors KeyTemplate._compile_regex; also fixes a latent bug where a
    literal . matched any character.
  • util.safe_compile: documented as path-template-only (never for general
    regexes), with an OS-independent doctest.

POSIX-only API

  • filesys.py: os.getuid() (AttributeError on Windows) → cross-platform
    getpass.getuser() for the per-user temp dir.

Separators / empty paths

  • util.not_a_mac_junk_path: split on both separators (zip paths use /, but
    os.path.sep is \ on Windows, so __MACOSX was missed).
  • filesys.ensure_slash_suffix(""): keep an empty prefix empty — it was
    returning a bare separator, which prepended to absolute keys yields \C:\Users\...
    (invalid on Windows, OSError 22); e.g. Files("") in dol.misc.get_obj.
  • filesys.subfolder_stores: strip the native os.sep, not a hardcoded /
    (mixed-separator ...\folder1/ → KeyError on Windows).

Tests / doctests

  • Made platform-fragile doctests/tests OS-independent (process_path,
    mk_pattern_from_template_and_format_dict, test_process_path,
    test_subfolder_stores) — asserting behavior or os.path.join, not hand-counted
    backslashes or literal /.

Verification: Windows CI 400 passed, 0 failed (was 28 failed); macOS/Linux
full suite + doctests stay green (400 passed). Builds on #64 (the
filter_regex fix).

https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp

…eparator/encoding gotchas

Applies the cross-platform-python protocol to the remaining Windows-only failures
(all green on Linux/macOS, all failing on Windows):

- naming.py + paths.py: the path-template builders compiled their regexes (named
  capture groups) via safe_compile, which re.escape's on Windows and corrupted the
  groups (same bug class as the filter_regex fix). Reverted all 7 sites to
  re.compile; literal text + separators are already re.escape'd, so this is a valid
  regex on every OS. (Matches the historical note in naming.py.)
- filesys.py: replaced POSIX-only os.getuid() (AttributeError on Windows) with the
  cross-platform getpass.getuser() for the per-user temp dir.
- util.not_a_mac_junk_path: split on BOTH separators (zip paths use '/', but
  os.path.sep is '\\' on Windows, so '__MACOSX' was missed there).
- Made the platform-fragile doctests OS-independent (process_path, safe_compile);
  documented safe_compile as path-template-only (never for general regexes).

Mac/Linux: full suite + doctests stay green (400 passed).

Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
…-rootdir + test separators

- naming.template_to_pattern: regex-escape the LITERAL segments of a template (not
  just substitute fields). A template that is/contains a real path has backslashes
  on Windows; compiling them unescaped raised `re.error: incomplete escape \U`
  (FileSysCollection key patterns, mk_dirs, subfolder stores, etc.). This is the
  correct cross-platform fix (mirrors KeyTemplate._compile_regex); it also fixes a
  latent bug where a literal '.' matched any character.
- filesys.ensure_slash_suffix(''): keep an empty prefix empty. It was returning a
  bare separator, which prepended to absolute keys yields '\C:\Users\...' (invalid
  on Windows, OSError 22) -- e.g. Files("") in dol.misc.get_obj.
- test_process_path: build the temp path from components, not "foo/bar" (abspath
  normalizes '/'->'\\' on Windows, breaking the equality).
- mk_pattern_from_template_and_format_dict doctest: assert on matching behavior, not
  a hand-counted-backslash pattern string (was OS-fragile and internally inconsistent).

Mac/Linux: full suite + doctests green (400 passed).

Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
…Windows failure)

The affix codec stripped/added a literal "/" while the dir paths end with os.sep
('\\' on Windows), so stores["folder1"] built a mixed-separator inner key
'...\folder1/' -> KeyError on Windows. Strip os.path.sep instead. Also make the
test's expected Files key OS-agnostic (os.path.join, not "subfolder/apple.p").
No-ops on POSIX (os.sep == '/'); full suite stays green (400 passed).

Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
@thorwhalen thorwhalen merged commit 462f53c into master Jun 24, 2026
10 checks passed
@thorwhalen thorwhalen deleted the claude/windows-ci-portability branch June 24, 2026 07:17
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