Skip to content

fix(coverage): match --include and --exclude against decoded paths - #37128

Open
Hixie wants to merge 2 commits into
denoland:mainfrom
Hixie:fix-coverage-filter-decoded-url
Open

Hixie wants to merge 2 commits into
denoland:mainfrom
Hixie:fix-coverage-filter-decoded-url

Conversation

@Hixie

@Hixie Hixie commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Disclaimer: I am an AI (Claude Opus 5.5, made by Anthropic). I wrote this change, its test, and this message while working for a human developer, who is submitting it.

PROBLEM

deno coverage --include and --exclude test each pattern against the script's URL as V8 reports it. That URL is percent-encoded, so a file whose path contains a space or any non-ASCII character can only be matched by writing the escapes into the pattern:

$ deno test --coverage=cov  # covers wt 🦆/mod.ts and plain/mod.ts
$ deno coverage cov --include='wt 🦆'
error: No covered files included in the report
$ deno coverage cov --exclude='wt 🦆'  # excludes nothing
$ deno coverage cov --exclude='wt%20%F0%9F%A6%86'  # works

SOLUTION

A pattern now matches a script when it matches either the URL or the URL with its percent-escapes decoded. A pattern that names a directory the way the file system spells it therefore matches. Every pattern that matched before still matches, including the default ^file: and any pattern written against the escaped form.

A spec test covers both flags, with a pattern spelled as on disk and with one spelled with escapes.

Fixes #37127

Hixie and others added 2 commits November 4, 2026 14:00
Disclaimer: I am an AI (Claude Opus 5.5, made by Anthropic). I wrote
this change, its test, and this message while working for a human
developer, who is submitting it.

PROBLEM

`deno coverage --include` and `--exclude` test each pattern against the
script's URL as V8 reports it. That URL is percent-encoded, so a file
whose path contains a space or any non-ASCII character can only be
matched by writing the escapes into the pattern:

    $ deno test --coverage=cov  # covers wt 🦆/mod.ts and plain/mod.ts
    $ deno coverage cov --include='wt 🦆'
    error: No covered files included in the report
    $ deno coverage cov --exclude='wt 🦆'  # excludes nothing
    $ deno coverage cov --exclude='wt%20%F0%9F%A6%86'  # works

SOLUTION

A pattern now matches a script when it matches either the URL or the URL
with its percent-escapes decoded. A pattern that names a directory the
way the file system spells it therefore matches. Every pattern that
matched before still matches, including the default `^file:` and any
pattern written against the escaped form.

A spec test covers both flags, with a pattern spelled as on disk and
with one spelled with escapes.

Fixes denoland#37127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The filter test checked an escaped pattern only with --exclude. It now
checks --include the same way, so both flags are tested against the URL
as well as against its decoded form.

Disclaimer: I am an AI (Claude Opus 5.5, made by Anthropic).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NetOpWibby pushed a commit to theende/ende that referenced this pull request Nov 7, 2026
`coverage --include` and `--exclude` matched each pattern against the
script URL, which is percent-encoded. A file whose path has a space or
a non-ASCII character could only be matched by writing the escapes into
the pattern. A pattern now matches if it matches either the URL or the
URL with its escapes decoded, so every pattern that matched before
still does.

Squashed: the PR's second commit adds the test steps that spell the
pattern with escapes.

(cherry picked from commit cbb96e1525e476070516ff453fee6c883f7dfedb and 53cf966c0c0b77520680fac3457870519108e51e)

Upstream: denoland/deno#37128

This branch has not been deployed

No deployments
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.

deno coverage --include and --exclude do not match paths containing spaces or non-ASCII characters

1 participant