Skip to content
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

useApprovalsSubdirectory() doesn't create the output directory in the expected location #196

Open
Bktero opened this issue Apr 26, 2022 · 3 comments

Comments

@Bktero
Copy link

Bktero commented Apr 26, 2022

Hello

From documentation, we can read:

Note that the sub-directory is created automatically and that it will be inside the directory containing the source code of the test, not the current working directory of the test process.

This is not what I get in my project:

image

We can see in the screenshot that the output_test_case is created in CMAKE_BINARY_DIR instead of CMAKE_SOURCE_DIR, as
we would expect because this is where tests.cpp is located. I have the same issue with Makefile and Ninja generators, btw.

Best regards
Pierre

@claremacrae
Copy link
Collaborator

Hi Pete, your screenshot is very clear in showing the problem.

I just checked and our GitHub Actions builds are still running and passing on a wide range of environments. The fact that they are passing tells me that the approved files in the repo (and not the build dir) are being found OK.

I think if this was a common problem, we would have had a lot more reports about it.

However, in case it's caused by a newer version of some tool or other, I would like to try and get to the bottom of it.

So the thing we need to work out is how your build differs from those that successfully place the approved and received files alongside the source code.

Is your project on GitHub, for me to test it out?

If not, please give me as much info as possible about the setup, including:

  • all the CMake files
  • the presets
  • the command-line args used to run CMake
  • The compiler with version

Thanks in advance.

@claremacrae
Copy link
Collaborator

I see you also submitted #195 - sorry not to have looked at that.

Is this the same problem, or something different?

@Bktero
Copy link
Author

Bktero commented Apr 27, 2022

There is now a project on GitHub to reproduce the issue (at least on my computer): https://github.com/Bktero/useApprovalsSubdirectoryBug

Writing this project, I found out that the issue depends on the generator. With MinGW Makefiles, it works; with Unix Makefiles, it doesn't. I have added the presets in the project.

I thought it was a different issue from #195 but now I think #195 is not completely relevant. Indeed, with the project I have just shared, you can reproduce #195 (and something very similar). To do so, remove the call to useApprovalsSubdirectory() in test.cpp. With the "failing" preset and you will get:

C:\......\useApprovalsSubdirectoryBug\test.cpp:4: Failure:
due to unexpected exception with message:
  Failed Approval: 
Approval File Not Found 
File: "C:\......\useApprovalsSubdirectoryBug\test.MyTestCase.approved.txt"

The "successful" preset correctly creates the file. I hence tend to believe both #195 and #196 are linked (maybe the same).


Details about my setup:

  • Catch 2.13.7
  • ApprovalTests 10.12.2
  • CMake 3.21.1
  • gcc 11.2.0 (Rev10, Built by MSYS2 project)
  • Windows 10 Entreprise (version 21H2, build 19044.1645)

Note that the project generates warnings:

C:/..../ApprovalTests.v.10.12.2.hpp:393:13: warning: 'errno_t getenv_s(size_t*, char*, size_t, const char*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]

Is this is an issue in ApprovalTests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants