GoogleCloudPlatform / terraform-python-testing-helper

Simple Python test helper for Terraform.
https://pypi.org/project/tftest/
Apache License 2.0
214 stars 31 forks source link

Stop Windows hangs when last output is on stderr #72

Closed andrewesweet closed 1 year ago

andrewesweet commented 1 year ago

Terraform CLI runs sometimes only produce output on stderr, or writes its final output to stderr. Tests for variable validation conditions and pre/post conditions often elicit this behaviour. On Windows 10 and Python 3.9, this leads to a hang. Line 714 (in this PR) is a blocking operation that will never be satisfied given no further standard output will be observed.

This PR hacks around it when running on Windows by redirecting stderr to stdout. This truly is a hack, because later logic from line 724 onwards assumes err will contain stderr but will now always be empty. In practice, this seems to work on Windows OK.

A better solution might be to do something like https://stackoverflow.com/a/4896288. This pushes my limited python-fu.

ludoo commented 1 year ago

Thanks! your two PRs are merged and I just cut v1.8.4

https://pypi.org/project/tftest/1.8.4/