Registry Mirror
Skip to content

Conversation

@christophwille

@christophwille christophwille commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

A sweep of all test projects for network access found places where tests reach the Internet without needing to. The Roslyn toolset downloads in ICSharpCode.Decompiler.Tests stay intentional: a package that is genuinely missing still fails the suite when it cannot be fetched.

Headless UI tests (ILSpy.Tests): MainWindowViewModel's constructor fires the startup update check. Each test session gets a fresh settings file, where the production default is "enabled, never checked", so every test that built the main window issued a real HTTPS request to the update feed. Errors are swallowed, so it never failed a test, but it is unmocked network traffic, and offline each request holds a thread until the HttpClient timeout. The test settings file is now seeded with automatic update checks off, through a shared TestSettingsFile helper used by both TestApp and ResetAppStateAttribute, and a test pins that default.

CLI tests (ICSharpCode.ILSpyCmd.Tests): every test passed --disable-updatecheck by hand. A new test that forgot it would silently query nuget.org at the end of its run. CliTestRunner.RunAsync now prepends the flag itself, and the per-test copies are gone.

Decompiler test setup (ICSharpCode.Decompiler.Tests): with every toolset already extracted, an offline run still failed in Tester's type initializer with FatalProtocolException: Unable to load the service index. The toolset constructors resolved FindPackageByIdResource eagerly, which fetches each feed's service index before any cache is checked. NuGet.Protocol has no offline switch for that path (the service index provider builds its own cache context, 30-minute HTTP cache window, no stale-cache fallback), so the resource is now resolved inside FetchPackage, only when a download is actually needed. The TestRunner build in the same setup then failed on NuGet audit during its implicit restore (NU1900 under warnings-as-errors); that build now passes -p:NuGetAudit=false, the runner's packages being audited by the regular solution restore already. Verified by running a Pretty test with an unreachable proxy and an empty NuGet HTTP cache: it failed before and passes now, and deleting an extracted ref pack with the network available still downloads it through the new path.

Everything else the sweep flagged is already mocked (FakeNuGetFeedClient / FakeNuGetIconLoader), local-only (Unix domain sockets in the temp directory), or plain URL string handling.

Assisted-by: Claude:claude-fable-5-1:Claude Code

MainWindowViewModel fires the startup update check from its constructor.
Every test session gets a fresh settings file, where the production default
is "enabled, never checked", so each test that built the main window issued a
real HTTPS request to the update feed. Errors are swallowed, so this never
failed a test, but it is unmocked network traffic from a unit test, and
offline each request holds a thread until the HttpClient timeout.

Assisted-by: Claude:claude-fable-5-1:Claude Code
Every CLI test passed --disable-updatecheck by hand. That guard held only by
convention: a new test that forgot the flag would silently query nuget.org at
the end of its run, with the failure swallowed. Putting the flag into
CliTestRunner makes it structural, and the per-test copies go away.

Assisted-by: Claude:claude-fable-5-1:Claude Code
…cached

Tester's static constructor resolved a FindPackageByIdResource for both
feeds, which loads each feed's service index over HTTP before any cache is
consulted. Offline, every decompiler test therefore died in the type
initializer with "Unable to load the service index", even when all toolsets
were already extracted and no download was needed. NuGet.Protocol offers no
offline mode for this: the service index provider uses its own cache context
with a 30-minute HTTP cache window and no stale-cache fallback. Resolving the
resource at download time is the only way to avoid the request.

The TestRunner build in the same setup hit the second feed-dependent step:
NuGet audit during its implicit restore, which under warnings-as-errors turns
an unreachable feed into NU1900 and fails the build.

Downloads that are genuinely required still fail the suite when the network
is unavailable, as intended.

Assisted-by: Claude:claude-fable-5-1:Claude Code
@christophwille christophwille changed the title Stop UI and CLI tests from reaching the network unintentionally Keep tests off the network unless a toolset download is actually needed Oct 18, 2026
@christophwille
christophwille merged commit 7367f23 into master Oct 18, 2026
18 checks passed
@christophwille
christophwille deleted the tests-no-unintended-network branch October 18, 2026 16:29
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.

2 participants