-
Notifications
You must be signed in to change notification settings - Fork 359
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
JUnit testcase name not unique per failure #1608
Comments
I considered this, I didn't care for the idea of inserting ranges into the test names. The point of a test name is that it's identifiable across runs. For example, you could track flaky tests. A source range is not guaranteed to be stable. This is GitLab's bug, they are making invalid parsing assumptions. A quick Google... Before we make things worse for everyone, please read through the linked GitLab thread and get a full understanding of the bug and whether there are any other workarounds. Adding an incrementing number seems like an acceptable workaround, I can review a PR. |
@bendrucker One solution that might be a little more elegant is to use the terraform resource name as well as an incrementing number to give a little more context. I believe that should also stay stable across tests. Thoughts? |
Yeah, I thought about that but AFAICT it's impossible. There's no guarantee that a rule operates at the level of a specific resource. A rule could raise multiple issues for the same resource on different attributes. Several rules in the Ultimately the source range is the useful context and it's up to tools to make use of that. Despite its wide adoption JUnit is not full-featured and suffers from the fact that too much data is unstructured and stuffed into text. Contrast this with the GitHub Actions annotations system, which includes support for source positions: Nothing we can do here is going to be "good" compared to that, so at least it should be simple. |
Improvements to the JUnit formatter are welcome, eg for some of the other extension fields GitLab seems to display. Part of the problem is that the only official looking spec I've found is very minimal. |
Summary
Problem
When there are multiple linting issues with the same cause, the test case name is not unique.
This causes issues when the JUnit results are parsed (by GitLab) which discards all the failures except the final one.
Proposed Solution
Include the file and line number in the testcase name
e.g.
<testcase classname="main.tf" name="terraform_deprecated_interpolation main.tf:197,31-75" time="0">
Command
docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint:v0.43.0 --format junit
Terraform Configuration
TFLint Configuration
Output
TFLint Version
0.43.0
Terraform Version
No response
Operating System
The text was updated successfully, but these errors were encountered: