Skip to content

Prevent users' proxy and config variables from affecting tests - #7492

Open
ds-env wants to merge 1 commit into
libgit2:mainfrom
ds-env:test-env-isolation
Open

ds-env wants to merge 1 commit into
libgit2:mainfrom
ds-env:test-env-isolation

Conversation

@ds-env

@ds-env ds-env commented Nov 20, 2026

Copy link
Copy Markdown

Some tests fail when the environment they run in sets proxy or config variables; the suites reset some of these variables, but not all.

Lower-case proxy variables (remote::httpproxy). Since #6498 the suite saves and clears HTTP_PROXY, HTTPS_PROXY and NO_PROXY, but libgit2 reads http_proxy, https_proxy and no_proxy first (http_proxy_env in remote.c). On main, https_proxy alone fails config_overrides, config_overrides_detached_remote and env, and no_proxy alone fails env; these are the failures reported in #6502, whose environment had the lower-case forms set. (curl, for one, accepts http_proxy only in lower case.) The commit saves, clears and restores the lower-case forms as well.

System config switches (repo::env). repo::env::config points GIT_CONFIG_SYSTEM to its own file, but with GIT_CONFIG_NOSYSTEM=1 that file is never read. The commit clears GIT_CONFIG_NOSYSTEM in clear_git_env(), and GIT_CONFIG_SYSTEM and GIT_CONFIG_GLOBAL with it: the other tests of the suite open repositories with GIT_REPOSITORY_OPEN_FROM_ENV and so read the user's config files too, and repo::env::config already unsets all three at its end.

A third variable, GIT_COMMON_DIR, makes repo::init fail through a bug in git_repository_init_ext; that is #7491.

To reproduce (on main, 42a89d7)

https_proxy=http://proxy.example.com:3128 build/libgit2_tests -sremote::httpproxy   # config_overrides, config_overrides_detached_remote, env
no_proxy=localhost,127.0.0.1 build/libgit2_tests -sremote::httpproxy                # env
GIT_CONFIG_NOSYSTEM=1 build/libgit2_tests -srepo::env                               # config

Testing

With the commit, each of the commands above passes. The offline suite (-xonline -xstress, Debug build, Linux) passes except core::structinit::compare, which fails on my machine without the commit too.

remote::httpproxy saved and cleared HTTP_PROXY, HTTPS_PROXY and NO_PROXY,
but libgit2 reads the lower-case http_proxy, https_proxy and no_proxy
first, so a machine with e.g. https_proxy set fails config_overrides,
config_overrides_detached_remote and env (see libgit2#6502).

repo::env cleared the repository variables, but not GIT_CONFIG_NOSYSTEM,
GIT_CONFIG_SYSTEM and GIT_CONFIG_GLOBAL; with GIT_CONFIG_NOSYSTEM=1 set,
repo::env::config fails, since the system file it sets is not read.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant