Skip to content

Conversation

@liamcervante
Copy link
Member

When executing in verbose display mode, Terraform Test will now include any diagnostics that would normally be excluded due to be expected.

Fixes #34673

Target Release

1.14.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@liamcervante liamcervante requested a review from a team as a code owner July 23, 2025 10:30
Comment on lines +180 to +186
if ctx.Verbose() {
// in verbose mode, we still add all the original diagnostics for
// display even if they are expected.
run.Diagnostics = run.Diagnostics.Append(diags)
} else {
run.Diagnostics = run.Diagnostics.Append(unexpectedDiags)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this not likely change the status of the run?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are we saying that's okay in verbose mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it does anymore. I made a change recently where it is much more explicit about setting the status. So, I think from after this point it doesn't look at the set of run.Diagnostics as a whole to work out the test status anymore but sets it's explicitly based on checks made at each stage.

For example see here for apply and here for plan. In both cases, the status is computed based on just the diagnostics of the current step and then set separately to the big collection of diagnostics.

So, I think at this stage it is safe to add error diagnostics into the general diagnostics as long as we're not actually changing the result of the test when doing this.

@liamcervante liamcervante requested a review from dsa0x July 23, 2025 13:30
@liamcervante liamcervante merged commit 160b6b3 into main Jul 24, 2025
8 checks passed
@liamcervante liamcervante deleted the liamcervante/34673 branch July 24, 2025 09:02
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terraform test - expect_failures does not display the validation rule error message in verbose mode

2 participants