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

some test fails if test_exe ran from current directory other than build/test #351

Open
AryanGitHub opened this issue Sep 26, 2023 · 8 comments
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest hacktoberfest issue Priority:Medium Priority Label for medium priority issue test Something about test

Comments

@AryanGitHub
Copy link
Contributor

Describe the bug
if we run test_exe from some other folder than build/test then some test fails

To Reproduce
Steps to reproduce the behavior:

  1. build the project with the flag DTEST=ON in cmake
  2. check current directory is not build/test, with help of pwd in Linux
  3. run build/test/test_exe not from the current directory build/test folder.

Expected behavior
It should not fail the tests

Screenshots

[  FAILED  ] 5 tests, listed below:
[  FAILED  ] DOTTest.ReadFromDotUndirected
[  FAILED  ] DOTTest.ReadFromDotUndirectedWeighted
[  FAILED  ] DOTTest.ReadFromDotDirected
[  FAILED  ] MTXTest.ReadFromMtxDirectedWeighted
[  FAILED  ] MTXTest.ReadFromMtxUndirectedWeighted

Desktop (please complete the following information):

  • OS: Fedora Linux 38 (Workstation Edition) 64bit
  • Version: 38
@sbaldu
Copy link
Collaborator

sbaldu commented Sep 26, 2023

Yes, those are the tests where we read a graph from file (dot or mtx). If you run from some other folder the relative path is not correct anymore.

@AryanGitHub
Copy link
Contributor Author

Yes, those are the tests where we read a graph from file (dot or mtx). If you run from some other folder the relative path is not correct anymore.

I think we can provide an absolute path from CMake to a variable, and pass it to the program.

@ZigRazor ZigRazor added bug Something isn't working good first issue Good for newcomers test Something about test Priority:Medium Priority Label for medium priority issue hacktoberfest hacktoberfest issue labels Sep 26, 2023
@badumbatish
Copy link
Contributor

Just ran into something like this on my personal project, modern CMake provides the optional named argument WORKING_DIRECTORY to be used together with add_test().

If nobody's gonna try this out i'll give it a try in the next couple weeks

@ZigRazor
Copy link
Owner

Ok @badumbatish !

@badumbatish
Copy link
Contributor

i did some digging around. i'm not sure exactly how to do this, but i think the add_test() working_directory option doesn't affect the working directory on the implementation in OutputOperation_impl.hpp and InputOperation_impl.hpp.

It'd be better if we refactor, for example, writeToDotFile() to accept a std::ofstream File instead of a working dir and file name. This way, we would open a a file in these tests* and pass in the file object instead.

I'm not sure how you feel about this

@ZigRazor
Copy link
Owner

could be a good alternative! you can implement it, aso because after the #427 we need to do a new major release and we can change also the interface!

@badumbatish
Copy link
Contributor

badumbatish commented May 14, 2024

sounds good to me, can i be notified when #427 is finished and MacOS related issues are merged? @ZigRazor

@ZigRazor
Copy link
Owner

YES, Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest hacktoberfest issue Priority:Medium Priority Label for medium priority issue test Something about test
Projects
None yet
Development

No branches or pull requests

4 participants