approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
316 stars 51 forks source link

Should any pre-existing received file be deleted before the new one is written? #112

Closed claremacrae closed 3 years ago

claremacrae commented 4 years ago

Pairing with a user today, we had some really confusing behaviour where some output .png files were identical, according to BeyondCompare, but the default ApprovalTests.cpp comparator said that they were different.

It turned out that the Juce library .png writer appended to any pre-existing .png file, rather than over-writing it... So once there was a failure, in each successive test run, ApprovalTests just appended more data to the received file, which just kept getting larger and larger!

Should we delete the received file, if it exists at the start of a verify() call?

Are there any situations where this could break existing code?

claremacrae commented 4 years ago

Version: v.8.4.0

isidore commented 3 years ago

This isn't a problem with approvaltests, it's a failing in the custom writer you created. As such I think it is a bad idea to try to systemically fix this unless it is shown to be a common problem.