approvals / approvals/ApprovalTests.cpp
Ninja + Catch2 + mingw64
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 339
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
Hello
I am sorry to open yet another bug about Ninja. I had a look at the very long https://github.com/approvals/ApprovalTests.cpp/pull/79 and https://github.com/approvals/ApprovalTests.cpp/issues/74 and I understood that Ninja is a problem, but also that this problem have been solved.
Sadly I still get errors in this the following configuration :
- Windows 10
- Ninja 1.10.2
- Catch 2.13.7
- ApprovalTests 10.12.2
- GCC 11.2.0 (from MSYS/mingw64)
My project structure:

My preset:
{
"version": 3,
"configurePresets": [
{
"name": "with-gcc",
"generator": "Ninja",
"binaryDir": "${sourceDir}/cmake-build-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "gcc.exe",
"CMAKE_CXX_COMPILER": "g++.exe"
}
}
],
"buildPresets": [
{
"name": "with-gcc",
"configurePreset": "with-gcc"
}
]
}
tests.cpp =
#include <iostream>
#include "ApprovalTests.hpp"
#include "catch2/catch.hpp"
TEST_CASE("MyTestCase") {
std::cout << "__FILE__ == " << __FILE__ << '\n';
ApprovalTests::Approvals::verify("something");
}
main.cpp =
#define APPROVALS_CATCH
#include "ApprovalTests.hpp"
//auto directoryDisposer = ApprovalTests::Approvals::useApprovalsSubdirectory("approval_tests");
Like this I get the following error:
__FILE__ == C:/Users/z19100018/CLionProjects/ninja_approvaltests/tests.cpp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja_approvaltests.exe is a Catch v2.13.7 host application.
Run with -? for options
-------------------------------------------------------------------------------
MyTestCase
-------------------------------------------------------------------------------
C:/Users/z19100018/CLionProjects/ninja_approvaltests/tests.cpp:5
...............................................................................
C:/Users/z19100018/CLionProjects/ninja_approvaltests/tests.cpp:5: FAILED:
due to unexpected exception with message:
Unable to create directory:
===============================================================================
test cases: 1 | 1 failed
assertions: 1 | 1 failed
Process finished with exit code 1
If I uncomment the line with useApprovalsSubdirectory(), it works:
__FILE__ == C:/Users/z19100018/CLionProjects/ninja_approvaltests/tests.cpp
===============================================================================
All tests passed (1 assertion in 1 test case)
Process finished with exit code 0
Here, we can see that the path provided by Ninja in __FILE__ is absolute. The issues linked above say that the problem is supposed to come from relative paths.
Any thoughts on this?
Thanks a lot!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the supplied CMake preset, Ninja, Catch2, and the tests.cpp/main.cpp examples. Start by reading ApprovalTests.hpp around approval directory creation and how FILE is used, then compare behavior with useApprovalsSubdirectory() enabled. Done means the provided configuration creates the approval directory and the test passes without that workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100