Skip to content

FileSnapshot::into_owned_or_cloned intermittently fails according to its journey test #1896

@EliahKagan

Description

@EliahKagan

Current behavior 😯

The gix-fs::fs snapshot::journey test case was introduced in f93aa61 (#1884) along with the into_owned_or_cloned method that it tests. That test case fails intermittently.

This was first observed in #1892, but it is not related to the changes in that PR. It seems to happen occasionally on all platforms, though I have not found it to fail on macOS, only on Ubuntu and Windows. I suspect that this is merely because we have fewer macOS jobs than Ubuntu or Windows jobs, but I do not know that to be why it hasn't happened on macOS. All failures observed so far have been on CI. I have not experimented locally with it.

Although #1892 makes a change to a Windows job that is one of the jobs where the failure was observed, the change is made for its future effect, and it does not change what software currently gets installed. More importantly, the observed failure in that job on Windows (as well as in another separate Windows job) is from before that PR. The failures observed in that PR have been on Ubuntu (and also in multiple jobs).

Besides being observed in that PR, I have observed failures on the main branch of my fork, where I have rerun jobs to check for it, and unintentionally in #1864 after a rebase that causes it to have f93aa61 in its history. It does not appear that failure is more or less likely on any branch compared to any other branch (for branches that have the test in their history).

The failures look like:

        FAIL [   0.005s] gix-fs::fs snapshot::journey
──── STDOUT:             gix-fs::fs snapshot::journey

running 1 test
test snapshot::journey ... FAILED

failures:

failures:
    snapshot::journey

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

──── STDERR:             gix-fs::fs snapshot::journey

thread 'snapshot::journey' panicked at gix-fs/tests/fs/snapshot.rs:31:5:
assertion `left == right` failed: it picks up the change
  left: "content"
 right: "change"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The failing part is:

std::fs::write(&file_path, "change")?;
let snap = smut.recent_snapshot(check, open)?.expect("content read");
assert_eq!(&**snap, "change", "it picks up the change");

Specifically, that assert_eq! fails, due to the test observing the old contents content, rather than the new contents change.

Expected behavior 🤔

The test should pass. I don't know if the problem is the test or the code under test though. It seems like the test straightforwardly asserts that any write that is completed from the perspective of Rust code that runs in sequence with a subsequent access to the snapshot should be observed in that subsequent access. If so, then that suggests the bug could be in the code under test.

Git behavior

Not applicable.

Steps to reproduce 🕹

Running the test repeatedly seems to work to reproduce it, at least on CI. Usually the test passes but sometimes it fails.

Observed failures on CI so far, in the order they have been observed, have been:

I originally "reported" this in #1892 (comment) but I figured it should have an issue, since its connection to that PR is coincidental.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions