build: make manpage_test work in split build

This commit is contained in:
Marcus Holland-Moritz 2024-08-12 11:11:12 +02:00
parent f646572ca2
commit d010ba2322
2 changed files with 25 additions and 8 deletions

View File

@ -445,7 +445,7 @@ if(WITH_TESTS)
)
endif()
if(WITH_TOOLS AND WITH_MAN_OPTION)
if((WITH_TOOLS OR WITH_FUSE_DRIVER) AND WITH_MAN_OPTION)
list(APPEND DWARFS_TESTS manpage_test)
endif()
@ -474,8 +474,12 @@ if(WITH_TESTS)
endif()
if(TARGET manpage_test)
target_link_libraries(manpage_test PRIVATE mkdwarfs_main dwarfsck_main dwarfsextract_main)
if(WITH_TOOLS)
target_compile_definitions(manpage_test PRIVATE DWARFS_WITH_TOOLS)
target_link_libraries(manpage_test PRIVATE mkdwarfs_main dwarfsck_main dwarfsextract_main)
endif()
if(WITH_FUSE_DRIVER)
target_compile_definitions(manpage_test PRIVATE DWARFS_WITH_FUSE_DRIVER)
target_link_libraries(manpage_test PRIVATE dwarfs_main)
endif()
endif()

View File

@ -24,10 +24,15 @@
#include <map>
#include <regex>
#include <string>
#include <string_view>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/map.hpp>
#include <dwarfs/tool/main_adapter.h>
#include <dwarfs/tool/pager.h>
#include <dwarfs/tool/render_manpage.h>
@ -50,21 +55,31 @@ struct tool_defs {
};
std::map<std::string, tool_defs> const tools = {
#ifdef DWARFS_WITH_TOOLS
{"mkdwarfs", {manpage::get_mkdwarfs_manpage(), mkdwarfs_main, "-H", false}},
{"dwarfs", {manpage::get_dwarfs_manpage(), dwarfs_main, "-h", true}},
{"dwarfsck", {manpage::get_dwarfsck_manpage(), dwarfsck_main, "-h", false}},
{"dwarfsextract",
{manpage::get_dwarfsextract_manpage(), dwarfsextract_main, "-h", false}},
#endif
#ifdef DWARFS_WITH_FUSE_DRIVER
{"dwarfs", {manpage::get_dwarfs_manpage(), dwarfs_main, "-h", true}},
#endif
};
auto const render_tests = ranges::views::keys(tools) | ranges::to<std::vector>;
std::array const coverage_tests{
#ifdef DWARFS_WITH_TOOLS
"mkdwarfs"s,
"dwarfsck"s,
"dwarfsextract"s,
#endif
#ifdef DWARFS_WITH_FUSE_DRIVER
#ifndef DWARFS_TEST_RUNNING_ON_ASAN
// FUSE driver is leaky, so we don't run this test under ASAN
"dwarfs"s,
#endif
#endif
};
} // namespace
@ -86,11 +101,9 @@ TEST_P(manpage_render_test, basic) {
}
}
INSTANTIATE_TEST_SUITE_P(
dwarfs, manpage_render_test,
::testing::Combine(::testing::Values("mkdwarfs", "dwarfs", "dwarfsck",
"dwarfsextract"),
::testing::Bool()));
INSTANTIATE_TEST_SUITE_P(dwarfs, manpage_render_test,
::testing::Combine(::testing::ValuesIn(render_tests),
::testing::Bool()));
namespace {