Skip to content

Speed up slow tests - #2019

Merged
thomas-zahner merged 10 commits into
lycheeverse:masterfrom
thomas-zahner:speed-up-slow-tests
Feb 9, 2026
Merged

thomas-zahner merged 10 commits into
lycheeverse:masterfrom
thomas-zahner:speed-up-slow-tests

Conversation

@thomas-zahner

@thomas-zahner thomas-zahner commented Feb 1, 2026 •

Copy link
Copy Markdown
Member

Fix #1892.

In CI we can see that tests now take about 55 seconds instead of 70 seconds. The CI action spends a lot of time in compiling lychee. This change is mainly an improvement for local development. E.g. on my machine the first stage of make test (cargo nextest run --all-targets --all-features) now takes about 5 seconds instead of 12 on average.

Apart from speeding up the tests I could also improve the reliability.

Some background details

test_lycheecache_exclude_custom_status_codes requires no internet but was slow because of unnecessary retries.

test_require_https is using example.com. As it seems really unpractical to make localhost functional with HTTPS and it generally isn't slow I would prefer to keep this test unchanged.

Fix the flakiness of the cache tests. They were racing against each other writing and deleting the cache files of each other.

@thomas-zahner
thomas-zahner force-pushed the speed-up-slow-tests branch 2 times, most recently from 6646340 to 521a8e0 Compare February 2, 2026 02:26
Comment thread lychee-bin/tests/cli.rs

@katrinafyi katrinafyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good. it's a very good idea to disentangle the cache tests.

Comment thread lychee-bin/tests/cli.rs
Comment thread lychee-bin/tests/cli.rs Outdated
Comment thread lychee-bin/tests/cli.rs Outdated
Comment thread lychee-bin/tests/cli.rs Outdated
Comment thread lychee-bin/tests/cli.rs Outdated
Remove dependency on previously deleted TEST_INVALID_URLS.html
The test is now running locally without requiring an internet connection
The previous assertion conincidentially matched the timestamp 1769996167
@thomas-zahner
thomas-zahner force-pushed the speed-up-slow-tests branch 2 times, most recently from 8fc4097 to 54d7e3b Compare February 9, 2026 13:53
thomas-zahner and others added 4 commits February 9, 2026 15:00
The test was previously lying and confusing.
Unknown status codes such as 999 are actually cached today.
linkedin returned 200 given lychee's user agent.
@thomas-zahner
thomas-zahner merged commit 9db63a7 into lycheeverse:master Feb 9, 2026
7 checks passed
@mre mre mentioned this pull request Feb 9, 2026
mre added a commit that referenced this pull request Mar 25, 2026
After thinking about this for a while, I think caching errors goes against typical CI workflows.

That's because if a link fails due to a network issue, a server outage, or if a previously failing link has been fixed, reading an error from the cache prevents lychee from realizing the link is now working. Right now it will load the broken link from cache, notice that it has no status code associated with it, and fail immediately. It just caches the error again until it expires and gets re-checked. That's quite unintuitive.

This commit updates Cache::store and Cache::load to skip CacheStatus::Error. As a result, failures are always rechecked on subsequent runs. We completely sidestep issues with caching transient network errors or missing HTTP status codes.

It also updates a CLI test to accurately assert that an invalid 999 response generates an empty cache file, restoring the original logic of the test which was accidentally flipped in a prior PR (#2019) to expect errors to be cached.

Fixes #1734.
Fixes #1783.
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.

Speed up slow tests

3 participants