-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Move testclient to a separate package #18229
Merged
k8s-github-robot
merged 1 commit into
kubernetes:master
from
caesarxuchao:move-testclient
Dec 10, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unversionedTest?
We do not use underscores in go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the blackbox testing feature. https://splice.com/blog/lesser-known-features-go-test/
And for the package name, I think the convention in this project is using under score.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the convention documented. Is there any other pkgs has underscore in names in k8s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it probably is a Go convention. If you
git grep "^package .*_.*"
in the repo you will find many examples.A black-box test example: https://github.com/kubernetes/kubernetes/blob/master/pkg/api/deep_copy_test.go#L17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. The pkg naming convention is not using underscore in go.
Please check https://golang.org/doc/effective_go.html#package-names.
I cannot see why you add the
_test
prefix. Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary. The main reason we want to put it into a different pkg is to avoid circle import I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I can't seem to find the official go documentation of this feature, but here is a decent explanation, scroll down to "black-box test package" https://splice.com/blog/lesser-known-features-go-test/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lavalamp OK. I did not notice there is an import cycle by my eye. :( The unversion pkg is named to
client
.The official doc is at https://golang.org/cmd/go/#hdr-Test_packages.
It is the same as I mentioned 3 replies above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha, very sorry, clearly I did not read the above very carefully at all :)
btw, I believe your suggestion of "unversionedTest" will not compile, since there are other files in package "unversioned" in the directory.
But ordinarily, I agree that we wouldn't use "_" in a package name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to emphasize @xiang90's point: https://golang.org/doc/effective_go.html#package-names: "there should be no need for underscores or mixedCaps". though this rule is not strictly followed in our codebase.
"_test" is a special case. And yes, we need to use it to break cyclic imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea... I was wrong for the beginning. Did not take a very close look at the beginning.