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

testing.T.Helper() not called in defered functions #292

Closed
ewbankkit opened this issue Feb 22, 2024 · 2 comments · Fixed by #293
Closed

testing.T.Helper() not called in defered functions #292

ewbankkit opened this issue Feb 22, 2024 · 2 comments · Fixed by #293
Labels
bug Something isn't working
Milestone

Comments

@ewbankkit
Copy link
Contributor

ewbankkit commented Feb 22, 2024

terraform-plugin-testing version

% go list -m github.com/hashicorp/terraform-plugin-testing/...
github.com/hashicorp/terraform-plugin-testing v1.6.0

Actual Behavior

...
    testing_new.go:91: Error running post-test destroy, there may be dangling resources: ...

t.Fatalf("Error running post-test destroy, there may be dangling resources: %s", err.Error())

This is in a function that is defered. The outer function does call testing.T.Helper(), but it is not called in the inner (defered function).

Expected Behavior

The file and line number reported should be from the calling test case.

@ewbankkit ewbankkit added the bug Something isn't working label Feb 22, 2024
@bflad
Copy link
Contributor

bflad commented Feb 22, 2024

Thank you for raising this, @ewbankkit 👍 This seems very reasonable, especially given that if we were likely to rewrite the internals of the testing logic, it would probably pass error types directly, rather than testing.T, which would prevent this sort of issue. If you are willing to submit a pull request for this change, we would be happy to review it.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants