ApprovalTests.cpp icon indicating copy to clipboard operation
ApprovalTests.cpp copied to clipboard

When creating new approved files, of non-text types, try to make them valid empty files

Open claremacrae opened this issue 4 years ago • 5 comments

Add integration with Simon Cropp's EmptyFiles tool - see https://github.com/VerifyTests/EmptyFiles#tool-usage

We would have to work out the mechanics of this.

claremacrae avatar Feb 17 '21 00:02 claremacrae

Since we don't have an installer mechanism, there's a variety of ways that users can obtain ApprovalTests.cpp, including:

  • via downloading the single header
  • via any package managers
  • git sub-repo or similar
  • CMake's FetchContent

So I think we'll have to train users to install the EmptyFiles tool themselves... (and install dotnet - which won't be standard for pure C++ projects...)

claremacrae avatar Feb 17 '21 00:02 claremacrae

(and install dotnet - which won't be standard for pure C++ projects...)

Simon Cropp pointed to that it's possible to make dotnet exes standalone, so the above wouldn't be needed... https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file

claremacrae avatar Apr 20 '21 06:04 claremacrae

Idea: we could create a seam to generate empty files - and if it detects that empty-file is present, it runs it... We could make the seam, and make it pluggable, and then pick it up later...

claremacrae avatar Aug 30 '21 15:08 claremacrae

The seam/customization point for controlling how new files are created is documented here:

https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Writers.md#empty-files

claremacrae avatar Aug 30 '21 18:08 claremacrae

There is a simpler seam now, that works well for individual file extensions: https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Writers.md#customizing-by-file-extension

claremacrae avatar Sep 10 '21 18:09 claremacrae