Prevent early deletion of temp files in specs #377
Merged
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.
After upgrading the bosh/integration image from Ruby 3.2 to 3.3, the shellout types unit spec began frequently failing with errors like:
It seems that Ruby 3.3 is much more aggressive about garbage collection. Several of the Tempfiles created in this spec were referenced only locally in a
let
definition, merely passing their path to the actual object returned by thelet
. Since the Tempfile object itself was no longer being referenced, it would be garbage collected and the file on disk deleted. Otherlet
s that returned the Tempfile directly did not have this problem.Now, all usages of Tempfile are defined in their own
let
, allowing the file to exist until after the test has finished running.