Skip to content

Commit

Permalink
test: only include relative paths in coverage
Browse files Browse the repository at this point in the history
All of our source files are reported with filenames starting with `../` so check for that before treating a file as ours.

esbuild recently improved its support for URLs in sourcemaps and now
some of them (`webpack://` ones) are about to start showing up in our
source maps, which will cause trouble (because the files don't exist).
  • Loading branch information
allisonkarlitskaya committed Feb 11, 2025
1 parent bb618e3 commit 706122f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/common/lcov.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ def parse_sourcemap(f, line_starts, dir_name):

our_sources = set()
for s in sources:
if "node_modules" not in s and (s.endswith(('.js', '.jsx', '.ts', '.tsx'))):
our_sources.add(s)
# reject any absolute paths or URLs (like webpack://)
if not s.startswith('../'):
continue
# don't generate coverage for node_modules/ code
if "node_modules" in s:
continue
# and only for these file types...
if not s.endswith(('.js', '.jsx', '.ts', '.tsx')):
continue
our_sources.add(s)

dst_col, src_id, src_line = 0, 0, 0
for dst_line, line in enumerate(lines):
Expand Down

0 comments on commit 706122f

Please sign in to comment.