unit_tests: set default data dir to the source tree at build time

This commit is contained in:
moneromooo-monero 2018-05-15 20:38:27 +01:00
parent 52f6b33890
commit b88c9a003e
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
2 changed files with 5 additions and 8 deletions

View file

@ -103,6 +103,8 @@ if (NOT MSVC)
COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") COMPILE_FLAGS " -Wno-undef -Wno-sign-compare")
endif () 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) SET_PROPERTY(SOURCE memwipe.cpp PROPERTY COMPILE_FLAGS -Ofast)
add_test( add_test(

View file

@ -61,8 +61,8 @@ int main(int argc, char** argv)
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
po::options_description desc_options("Command line options"); po::options_description desc_options("Command line options");
const command_line::arg_descriptor<std::string> arg_data_dir = { "data-dir", "Data files directory" }; 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, ""); command_line::add_arg(desc_options, arg_data_dir);
po::variables_map vm; po::variables_map vm;
bool r = command_line::handle_error_helper(desc_options, [&]() bool r = command_line::handle_error_helper(desc_options, [&]()
@ -74,11 +74,6 @@ int main(int argc, char** argv)
if (! r) if (! r)
return 1; 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(); return RUN_ALL_TESTS();