From 5a3ad9dfa9976a72cfbc587913c55fa4a7e0757f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 12 Apr 2018 20:53:16 +0100 Subject: Data-driven testDependAll Refactor testDependAll to be a Boost data-driven test. Now a new test case is created for each ebuild cache. --- gentoobrowse-api/unittests/testDependAll.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gentoobrowse-api/unittests/testDependAll.cpp b/gentoobrowse-api/unittests/testDependAll.cpp index 47c7363..5fe0364 100644 --- a/gentoobrowse-api/unittests/testDependAll.cpp +++ b/gentoobrowse-api/unittests/testDependAll.cpp @@ -1,5 +1,6 @@ #define BOOST_TEST_MODULE TestDependAll #include +#include #include #include @@ -7,24 +8,31 @@ #include void -testDependRange(const boost::optional & r) +testDependRange(const std::optional & r) { if (r) { - Portage::Utils::Depend::parse(r->first, r->second); + Portage::Utils::Depend::parse(*r); } } -BOOST_AUTO_TEST_CASE( processAll ) +auto +getFileList() { + std::vector paths; for (boost::filesystem::recursive_directory_iterator d("/usr/portage/metadata/md5-cache"); d != boost::filesystem::recursive_directory_iterator(); d++) { if (boost::filesystem::is_regular_file(d->status())) { - BOOST_TEST_CHECKPOINT(*d); - Gentoo::Utils::EbuildCacheParser ecp(*d); - testDependRange(ecp.getRange("DEPEND")); - testDependRange(ecp.getRange("RDEPEND")); - testDependRange(ecp.getRange("PDEPEND")); + paths.push_back(*d); } } + return paths; +} + +BOOST_DATA_TEST_CASE( processAll, boost::unit_test::data::make(getFileList()), path ) +{ + Gentoo::Utils::EbuildCacheParser ecp(path); + testDependRange(ecp.getRange("DEPEND")); + testDependRange(ecp.getRange("RDEPEND")); + testDependRange(ecp.getRange("PDEPEND")); } -- cgit v1.2.3