Comments (7)
That's a very fair question. I don't think we considered people who might have pre-created approval files, and for whom the extra character written out might be a problem.
If we were to change the behaviour of StringWriter, we would break a whole load of existing tests, so this will need some thought.
An idea for a temporary workaround: we recently made it quite easy to supply custom writer implementation, so perhaps you could try supplying your own writer class that didn't add the extra newline?
There is documentation here: https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/Writers.md#top
from approvaltests.cpp.
I might try that.
Also, I need to look into writing the "received" file myself, as I'm generating it with an external program that can easily save to file itself. I suspect that might look like a custom Writer that can format the raw data.
from approvaltests.cpp.
I'm not sure about this, but if all your tests are using pre-created data and calling external programs, it's starting to sound to me like maybe the Python implementation of Approval Tests might give you what you need - https://github.com/approvals/ApprovalTests.Python
Assuming you stick with the C++ version, there's one potential pitfall with the naming of the pure virtual methods in ApprovalWriter that we have not documented:
https://github.com/approvals/ApprovalTests.cpp/blob/master/ApprovalTests/core/ApprovalWriter.h
The cleanUpReceived()
method might sound like it is allowed to tweak the contents of the received file, but you should do any customisation of writing in write()
- and in fact cleanUpReceived()
is called to delete the received file on disk, if the test succeeded.
from approvaltests.cpp.
Oh - one more thought - is verifyExistingFile() any use to you:
ApprovalTests.cpp/ApprovalTests/Approvals.h
Line 143 in 01278b9
It is for when some other process already wrote out the received file, and so Approval Tests does not need to write anything...
from approvaltests.cpp.
verifyExistingFile
sent me down a weird path, with an empty .approved.1
file being generated. Creating a custom writer is working nicely.
For context, the code under test is being executed from within the approval tests, the external program is just for converting binary image files into something diff-able.
from approvaltests.cpp.
The Reporter implementations that launch a diffing tool have to create an approved file, if it doesn’t yet exist, so that the diffing tool will launch and allow received to be copied to approved... Otherwise, most diff tools would just refuse to launch, saying one file did not exist.
So this is expected behaviour for most cases when first running a new Approvals test.
Glad you got the custom writer working!
Do you think this ticket needs any work now?
(I’ll probably leave it open anyway, as a reminder to document the things we talked about)
from approvaltests.cpp.
Thanks, I don't think I need anything more out of this issue.
from approvaltests.cpp.
Related Issues (20)
- Add clang12 CI build HOT 1
- Provide a script to allow users to generate the single header from the current code, without doing a release HOT 9
- Add a documentation example showing how to obtain ApprovalTests.cpp via CPM.cmake HOT 1
- Add vcpkg to our release process HOT 2
- Document how to use Approval Tests with vcpkg HOT 1
- Bullet lists not rendered correcting on Read the Docs version of our documentation HOT 3
- Add a copyright statement to the released single header HOT 1
- GitHub Actions: Don't run scheduled tasks on forked repos
- Using kdiff3 as diff tool, user has to specify name of output file after merge
- cygwin CI build hangs for 6 hours then fails HOT 5
- warning C4459 in MSVC with /W4 HOT 1
- Does not compile with clang13 due to -Werror/-Wdeprecated-copy-with-dtor HOT 2
- Ninja + Catch2 + mingw64
- useApprovalsSubdirectory() doesn't create the output directory in the expected location HOT 3
- "Unable to create directory" - unable to run test build with mingw provided by qt-installer HOT 5
- with CppUTest: `ApprovalMismatchException` suppresses other tests output HOT 4
- add `code -d {Received} {Approved}` to Reporters list
- Catch2 integration does not handle Generators inside sections HOT 1
- Catch2 v3 integration HOT 5
- Bug with {fmt} integration HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from approvaltests.cpp.