Skip to content

test(install): exercise copyFrom's same-inode branch - #166

Merged
codeyevsky merged 1 commit into
solongate:mainfrom
Nelmad:test/copyfrom-same-inode-fixture
Oct 26, 2026
Merged

codeyevsky merged 1 commit into
solongate:mainfrom
Nelmad:test/copyfrom-same-inode-fixture

Conversation

@Nelmad

@Nelmad Nelmad commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #161.

The first copyFrom already creates the destination, so the following os.Link fails with EEXIST and the test skips before reaching its assertion. Remove that copy before creating the hard link.

Also assert that the source and destination still refer to the same file after the second copyFrom. Checking only the returned binary name would still pass if the same-inode branch were removed and the binary were unnecessarily copied again.

Only the existing test changes; production code and the fallback for environments without hard-link support are unchanged.

Validation on macOS arm64, Go 1.26.10:

  • Before: the target test skips with file exists; the same-inode block has coverage count 0. After: the test passes and the block has count 1.
  • go vet ./... passes in packages/core; go test -count=1 -race ./install/ passes all 131 top-level tests without skips.
  • In a temporary Go overlay, disabling the same-inode branch still passes with only the fixture fix, but fails with the added assertion.
  • The changed file passes the repository's CI gofmt rule. The install tests also cross-compile for Windows amd64; they were not executed on Windows.
  • ./scripts/sg-unit-check.sh stopped in guard/shield because the execution sandbox disallows localhost listeners. That package passes when rerun with localhost access and an isolated HOME. The full repository suite was not completed for this change.

Linux execution was not repeated locally because the Docker daemon was unavailable. No real-agent integration or installer scripts were run locally: this change only repairs a unit-test fixture, and the tests use temporary files and settings.

Hosted validation subsequently passed for this commit: CI, CodeQL, and Trivy. CI includes all nine Go module jobs, six cross-platform builds, and the integration checks.

Remove the initial destination copy before linking so the fixture does
not skip with EEXIST. Check that copyFrom preserves the shared inode,
since checking only the returned name also passes after an unnecessary copy.

Signed-off-by: Nelmad <17722412+Nelmad@users.noreply.github.com>

@codeyevsky codeyevsky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Test-only fix: removes the stale destination before the hard-link, asserts same-inode after copyFrom. Verified locally, production code unchanged.

@codeyevsky
codeyevsky merged commit b2b4a54 into solongate:main Oct 26, 2026
34 checks passed
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.

install: TestCopyFromSkipsAlreadyIdenticalBinary always skips, so copyFrom's same-inode branch is never tested

2 participants