Skip to content

Normalize cargo registry paths for any registry source#331

Open
devjgm wants to merge 1 commit into
dtolnay:masterfrom
devjgm:greg/trybuild-custom-registry-normalization
Open

Normalize cargo registry paths for any registry source#331
devjgm wants to merge 1 commit into
dtolnay:masterfrom
devjgm:greg/trybuild-custom-registry-normalization

Conversation

@devjgm
Copy link
Copy Markdown

@devjgm devjgm commented May 23, 2026

Adds support for caching proxies and other custom registries used as crates-io replacements. Previously, only github.com- and index.crates.io- source directories were normalized to $CARGO; any other registry host caused raw paths to appear in snapshot comparisons, making it difficult to maintain "snapshot" tests using trybuild that work on a developers local machine (using crates.io) and in a docker container in CI that's pointed at a caching proxy of crates.io.

Extracts a normalize_cargo_registry helper that matches any registry source directory of the form /registry/src/{name}-{16-hex-chars}.

Extract a `normalize_cargo_registry` function that matches any cargo
registry source path of the form:

    .../registry/src/{name}-{16-hex-chars}/...

replacing the prefix up to and including the hash with `$CARGO`.

Previously the `CargoRegistry` normalization only recognized
`github.com-` and `index.crates.io-` as registry source directories,
causing custom registries (CDN mirrors, private registries, etc.) to
appear un-normalized in snapshot comparisons.

Using `rfind('-')` on the directory name segment correctly handles
registry hostnames that themselves contain hyphens.
@devjgm

This comment was marked as outdated.

@devjgm devjgm closed this May 23, 2026
@devjgm devjgm reopened this May 23, 2026
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