Skip to content

fix flaky tests - #14768

Open
jschueller wants to merge 7 commits into
sphinx-doc:masterfrom
jschueller:freshenv
Open

jschueller wants to merge 7 commits into
sphinx-doc:masterfrom
jschueller:freshenv

Conversation

@jschueller

@jschueller jschueller commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

this fixes the flaky tests currently revealed by failed CI jobs:

  • somes tests need their own srcdir/env to avoid random failures depending on xdist worksteal scheduling
  • fix the linkcheck test sensitive to timeouts on slow/busy runners
  • use github docutils mirror instead of less reliable repo.or.cz

there may be others but at least this allows to run CI somewhat reliably (ran a dozen times without any error)

cherry-picks from #14691 + #14572, see also #12191
/cc @jayaddison @DavidAGInnovation @Darlokt @jdillard @AA-Turner

@jschueller
jschueller force-pushed the freshenv branch 4 times, most recently from d1f89bc to 794b500 Compare October 21, 2026 08:40
@jschueller jschueller changed the title tests: use freshenv in python_use_unqualified_type_names tests fix flaky tests Oct 21, 2026
@jschueller
jschueller force-pushed the freshenv branch 5 times, most recently from b622ed0 to 9fe8de2 Compare October 21, 2026 11:41
Comment thread tests/test_builders/test_build_linkcheck.py
Comment thread tests/test_builders/test_build_linkcheck.py
Comment thread tests/test_builders/test_build_linkcheck.py Outdated
jschueller and others added 5 commits October 22, 2026 13:42
Raise linkcheck_timeout from 0.25s to 2s: on runners with few CPUs,
a local test-server round-trip can stall for a few hundred
milliseconds under full-suite load, producing a flaky 'timeout'
status instead of 'working'.

Also implement do_HEAD in CapitalisePathHandler so each URL needs
a single round-trip instead of a 501 HEAD followed by a GET.
repo.or.cz intermittently fails with TLS handshake errors, breaking
the docutils-latest and LaTeX jobs. The docutils/docutils mirror
tracks the same trunk and is far more reliable from GH runners.
The html, latex, texinfo, and man rubric tests shared one testroot
(and thus srcdir/env) with different builders. Whichever builder ran
first on an xdist worker populated the pickled environment, so later
tests skipped re-reading sources: the html test then missed the
parse-time '"7" unknown' directive warning while still emitting
the write-phase warning, failing test_html5_rubric at random.

Separate source directories remove the sharing entirely, following
the approach of sphinx-doc#14691.
Give the conditional missing-reference test its own source and build directory so its generated HTML cannot affect Python domain tests.

Clear NO_COLOR and NO_COLOUR before forcing color in status iterator tests, making their expectations independent of the invoking environment.

@Darlokt Darlokt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the only thing is maybe the linkcheck timeout, but that can be looked at separately, this should resolve most of the instability.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants