snitch-org / snitch

Lightweight C++20 testing framework.
Boost Software License 1.0
268 stars 10 forks source link

The library contains absolute paths to the build directory #62

Closed tocic closed 1 year ago

tocic commented 1 year ago
git clone https://github.com/cschreib/snitch.git
cd "snitch/"
mkdir "build/"
cmake -B "build/" -S .
cmake --build "build/"
strings "build/libsnitch.a" | grep "tocic"

results in

/home/tocic/snitch/src/snitch.cpp

, i.e. the library contains references to its build directory. It should not contain them for reproducibility.

These strings come from the __FILE__ macro expansions in

https://github.com/cschreib/snitch/blob/eaa322ce9e7bbfbd0b39aa529ea59de4acbd9c42/src/snitch.cpp#L924-L926

and

https://github.com/cschreib/snitch/blob/eaa322ce9e7bbfbd0b39aa529ea59de4acbd9c42/src/snitch.cpp#L944

, which also means that the following program

#include <snitch/snitch.hpp>

TEST_CASE("Test location") {
  throw 42;
}

will report

starting tests with snitch v
==========================================
failed: running test case "Test location"
          at /home/tocic/snitch/src/snitch.cpp:926
          unhandled unknown exception caught
==========================================
error: some tests failed (1 out of 1 test cases, 0 assertions, 0.000029 seconds)

, though the path to the test file was expected to be printed.

cschreib commented 1 year ago

Thanks for reporting this! I will address it in the next version.