Skip to content

Nondeterministic macOS is_symlink assertion failure in overwriting_files_and_lone_directories_works #1373

Closed
@EliahKagan

Description

@EliahKagan

Current behavior 😯

In gix-worktree-state/tests/state/checkout.rs, the test overwriting_files_and_lone_directories_works fails occasionally on the assertion:

https://github.com/Byron/gitoxide/blob/3c2174101ed35dcb9bdb4585b3245507b15efe59/gix-worktree-state/tests/state/checkout.rs#L238

Usually it passes, but occasionally it fails. This happens both on CI and in manual runs. As far as I know, the failure only happens on macOS. Here's an example from CI in my fork:

        FAIL [   0.422s] gix-worktree-state-tests::worktree state::checkout::overwriting_files_and_lone_directories_works

--- STDOUT:              gix-worktree-state-tests::worktree state::checkout::overwriting_files_and_lone_directories_works ---

running 1 test
test state::checkout::overwriting_files_and_lone_directories_works ... FAILED

failures:

failures:
    state::checkout::overwriting_files_and_lone_directories_works

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 10 filtered out; finished in 0.42s


--- STDERR:              gix-worktree-state-tests::worktree state::checkout::overwriting_files_and_lone_directories_works ---
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
thread 'state::checkout::overwriting_files_and_lone_directories_works' panicked at gix-worktree-state/tests/state/checkout.rs:238:9:
assertion `left == right` failed
  left: false
 right: true
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I don't know why this happens, but maybe it is somehow related to concurrency? I say this based only on #1354 (comment), indicating that "the filesystem probe" for symlinks is "still not safe for concurrent operations."

Expected behavior 🤔

The test should pass in all runs, rather than just most.

Git behavior

I'm unsure if there is a corresponding Git behavior, because I am unsure if this is a test bug or a bug in the code under test. Above the line with the assertion, the test has this comment:

https://github.com/Byron/gitoxide/blob/3c2174101ed35dcb9bdb4585b3245507b15efe59/gix-worktree-state/tests/state/checkout.rs#L237

I'm not sure what aspect of Git behavior that's referring to, though. As far as I know, Git determines whether it will attempt to create symlinks on Windows by checking core.symlinks and, unlike on other systems, defaults it to false if it is not set in any scope.

Steps to reproduce 🕹

I don't know a good procedure. I've been running tests a fair amount and occasionally seeing the problem. Running the tests many times in succession would likely trigger it. Also running them many times in succession while only allowing one test to run at a time might shed some light on whether concurrency is involved, but this would of course be even more time-consuming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedan issue is accepted as shortcoming to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions