Skip to content

docs(vcs): workdir_root doctest asserts None == None, not the convergence it claims #818

@dekobon

Description

@dekobon

Summary

The no_run doctest on vcs::workdir_root claims to demonstrate that two
files in the same checkout share one work-tree root, but as written it
asserts None == None and proves nothing about that claim.

Location

  • src/vcs/mod.rs:366-372 (the doc example on workdir_root)

Evidence

/// ```no_run
/// use std::path::Path;
/// // Two files in the same checkout share one work-tree root.
/// let a = big_code_analysis::vcs::workdir_root(Path::new("repo/src/a.rs"));
/// let b = big_code_analysis::vcs::workdir_root(Path::new("repo/tests/b.rs"));
/// assert_eq!(a, b);
/// ```

workdir_root (impl in src/vcs/git/repo.rs:59-72) resolves the directory
to probe like so: for a non-existent path it takes path.parent()
(repo/src and repo/tests respectively), then calls open(directory).
Both repo/src and repo/tests are relative paths that do not exist
relative to the doctest's working directory, so open(...) returns Err
and workdir_root returns None for both inputs.

The assertion therefore reduces to assert_eq!(None, None), which holds
regardless of whether the "same checkout shares one root" property is true.
The two inputs also resolve via different parent directories
(repo/src vs repo/tests), so the example does not even feed
workdir_root two paths that would converge on one real work tree.

The example is no_run, so it never executes in CI and cannot fail; its
only effect is documentation. A reader who removes no_run to verify the
behavior would get a test that passes for the wrong reason (the
vacuous-assert failure mode tracked elsewhere, e.g. #787).

Expected Behavior

The example should either:

  • demonstrate the documented "same checkout, same root" property against a
    real repository (necessarily no_run, but using paths that, when run in a
    checkout, actually return Some(root) for both and converge), with a
    comment making clear it requires a real checkout; or
  • be reduced to a prose statement of the contract if a self-contained,
    meaningful runnable example is not feasible without fixture setup.

The current form should not present assert_eq!(a, b) as evidence of the
convergence property when both sides are None for unrelated reasons.

Actual Behavior

The doc example asserts None == None for two non-existent relative paths
and is presented as demonstrating that two files in the same checkout share
one work-tree root. It demonstrates neither convergence nor the Some-root
case.

Impact

Documentation only. A contributor reading or attempting to run the example
is misled about what is being verified; the example provides false
assurance about the convergence contract that issue #670 relies on.


Resolution

Rewrote the workdir_root no_run doctest to illustrate same-checkout paths sharing one Some(root) instead of the vacuous None == None assertion. Commit a7e35ad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions