-
Notifications
You must be signed in to change notification settings - Fork 10.3k
terraform-test: Add strict mode #38224
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
Draft
matejrisek
wants to merge
8
commits into
main
Choose a base branch
from
feature/34010/add-strict-mode-tf-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0516cc4
terraform-test: Add strict mode
matejrisek 4122811
Add missing CP headers
matejrisek 336db23
Add changelog entry
matejrisek 288e6d3
Remove changelog entry
matejrisek 454eed1
Add .changes entry
matejrisek 4dca612
Merge branch 'main' into feature/34010/add-strict-mode-tf-test
matejrisek 2e01c5e
Pull strictness test out of the checkForMissingExpectedFailures method
matejrisek 06cd2b4
Reduce the return vars number from FilterVariablesToModule
matejrisek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: ENHANCEMENTS | ||
| body: 'Terraform Test: Add strict mode' | ||
| time: 2026-03-03T08:35:43.709504+01:00 | ||
| custom: | ||
| Issue: "38224" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| variable "input" {} | ||
|
|
||
| resource "test_resource" "resource" { | ||
| value = var.input | ||
| } |
13 changes: 13 additions & 0 deletions
13
internal/command/testdata/test/strict-warnings-plan/main.tftest.hcl
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| run "test" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| input = "Hello, world!" | ||
| undeclared = "this triggers a warning" | ||
| } | ||
|
|
||
| assert { | ||
| condition = test_resource.resource.value == "Hello, world!" | ||
| error_message = "bad value" | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
It may be important to clarify what kind of warnings we are turning into an error. In my opinion, the warnings here are not about the operation made by the run, but by declaring an unused variable within the test, and I would argue that should not cause the test to fail, even in strict mode. The warning we should be focused on are the ones produced by the test's execution of a terraform operation (plan/apply)
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.
Hey @garvitarai1 would you mind chiming in here?
The original Issue is this one .
We wonder what should constitute the strict mode - whether we should report every warning as an error (similar to some other toolings in other languages) or we should be selective with promotion of warnings to errors to the scope Sams proposed in the message above?
And the more important question is - does having one datapoint about the nice-to-have strict mode in "discuss" 2.5 years ago warrants introducing this mode?
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.
I checked Jira and quickly scanned GH issues as well, so this seems like a one off request. I have the same instinct as Sams that not all warnings are equal, and this might be a noisy experience to promote all warnings to errors.
I think the path forward depends on where the implementation stands. If the work is done, then I'd vote for shipping this as an experiment in an alpha release. In this case, let's bring this to the team meeting to get more opinions on the behaviour. If it needs significant effort, then lets de-prioritize.