Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feature git makes tests non-deterministic #29

Closed
alexanderkjall opened this issue Sep 16, 2023 · 3 comments · Fixed by #41
Closed

feature git makes tests non-deterministic #29

alexanderkjall opened this issue Sep 16, 2023 · 3 comments · Fixed by #41
Labels
bug Something isn't working

Comments

@alexanderkjall
Copy link

Describe the bug

Running cargo test --features git against version 0.6.0 makes fetch_invalidates_cache, opens_existing and updates_cache non-deterministic and failing.

To Reproduce

run: cargo test --features git

relevant output:

Initialized empty Git repository in /tmp/r/tame-index-0.6.0/target/tmp/.tmpbSyBvV/
test clones_new ... ok
test updates_cache ... FAILED
test opens_existing ... FAILED
test fetch_invalidates_cache ... FAILED
test non_main_local_branch ... ok

failures:

---- updates_cache stdout ----
thread 'updates_cache' panicked at 'assertion failed: `(left == right)`
  left: `"984e53ed96b09639d6318d53025e4a50b1fd061e"`,
 right: `"cf4010efe947a9643bf992b52d40674930ad5848"`', tests/git.rs:314:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- opens_existing stdout ----
thread 'opens_existing' panicked at 'assertion failed: `(left == right)`
  left: `"984e53ed96b09639d6318d53025e4a50b1fd061e"`,
 right: `"4cfcbdd63ae052b57a220dc7b9bb3907857a6bf3"`', tests/git.rs:273:5

---- fetch_invalidates_cache stdout ----
thread 'fetch_invalidates_cache' panicked at 'assertion failed: `(left == right)`
  left: `"984e53ed96b09639d6318d53025e4a50b1fd061e"`,
 right: `"91d6cda9432874bd9c4d8af62015bdcc02ed5bd3"`', tests/git.rs:348:5


failures:
    fetch_invalidates_cache
    opens_existing
    updates_cache

test result: FAILED. 2 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

It seems like the right field changes every second to a new value.

Expected behavior
That the unit tests passed.

Screenshots
n/a

Device:

  • OS: I run arch btw ;)

Additional context
n/a

@alexanderkjall alexanderkjall added the bug Something isn't working label Sep 16, 2023
@Jake-Shadle
Copy link
Member

I'm assuming you have some kind of global git config or something that is affecting tests on your machine, the git tests in this repo have been 100% reproducible since they were added since they only rely on local operations, not networked ones. The tests work for the purposes of this project, but if you end up finding out why they don't on your machine feel free to open a PR.

@alexanderkjall
Copy link
Author

I guess that it might be that I have my environment setup to sign my git commits:

$ cat .gitconfig
[user]
	email = [email protected]
	name = Alexander Kjäll
	signingkey = 1D108E6C07CBC406
[commit]
	gpgsign = true
[tag]
	gpgsign = true
[gpg]
	program = gpg-sq

One could maybe argue that a unit test shouldn't read the users global configuration, but I haven't verified that this is the source for the non-determinism.

Jake-Shadle added a commit that referenced this issue Nov 6, 2023
By default gix will honor the user's settings (repo, global etc) but
this breaks testing if the user has GPG signing enabled, which causes
the commit ids to be different from what's expected.

Resolves: #29
@Jake-Shadle
Copy link
Member

I think this is resolved in 0.8.0, let me know if that is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants