Skip to content

Remove fstest dependency on root package#281

Open
dmcgowan wants to merge 2 commits intocontainerd:mainfrom
dmcgowan:update-fstests
Open

Remove fstest dependency on root package#281
dmcgowan wants to merge 2 commits intocontainerd:mainfrom
dmcgowan:update-fstests

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

Related to #277

Summary

  • Replace fstest's use of continuity.NewContext, continuity.BuildManifest, and the continuity.Resource interfaces with a local directory walker and plain resource struct
  • Break the transitive dependency chain where consumers of CheckDirectoryEqual (used in ~37 test files across containerd and buildkit) pull in the full root package with its protobuf, manifest, and driver machinery
  • Add test coverage for CheckDirectoryEqual, CheckDirectoryEqualWithApplier, and the new buildResources walker

Details

The fs/fstest package provides CheckDirectoryEqual for comparing two directory trees in tests. Previously this worked by building full continuity manifests (context + manifest + protobuf resources), which dragged in the entire root continuity package as a dependency. Any external repo importing fs/fstest for test helpers transitively required protobuf, the driver framework, digest libraries, and other machinery unrelated to simple directory comparison.

The new implementation replaces this with:

  • walker.go — a filepath.Walk-based directory walker that produces a sorted []resource list with path, mode, uid/gid, size, SHA256 content hash, symlink target, and device major/minor
  • walker_unix.go / walker_windows.go — platform-specific stat, hardlink detection, and device info extraction
  • continuity_util.go — updated diff and comparison functions operating on the concrete resource type instead of continuity.Resource interfaces

The comparison behavior is preserved:

  • Path, mode, uid, gid are compared for all resource types
  • Regular files compare size, SHA256 digest, and hardlink paths
  • Symlinks compare targets
  • Devices compare major/minor numbers
  • Directories and named pipes compare by metadata only
  • XAttrs were collected but never compared before (// TODO in old code) and remain uncompared

Test plan

  • New tests in compare_test.go cover: identical directories, content differences, extra/missing files, symlinks, symlink target differences, hardlinks, permission differences, applier-based comparison, and buildResources output validation
  • go test ./fs/fstest/ passes
  • Existing fs/ test suite (TestDirectoryCompare, copy tests using CheckDirectoryEqual) continues to pass

Replace the fstest package's use of continuity.NewContext,
continuity.BuildManifest, and the continuity Resource interfaces with a
local directory walker and concrete resource type. This breaks the
second-order dependency chain where external consumers of
CheckDirectoryEqual (used in ~37 test files across containerd and
buildkit) transitively pulled in the entire root package with its
manifest, protobuf, and driver machinery.

The new walker uses filepath.Walk, crypto/sha256 for content comparison,
and platform-specific stat calls for uid/gid, hardlinks, and device info.

Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan dmcgowan force-pushed the update-fstests branch 2 times, most recently from af32332 to 3ce6856 Compare April 12, 2026 17:07
Cover CheckDirectoryEqual, CheckDirectoryEqualWithApplier, and
buildResources with tests for: identical directories, content
differences, extra/missing files, symlinks, symlink target differences,
hardlinks, and permission differences.

Signed-off-by: Derek McGowan <derek@mcg.dev>
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.

1 participant