# Windows

> Installing and running trimtest natively on Windows 10 and 11 (x64 and arm64), what it handles, and what to know about shims, line endings and long paths.

trimtest runs natively on Windows 10 and 11, x86_64 and arm64. Windows is supported alongside Linux and macOS: the
test suite runs on Windows in CI on every push, and the [soundness bench](/trust/soundness/) has been run there (9 repositories, 10 mutations each) with
no misses observed (`bench/RESULTS.md` in the repository). WSL also works and behaves exactly like Linux.

## Install

```powershell
# prebuilt binary: verifies the checksum, installs to %LOCALAPPDATA%\trimtest\bin and adds it to your PATH
irm https://raw.githubusercontent.com/RabinApps/trimtest/main/install.ps1 | iex
#   $env:TRIMTEST_VERSION = "v0.1.0" pins a release; $env:TRIMTEST_INSTALL_DIR changes the target

cargo install trimtest                 # from crates.io (needs the Rust toolchain and MSVC build tools)
cargo binstall trimtest                # prebuilt, if you use cargo-binstall
scoop install trimtest                 # once the Scoop bucket is published
winget install RabinApps.trimtest      # once the winget package is published
```

The zip archives and checksums are also on the [releases page](https://github.com/RabinApps/trimtest/releases).
Open a new terminal after installing so the updated PATH is picked up. PowerShell, `cmd.exe` and Git Bash all work.

## What trimtest does differently on Windows

- **Runners that are `.cmd` or `.bat` files.** `npx`, `pnpm`, `yarn`, `mvn`, `gradle`, `flutter` and `dart` are
  batch shims on Windows. trimtest looks programs up on `PATH` with `PATHEXT`, so these work without any
  configuration. `./gradlew` and `./mvnw` resolve to `gradlew.bat` and `mvnw.cmd` in the project. A project with only
  the `.bat` or `.cmd` wrapper is detected as having a wrapper.
- **Python.** `python3` is not normally present on Windows. trimtest uses the first of `python3`, `python` and `py`
  that actually runs (it skips the Microsoft Store stub that merely opens the Store). To force one, set
  `[runner] python = "py -3 -m"` or a path in [`trimtest.toml`](/reference/config/).
- **Paths.** Repository paths inside trimtest are always `/`-separated, whatever the OS. Reports from coverage
  tools (`C:\repo\a.py`, `file:///C:/repo/a.js`, UNC paths, `\\?\` prefixes, a different drive-letter case) are
  mapped back to the same repo-relative file. Backslashes in `trimtest.toml` paths and in `tsconfig.json`,
  `package.json`, `go.work` and `pubspec.yaml` are accepted.
- **Line endings.** A checkout with `core.autocrlf=true` (CRLF) selects exactly what an LF checkout does: line
  endings are normalised before files are fingerprinted, so a map recorded on one machine is valid on the other.
- **Timeouts.** `--timeout` and `--total-timeout` kill the whole process tree using a Windows Job Object, so a hung
  runner's children go with it.

## Things to know

- **Long paths.** Deep `node_modules` or `target` trees can exceed 260 characters. Enable them once:
  `git config --system core.longpaths true`, and turn on Windows long path support (registry key
  `LongPathsEnabled`, or Group Policy).
- **Antivirus and indexers.** Real-time scanners can briefly lock `.trimtest\map.json`. trimtest retries the write
  for about a second; exclude `.trimtest\` from scanning if you still see failures.
- **Symlinks and junctions.** Not required. You do not need Developer Mode.
- **Arguments through `.cmd` shims.** Windows batch files re-parse their arguments. trimtest passes test names
  through the shim unchanged, but a test path containing `%`, `^` or `"` can be rejected by Windows itself; rename
  the test file in that case.
- **Gradle and captured output.** Gradle's background daemon inherits the pipe a program's output is captured
  through and keeps it open after trimtest has finished. Anything that waits for the pipe to close (a script that
  reads trimtest's output to the end, or `trimtest run | tee log`) can then appear to hang. Run `gradle --stop`
  afterwards, or set `org.gradle.daemon=false` in `gradle.properties` for CI. Plain terminal use and GitHub
  Actions steps are not affected.
- **Untested toolchains.** Swift on Windows, Flutter/Dart and Zig have not been run on Windows. They use the same
  resolution rules and should work, but are not verified.

## GitHub Actions on Windows

```yaml
jobs:
  test:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6
        with: { fetch-depth: 0 }
      - name: Install trimtest
        run: irm https://raw.githubusercontent.com/RabinApps/trimtest/main/install.ps1 | iex
      # ...your toolchain setup here...
      - run: trimtest run --base origin/${{ github.base_ref }} --timeout 900
```

`install.ps1` adds trimtest to the PATH of the current step, so later lines in the same step can call it; use
`echo "$env:LOCALAPPDATA\trimtest\bin" >> $env:GITHUB_PATH` to make it available to later steps.
