Tests: the Discord mirror tests pass on Windows #3610

Merged
fromthemoonx merged 1 commit from upstream-pr/3610 into main 2026-12-03 05:53:16 +00:00
fromthemoonx commented 2026-12-01 19:27:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T19:27:56Z.


python -m unittest discover -s scripts -p "test_*.py", the run TESTING.md asks for on script changes, gives 8 errors on Windows on main 6bfb5c5. All are in test_discord_mirror, and CI does not see them because the mirror's workflow runs on ubuntu-latest:

  • 7 UnicodeEncodeError: 'charmap' codec can't encode character U+200B (zero-width space). The sync log prints the posts, whose @ escape is a zero-width space, and the Windows console encoding (cp1252) has no such character.
  • test_nothing_is_written_when_the_state_cannot_be_saved: FileNotFoundError: shell not found: neither %ComSpec% nor %SystemRoot% is set. setUp clears the whole environment, so the shell before_first_write runs cannot be found on Windows.

What is in it

  • scripts/test_discord_mirror.py (tests only): setUp keeps SYSTEMROOT / COMSPEC when they are set, and sends the log to an io.StringIO (no test reads it). scripts/discord_mirror.py is unchanged.

Tested

  • RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Python 3.12, rustc 1.100.0, debug.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 at 4a4ef436: 2904 passed, 0 failed, 51 ignored. SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same as main.
  • python -m unittest discover -s scripts -p "test_*.py": 66 tests OK (on main: 66 run, 8 errors, the ones above).
  • python -m unittest scripts/test_discord_mirror.py: OK 3 of 3 from Git Bash, once with PYTHONIOENCODING=utf-8, and once from Windows PowerShell 5.1.

Not tested

  • Linux / the GitHub Actions runner: not run here. The change only adds two variables to the test environment when they exist (not on Linux) and buffers stdout.

AI use

  • Claude Code (Claude Opus 5.5): found the errors while merge-checking #3456, wrote the change and this description, and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5592930949 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3610). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-01T19:27:56Z. --- `python -m unittest discover -s scripts -p "test_*.py"`, the run TESTING.md asks for on script changes, gives 8 errors on Windows on `main` `6bfb5c5`. All are in `test_discord_mirror`, and CI does not see them because the mirror's workflow runs on `ubuntu-latest`: - 7 `UnicodeEncodeError: 'charmap' codec can't encode character U+200B` (zero-width space). The sync log prints the posts, whose `@` escape is a zero-width space, and the Windows console encoding (cp1252) has no such character. - `test_nothing_is_written_when_the_state_cannot_be_saved`: `FileNotFoundError: shell not found: neither %ComSpec% nor %SystemRoot% is set`. `setUp` clears the whole environment, so the shell `before_first_write` runs cannot be found on Windows. **What is in it** - `scripts/test_discord_mirror.py` (tests only): `setUp` keeps `SYSTEMROOT` / `COMSPEC` when they are set, and sends the log to an `io.StringIO` (no test reads it). `scripts/discord_mirror.py` is unchanged. **Tested** - RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Python 3.12, rustc 1.100.0, debug. - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` at `4a4ef436`: 2904 passed, 0 failed, 51 ignored. SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same as `main`. - `python -m unittest discover -s scripts -p "test_*.py"`: 66 tests OK (on `main`: 66 run, 8 errors, the ones above). - `python -m unittest scripts/test_discord_mirror.py`: OK 3 of 3 from Git Bash, once with `PYTHONIOENCODING=utf-8`, and once from Windows PowerShell 5.1. **Not tested** - Linux / the GitHub Actions runner: not run here. The change only adds two variables to the test environment when they exist (not on Linux) and buffers stdout. **AI use** - Claude Code (Claude Opus 5.5): found the errors while merge-checking #3456, wrote the change and this description, and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-01 20:23:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:23:59Z.


Review (head 4a4ef436, diff read, not a merge-check):

No problems found in the diff. Checked that setUp in scripts/test_discord_mirror.py now keeps SYSTEMROOT / COMSPEC only when they are set, so the shell=True call in State.writing (scripts/discord_mirror.py ~333) can find cmd.exe, and that log() (~52) looks up sys.stdout on every call, so the io.StringIO patch catches the U+200B text from escape (~114); no test asserts on that output.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7324617621 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3610#issuecomment-7324617621). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T20:23:59Z. --- Review (head 4a4ef436, diff read, not a merge-check): No problems found in the diff. Checked that `setUp` in `scripts/test_discord_mirror.py` now keeps `SYSTEMROOT` / `COMSPEC` only when they are set, so the `shell=True` call in `State.writing` (`scripts/discord_mirror.py` ~333) can find `cmd.exe`, and that `log()` (~52) looks up `sys.stdout` on every call, so the `io.StringIO` patch catches the U+200B text from `escape` (~114); no test asserts on that output. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Decodere commented 2026-12-02 08:57:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:57:26Z.


merge-check
base: 1c8b551475
head: 4a4ef436ef
merge: clean (git merge --no-edit onto 1c8b5514, git diff --check clean; scripts/test_discord_mirror.py +4/-1)
build: not run (Tier 0 Python script-test diff touching only scripts/test_discord_mirror.py; no Rust code changed)
tests: python -m unittest -v scripts/test_discord_mirror.py -> 10 passed, 0 failed (on clean base 1c8b5514: 9 passed, 1 error: FileNotFoundError: shell not found: neither %ComSpec% nor %SystemRoot% is set); python -m unittest discover -s scripts -p "test_*.py" -> 66 passed, 0 failed (base: 65 passed, 1 error). Rust workspace tests not run (Tier 0).
review: Read the full diff (scripts/test_discord_mirror.py:71-74, +4/-1). Preserving SYSTEMROOT and COMSPEC only when present in os.environ keeps shell=True working on Windows while remaining a no-op on POSIX, and patching sys.stdout to io.StringIO() avoids Windows console code-page encoding errors during test output. Clean, minimal, no regressions.
performance: none (test-only change in scripts/; zero runtime impact)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Python 3.15.2, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7340160596 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3610#issuecomment-7340160596). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T08:57:26Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 4a4ef436ef5fb987ed91728c64eea8fc1168da6f merge: clean (`git merge --no-edit` onto `1c8b5514`, `git diff --check` clean; `scripts/test_discord_mirror.py` +4/-1) build: not run (Tier 0 Python script-test diff touching only `scripts/test_discord_mirror.py`; no Rust code changed) tests: `python -m unittest -v scripts/test_discord_mirror.py` -> 10 passed, 0 failed (on clean base `1c8b5514`: 9 passed, 1 error: `FileNotFoundError: shell not found: neither %ComSpec% nor %SystemRoot% is set`); `python -m unittest discover -s scripts -p "test_*.py"` -> 66 passed, 0 failed (base: 65 passed, 1 error). Rust workspace tests not run (Tier 0). review: Read the full diff (`scripts/test_discord_mirror.py:71-74`, +4/-1). Preserving `SYSTEMROOT` and `COMSPEC` only when present in `os.environ` keeps `shell=True` working on Windows while remaining a no-op on POSIX, and patching `sys.stdout` to `io.StringIO()` avoids Windows console code-page encoding errors during test output. Clean, minimal, no regressions. performance: none (test-only change in `scripts/`; zero runtime impact) verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Python 3.15.2, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
bmjask commented 2026-12-02 15:52:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:52:10Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7351061646 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3610#issuecomment-7351061646). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:52:10Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
grathepic commented 2026-12-03 02:01:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by grathepic on 2026-12-03T02:01:05Z.


merge-check
base: 078358a058
head: 4a4ef436ef
merge: clean (git diff --check exit 0)
build: not needed (Tier 0 Python script test change; no Rust files touched)
tests: on unmerged base 078358a0 with PYTHONIOENCODING=cp1252: test_discord_mirror.py -> 2 passed, 8 errors (7 UnicodeEncodeError on \u200b + 1 FileNotFoundError in test_nothing_is_written_when_the_state_cannot_be_saved). On merged tree: PYTHONIOENCODING=cp1252 python -m unittest discover -s scripts -p "test_discord_mirror.py" -v -> 10 passed, 0 failed; python -m unittest discover -s scripts -p "test_*.py" -v -> 85 passed, 0 failed. Rust workspace suite not run (Tier 0).
title run: none (Tier 0 script-test change)
review: Read full diff (scripts/test_discord_mirror.py, +4/-1) and verified the surrounding test file and scripts/discord_mirror.py. No findings. io is already imported; preserving SYSTEMROOT and COMSPEC only when set in os.environ lets subprocess.run(..., shell=True) resolve cmd.exe on Windows while remaining a no-op on POSIX; patching sys.stdout to io.StringIO() catches log()'s print(..., flush=True) without affecting any assertions (no test reads stdout); scripts/discord_mirror.py is unchanged. All CI checks are green. Not tested: Linux runner (no-op there since those env vars are unset).
performance: none (test-only change in scripts/)
verdict: safe to merge
hardware / tool and model: AMD Ryzen 7 5800X3D, Windows 11 (10.0.26300.0), Python 3.12.3 / Antigravity, Gemini 4 Neon

<!-- greyfinch-sync:ivall/xcl:comment:7364991796 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3610#issuecomment-7364991796). Originally posted by [grathepic](https://github.com/grathepic) on 2026-12-03T02:01:05Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 4a4ef436ef5fb987ed91728c64eea8fc1168da6f merge: clean (`git diff --check` exit 0) build: not needed (Tier 0 Python script test change; no Rust files touched) tests: on unmerged base `078358a0` with `PYTHONIOENCODING=cp1252`: `test_discord_mirror.py` -> 2 passed, 8 errors (7 `UnicodeEncodeError` on `\u200b` + 1 `FileNotFoundError` in `test_nothing_is_written_when_the_state_cannot_be_saved`). On merged tree: `PYTHONIOENCODING=cp1252` `python -m unittest discover -s scripts -p "test_discord_mirror.py" -v` -> 10 passed, 0 failed; `python -m unittest discover -s scripts -p "test_*.py" -v` -> 85 passed, 0 failed. Rust workspace suite not run (Tier 0). title run: none (Tier 0 script-test change) review: Read full diff (`scripts/test_discord_mirror.py`, +4/-1) and verified the surrounding test file and `scripts/discord_mirror.py`. No findings. `io` is already imported; preserving `SYSTEMROOT` and `COMSPEC` only when set in `os.environ` lets `subprocess.run(..., shell=True)` resolve `cmd.exe` on Windows while remaining a no-op on POSIX; patching `sys.stdout` to `io.StringIO()` catches `log()`'s `print(..., flush=True)` without affecting any assertions (no test reads stdout); `scripts/discord_mirror.py` is unchanged. All CI checks are green. Not tested: Linux runner (no-op there since those env vars are unset). performance: none (test-only change in `scripts/`) verdict: safe to merge hardware / tool and model: AMD Ryzen 7 5800X3D, Windows 11 (10.0.26300.0), Python 3.12.3 / Antigravity, Gemini 4 Neon
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3610
No description provided.