Platform support

Version 0.2.0 Updated Nov 27, 2025

CmdMox supports Linux, macOS and Windows. Shims are generated as POSIX symlinks on Unix-like systems and as .cmd launchers on Windows so that CreateProcess resolves them via PATHEXT. The batch launchers embed the active Python interpreter and forward all arguments to the shared shim.py, so no additional wrappers or entry points are required.

When CmdMox enters replay mode on Windows it ensures .CMD is present in the effective PATHEXT value, even if developers customised their shell to omit the extension. The generated launchers always emit CRLF line endings and escape carets/percent signs so the Windows command processor parses them consistently with native batch scripts, even when arguments or installation paths include spaces and other metacharacters. CmdMox also filters duplicate command names on case-insensitive filesystems so two mocks whose names only differ by casing cannot trample each other's shim files. At runtime the shim collapses doubled carets (^^) in Windows arguments into single carets so multi-layer batch escaping does not leak into IPC payloads. Arguments that genuinely need repeated carets will therefore reach the server with a single literal caret.

Deeply nested workspaces can easily exceed the traditional MAX_PATH limit on Windows. The environment manager now asks the filesystem for a short (8.3) alias whenever the shim directory path would overflow the limit, ensuring shims remain invokable while still cleaning up the real directory afterwards. PATH filtering honours the underlying filesystem semantics too, so variations in casing no longer leave behind duplicate entries when passthrough spies merge their lookup paths.

Importing :mod:cmd_mox.shim no longer mutates sys.path or sys.modules. The bootstrap that prefers stdlib modules over editable installs runs only when the shim entrypoint executes. When shim helpers are reused directly, cmd_mox._shim_bootstrap.bootstrap_shim_path() should be called during setup first.

When you need to make an explicit decision in a test module (for instance when using the context manager API), import the helper re-exported from the package:

from cmd_mox import skip_if_unsupported

skip_if_unsupported()

skip_if_unsupported defers to pytest.skip on unsupported platforms. If you only need to gate a code path, cmd_mox.is_supported_platform() returns a boolean instead. Advanced tests can override the detected platform by setting the CMD_MOX_PLATFORM_OVERRIDE environment variable, which is primarily useful for simulating alternative environments inside CI pipelines (for example to exercise Windows-specific shims from a Linux runner).

The cmd-mox test suite also uses the pytest.mark.requires_unix_sockets marker for scenarios that need to bind a Unix domain socket. Marking these tests keeps them green on platforms (or CI sandboxes) that disallow Unix sockets entirely.