Skip to content
Permalink
Browse files

Set default data dir to the source tree at build time

  • Loading branch information...
miltonf committed Apr 12, 2019
1 parent bf9c9f2 commit 2d71b3252c045d84edad66e4a8ff33e792973104
Showing with 5 additions and 8 deletions.
  1. +2 −0 tests/unit_tests/CMakeLists.txt
  2. +3 −8 tests/unit_tests/main.cpp
@@ -104,6 +104,8 @@ if (NOT MSVC)
COMPILE_FLAGS " -Wno-undef -Wno-sign-compare")
endif ()

SET_PROPERTY(SOURCE main.cpp PROPERTY COMPILE_FLAGS -DDEFAULT_DATA_DIR="\\"${CMAKE_SOURCE_DIR}/tests/data\\"")

SET_PROPERTY(SOURCE memwipe.cpp PROPERTY COMPILE_FLAGS -Ofast)

add_test(
@@ -61,8 +61,8 @@ int main(int argc, char** argv)
::testing::InitGoogleTest(&argc, argv);

po::options_description desc_options("Command line options");
const command_line::arg_descriptor<std::string> arg_data_dir = { "data-dir", "Data files directory" };
command_line::add_arg(desc_options, arg_data_dir, "");
const command_line::arg_descriptor<std::string> arg_data_dir = { "data-dir", "Data files directory", DEFAULT_DATA_DIR };
command_line::add_arg(desc_options, arg_data_dir);

po::variables_map vm;
bool r = command_line::handle_error_helper(desc_options, [&]()
@@ -74,12 +74,7 @@ int main(int argc, char** argv)
if (! r)
return 1;

if (command_line::is_arg_defaulted(vm, arg_data_dir))
unit_test::data_dir = boost::filesystem::canonical(boost::filesystem::path(epee::string_tools::get_current_module_folder()))
.parent_path().parent_path().parent_path().parent_path()
.append("tests").append("data");
else
unit_test::data_dir = command_line::get_arg(vm, arg_data_dir);
unit_test::data_dir = command_line::get_arg(vm, arg_data_dir);

return RUN_ALL_TESTS();
}

0 comments on commit 2d71b32

Please sign in to comment.
You can’t perform that action at this time.