dotnet / dotnet/docfx

[Bug] `docfx.Snapshots.Tests` tests detect PDF diffs on non Ubuntu environment

Open
#10,473 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**Describe the bug**
When running `docfx.Snapshots.Tests` tests on Windows environment.
Snapshot diffs are detected that are relating to generated PDF files.

**Expected behavior**
`docfx.Snapshots.Tests` run successfully without diffs on Windows environment.

**Context**
- OS: Windows

**Additional context**

PDF snapshot diffs are caused by following OS dependent behaviors.
1. OS dependent fonts differences (Embedded fonts are selected by specified font family)
2. OS specific rendering differences. (See `https://github.com/UglyToad/PdfPig/issues/840`)

I've tried to use Web Fonts (`Noto Sans` and `Noto Sans Mono`) to resolve issues.
But `2. OS specific rendering differences` seems to be hard to resolve. (It cause diffs on line break location)

As a temporary workaround.
I'm using following git commands to ignore diffs.

```cmd
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/api/toc.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/apipage/toc.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/articles/seed.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/md/toc.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/pdf/toc.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/restapi/toc.pdf.verified.json
git update-index --skip-worktree test/docfx.Snapshot.Tests/SamplesTest.Seed/toc.pdf.verified.json
```

> [!NOTE]
> When reset above settings.
> It need to exec command with `--no-skip-worktree`.
> Skipped files can be found by using `git ls-files -v` command and `S` flag.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.