Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cargo test suite fails if default branch is not master #8863

Closed
bk2204 opened this issue Nov 15, 2020 · 1 comment · Fixed by rust-lang/git2-rs#656 or #9035
Closed

cargo test suite fails if default branch is not master #8863

bk2204 opened this issue Nov 15, 2020 · 1 comment · Fixed by rust-lang/git2-rs#656 or #9035
Labels
A-git Area: anything dealing with git A-testing-cargo-itself Area: cargo's tests C-bug Category: bug

Comments

@bk2204
Copy link
Contributor

bk2204 commented Nov 15, 2020

Problem
Running cargo test in the cargo repository fails many tests if the user has set the default branch to something other than master.

Steps

  1. git config --global init.defaultBranch dev
  2. cargo test
  3. Notice failures

Possible Solution(s)
When using Git in a test suite, it's necessary to set HOME to a controlled location and to also set GIT_CONFIG_NOSYSTEM to avoid reading the system configuration file; otherwise, the global or system configuration files can break tests. Cargo probably needs to set these values during setup in the test suite; this is probably not the only configuration option that will have the effect of breaking tests.

Notes

Output of cargo version:

cargo 1.47.0 (f3c7e066a 2020-08-28)

(Note that this is not the version being tested, about which this report is being made.)

Debian GNU Linux amd64/sid, rustc 1.47.0, cargo repository revision 2af662e.

@bk2204 bk2204 added the C-bug Category: bug label Nov 15, 2020
@bk2204 bk2204 changed the title cargo test fails if default branch is not master cargo test suite fails if default branch is not master Nov 15, 2020
@ehuss
Copy link
Contributor

ehuss commented Nov 15, 2020

Thanks for the report! The tests run in a sandbox with a custom HOME, but I believe the issue is that the index created for each test is built outside of the sandbox. The git repo is created around here. It definitely would be good to have the tests ignore outside settings, though I'm not sure the easiest way to do that. #7944 recently added a special-cased fix for the cargo new tests, but a more general solution would be nice! It looks like libgit2's testsuite manually calls cl_sandbox_set_search_path_defaults to control the search paths.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-git Area: anything dealing with git A-testing-cargo-itself Area: cargo's tests C-bug Category: bug
Projects
None yet
2 participants