Skip to content

Commit 1620efa

Browse files
branchseerclaudehappy-otter
committed
docs: add cross-platform testing requirements to CLAUDE.md
- Document critical requirement: no platform skipping - Add cargo xtest command for Windows cross-compilation testing - Include cross-platform test design patterns - Reference vite_pty::resize_terminal as example implementation - Add cross-platform requirements to Code Constraints section This establishes clear guidelines that all features must work on both Unix and Windows, with proper testing on both platforms. Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
1 parent 8959d12 commit 1620efa

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ Test fixtures and snapshots:
3838
- resolved program paths, cwd, and env vars
3939
- **E2E**: `crates/vite_task_bin/tests/e2e_snapshots/fixtures/` - needed for testing execution and beyond: caching, output styling
4040

41+
### Cross-Platform Testing
42+
43+
**CRITICAL**: This project must work on both Unix (macOS/Linux) and Windows. For any cross-platform features:
44+
45+
1. **No Platform Skipping**: Skipping tests on either platform is **UNACCEPTABLE**
46+
- Use `#[cfg(unix)]` and `#[cfg(windows)]` for platform-specific code within tests
47+
- Both platforms must execute the test and verify the feature works correctly
48+
- If a feature can't work on a platform, it shouldn't be added
49+
50+
2. **Windows Cross-Testing from macOS**:
51+
```bash
52+
# Test on Windows (aarch64) from macOS via cross-compilation
53+
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p <package> --test <test>
54+
55+
# Examples:
56+
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p vite_pty --test terminal
57+
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p vite_pty --test terminal -- resize_terminal
58+
```
59+
60+
3. **Cross-Platform Test Design Patterns**:
61+
- Use conditional compilation for platform-specific setup/assertions
62+
- Use cross-platform libraries for common operations (e.g., `terminal_size` for terminal dimensions)
63+
- Verify platform-specific behavior works as expected:
64+
- **Unix**: SIGWINCH signals, ioctl, /dev/null, etc.
65+
- **Windows**: ConPTY, GetConsoleScreenBufferInfo, NUL, etc.
66+
67+
4. **Example**: The `vite_pty::resize_terminal` test demonstrates proper cross-platform testing:
68+
- Unix: Installs SIGWINCH handler to verify signal delivery
69+
- Windows: Acknowledges synchronous ConPTY resize behavior
70+
- Both: Query terminal size using cross-platform `terminal_size` crate
71+
- Both: Verify resize actually works and returns correct dimensions
72+
4173
## CLI Usage
4274

4375
```bash
@@ -102,6 +134,8 @@ just lint-windows # Windows via cargo-xwin
102134

103135
## Code Constraints
104136

137+
### Required Patterns
138+
105139
These patterns are enforced by `.clippy.toml`:
106140

107141
| Instead of | Use |
@@ -113,6 +147,15 @@ These patterns are enforced by `.clippy.toml`:
113147
| `std::env::current_dir` | `vite_path::current_dir` |
114148
| `.to_lowercase()`/`.to_uppercase()` | `cow_utils` methods |
115149

150+
### Cross-Platform Requirements
151+
152+
**All code must work on both Unix and Windows without platform skipping:**
153+
154+
- Use `#[cfg(unix)]` / `#[cfg(windows)]` for platform-specific implementations
155+
- Always test on both platforms (use `cargo xtest` for Windows cross-compilation)
156+
- Platform differences should be handled gracefully, not skipped
157+
- Document platform-specific behavior in code comments
158+
116159
## Path Type System
117160

118161
- **Type Safety**: All paths use typed `vite_path` instead of `std::path`

0 commit comments

Comments
 (0)