Skip to content

test: cover cached cwd contracts#56

Merged
hyfdev merged 3 commits into
mainfrom
agent/cached-cwd-contract-matrix
Jul 14, 2026
Merged

test: cover cached cwd contracts#56
hyfdev merged 3 commits into
mainfrom
agent/cached-cwd-contract-matrix

Conversation

@hyfdev

@hyfdev hyfdev commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Extend the cached-current-directory integration test across cwd-independent relative inputs, cwd-dependent pure-relative and mixed absolute/relative branches, strict and fallible results, and exact Cow ownership.
  • Isolate the pure-relative cache lifecycle in its own integration-test process so no mixed branch can initialize the cache on its behalf.
  • Verify that relative(...).into_owned().into_slash() follows the same cached-cwd policy while relative_with remains controlled only by its explicit cwd.
  • Verify on Windows that drive-relative receiver and base inputs continue to use authoritative per-drive cwd state instead of the single cached process cwd.
  • Add an isolated Unix child-process test proving that failed cwd lookups do not poison the cache and that the first later success can still become the cached value.
  • Run the default-feature suite for the sugar_path package alone so workspace feature unification cannot silently enable cached_current_dir.

Why

The existing cache test covered absolutize, but did not enforce the ambient relative branches or their final slash-conversion composition. The unavailable-cwd test proved errors while cwd stayed missing, but did not prove that the cache retries after a failure. These tests make the documented process-lifetime feature behavior explicit without changing the implementation.

Impact

This changes tests and one CI command only. It does not change production code, dependencies, benchmarks, or allocation snapshots. The same CI correction is owned by Draft PR #52; carrying it here lets this PR produce valid standalone default/all-feature evidence, and it will disappear from this diff after #52 merges and this branch rebases.

Validation

  • cargo +1.97.0 fmt --all --check
  • git diff --check
  • cargo +1.97.0 test --test cached_current_dir
  • cargo +1.97.0 test --test cached_current_dir --all-features
  • cargo +1.97.0 test --test cached_current_dir_failure
  • cargo +1.97.0 test --test cached_current_dir_failure --all-features
  • cargo +1.97.0 test -p sugar_path --test cached_current_dir_relative
  • cargo +1.97.0 test -p sugar_path --all-features --test cached_current_dir_relative
  • cargo +1.97.0 test -p sugar_path
  • cargo +1.97.0 test --workspace --all-features
  • cargo +1.97.0 clippy --workspace --all-targets --all-features -- -D warnings
  • RUSTDOCFLAGS='-D warnings' cargo +1.97.0 doc --workspace --all-features --no-deps
  • Changed tests compile and pass Clippy for x86_64-pc-windows-msvc, with and without cached_current_dir, in a dependency-only harness

Adversarial review

  • Review found that the workspace's allocation tracker enabled cached_current_dir during the nominal default-feature job. The default job now selects only sugar_path.
  • Review found that later mixed relative calls could initialize the cache even if the pure-relative branch did not. That lifecycle now runs in an isolated integration-test process and observes the third cwd immediately after one pure-relative lookup in the second cwd.
  • The same reviewer rechecked both fixes and reported PASS for the code and test design.
  • The first genuine default-feature Windows run then exposed a test-oracle bug: an expected relative path used a literal / instead of the native separator. The expectation now uses PathBuf::join, and the rerun passed on Windows.

Hosted CI passed all 9 checks. The logs confirm separate cargo test --locked -p sugar_path and workspace all-feature runs, with the cache lifecycle tests executing in both configurations on native Windows, Linux, and macOS. The unavailable-cwd recovery test also executes and passes on Linux and macOS.

@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.87%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 227 untouched benchmarks
⏩ 38 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation string 255.8 ns 226.7 ns +12.87%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing agent/cached-cwd-contract-matrix (24515c6) with main (05c456d)

Open in CodSpeed

Footnotes

  1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@hyfdev
hyfdev marked this pull request as ready for review July 14, 2026 12:55
Copilot AI review requested due to automatic review settings July 14, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hyfdev
hyfdev merged commit f66d7c1 into main Jul 14, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants