-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diffing tool is never prompted to open #223
Comments
Hi, thanks for using Approval Tests. Your setupWhat platform are you running on? Please check the list of supported reporters for your platform: Which of the supported reporters (diff tools) have you got installed on your machine? And are they in the default location that Approval Tests searches for? Or if you are using VSCode as the diff tool, is it in your path? For example, clicking on the 'Snippet Source' links in the above page, you might find that your Araxis Merge installation is not found - in which case, you can search the code for |
If you have installed a diff tool which is not recognised by this project, there are other links on that page for setting up your own custom reporter and making it the default. |
I'm on a Mac OS 13.6.3. I've got both Visual Studio Code and Sublime Merge installed. They are both located on the same path that ApprovalTests should search for. Is there a specific argument that needs to be provided to the test executable? Here's my cmake configuration for completeness sake: FetchContent_Declare(
Catch2
GIT_REPOSITORY "https://github.com/catchorg/Catch2.git"
GIT_TAG "v2.13.10"
)
FetchContent_MakeAvailable(Catch2)
FetchContent_Declare(
ApprovalTests
GIT_REPOSITORY "https://github.com/approvals/ApprovalTests.cpp.git"
GIT_TAG "v.10.12.2"
)
FetchContent_MakeAvailable(ApprovalTests)
file(GLOB UNIT_TESTS CONFIGURE_DEPENDS tests/**/*_spec.cpp)
enable_testing()
foreach(UNIT_TEST ${UNIT_TESTS})
get_filename_component(TEST_BASENAME ${UNIT_TEST} NAME_WE)
add_executable(${TEST_BASENAME} ${CMAKE_CURRENT_SOURCE_DIR}/tests/main_config.cpp ${UNIT_TEST})
add_test(NAME ${TEST_BASENAME} COMMAND ${TEST_BASENAME})
target_compile_features(${TEST_BASENAME} PUBLIC cxx_std_17)
target_link_libraries(${TEST_BASENAME} ApprovalTests::ApprovalTests Catch2::Catch2 playa)
endforeach() |
Thanks for checking. That's surprising. We haven't had any such report previously, so nothing springs to mind about what the cause could be.
Any required arguments are included in the source code for the relevant reporter/diff tool
If your executable builds and runs, it won't be a CMake problem. It's unlikely, but perhaps it may turn out that a diff tool has changed its command line arguments, for example. All I can think of is to help you debug it for yourself. First, please run these commands and tell me what happens:
They should both open up the respective diff tool, and show |
Thanks for the ongoing help @claremacrae. Both commands run fine and show the desired behavior. I was asking about the arguments for the text executable, because I don't see any information regarding any of the diffing tools. When is the approval happening, on build or executable run? |
I think that you are saying that both commands run fine in the console, but when you run your tests and call one of the This is really strange.
In order to offer Convention over configuration, it's a series of steps, and they all happen at run time. In order to make that process visible to developers of the library, our tests create a text file showing the commands and their command-line args generated for all the supported diff tools on all the platforms (plus some invalid combinations, that can be ignored) I copied the command-lines I gave you to test, from that file - so I am confident that I gave you the command-lines to execute that Approval Tests would be executing, if there was nothing in the user's source code to override the way that Approval Tests searches for diff tools. Please can you show the source code of the test that does not pop up a diff command? Many thanks. |
Yes exactly.
Why is the MacOS command here's the test file: #include <catch2/catch.hpp>
#include <vector>
#include "playa/core/event.h"
#include "ApprovalTests/Approvals.h"
TEST_CASE("Event Test suite")
{
using namespace playa;
SECTION("should expand rhythm into events")
{
// when
auto events = Event::expandDuration(Rhythm<4>{n4, n4, n4, n4}, 0);
etl::vector expected{Event{0u, n4, n4}, Event{n4, n4, n2}, Event{n4 * 2u, n4, n2 + n4}, Event{n4 * 3u, n4, n1}};
auto expected_str = std::vector(events.begin(), events.end());
// then
ApprovalTests::Approvals::verifyAll("Expand Rhythms simple", expected_str);
}
} Full error:
|
No, that is covered by the "(plus some invalid combinations, that can be ignored)" comment above. One of the steps that the code does is to first check whether the given exe/script path exists on the machine running the tests, and if it doesn't, it goes on to the next candidate reporter in the list. This is a well-tried pattern over many implementations of Approval Tests in many different languages.
Thank you.
Yes, so that never reached the Approval Tests code. Approvals has a very specific message if it cannot find a reporter. Also, it's telling you it crashed in line 13, which is this one: auto events = Event::expandDuration(Rhythm<4>{n4, n4, n4, n4}, 0); |
I'm still super confused though, as in your original report above you said:
But that |
I'm using |
So it works fine when I switch to: |
Thank you for the update and the extra information. I'll close the ticket, as no action is required. |
I have the following statements in a test case, which generates a
.received
file when I build the tests. When I run the tests the diffing tool never opens up and the test crashes due to the errorApprovalMissingException
.I'm using v10.12.2 and Catch2 v2.13.10.
The text was updated successfully, but these errors were encountered: