Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate the testing import in test code #32

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

skitt
Copy link
Contributor

@skitt skitt commented Oct 4, 2024

testing_mocks_linux.go imports the testing package, and that import leaks into any binary built with securejoin. This causes issues in projects which check for that, such as Kubernetes (see kubernetes/kubernetes#127832 and its tests).

This adds a level of indirection for hooks used to force testing behaviour in procfs_linux.go, so that the mocks can be defined only in _test.go files. This ensures that the testing package is only pulled in for tests.

testing_mocks_linux.go imports the testing package, and that import
leaks into any binary built with securejoin. This causes issues in
projects which check for that, such as Kubernetes (see
kubernetes/kubernetes#127832 and its tests).

This adds a level of indirection for hooks used to force testing
behaviour in procfs_linux.go, so that the mocks can be defined only in
_test.go files. This ensures that the testing package is only pulled
in for tests.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
Copy link
Owner

@cyphar cyphar left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the patch!

I'll do a release in a day or two so you can use it in Kubernetes soon.

@cyphar cyphar merged commit 86e6182 into cyphar:main Oct 8, 2024
12 checks passed
cyphar added a commit that referenced this pull request Oct 8, 2024
Ref: 6864912 ("Isolate the testing import in test code")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
cyphar added a commit that referenced this pull request Oct 8, 2024
Ref: 6864912 ("Isolate the testing import in test code")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
@skitt skitt deleted the isolate-testing-dependency branch October 8, 2024 14:49
@cyphar
Copy link
Owner

cyphar commented Oct 9, 2024

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