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

Cleanup: more consistent naming of inner *testing.T #508

Open
corneliusweig opened this issue Feb 22, 2020 · 7 comments
Open

Cleanup: more consistent naming of inner *testing.T #508

corneliusweig opened this issue Feb 22, 2020 · 7 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@corneliusweig
Copy link
Contributor

There are basically two patterns in krew:

  1. Shadow the outer t *testing.T.

  2. Use an inner tt *testing.T

Both variants have their pro's and con's:
Shadowing can be confusing because one might overlook that there is an inner variable that shadows the outer one. However, in the great majority of cases, only the inner *testing.T should be used for assertions, so this also prevents errors where a test uses the outer one. So either way is fine.

Let's decide which pattern we want to follow and stick to it. This should also come with a source code test.

@corneliusweig corneliusweig added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Feb 22, 2020
@ahmetb
Copy link
Member

ahmetb commented Feb 22, 2020

Nr.2 for sure :P

@ahmetb
Copy link
Member

ahmetb commented Feb 22, 2020

Also, honestly it doesn't matter a whole lot.
It seems like we almost never need the t in the outer scope.
This is also something sort of hard to enforce, we probably shouldn't be in the business of handling this.

@corneliusweig
Copy link
Contributor Author

So you suggest to simply ignore that we are using different patterns?

@ahmetb
Copy link
Member

ahmetb commented Feb 22, 2020

IMO this isn’t really a coding pattern. Simply a variable shadowing in different scopes. It currently seems harmless, and doesn’t lead to code duplication etc.

If it bothers you a lot, feel free to write some code to enforce it. Maybe there’s a pattern we can check.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 22, 2020
@corneliusweig
Copy link
Contributor Author

Go 1.14 has improved support for deferred cleanup routines in tests. This should also be handled, either here or elsewhere

@ahmetb
Copy link
Member

ahmetb commented Jun 1, 2020

#606 suggests using go1.14 as well. It sounds like we just need to go do it.
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

4 participants