From db5f17c4ee208a4523aebc8715554f273607d792 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 2 May 2018 00:17:43 +0100 Subject: Make testDependAll more generic ready for other things --- gentoobrowse-api/unittests/Jamfile.jam | 6 ++--- gentoobrowse-api/unittests/testDependAll.cpp | 38 --------------------------- gentoobrowse-api/unittests/testProcessAll.cpp | 37 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 41 deletions(-) delete mode 100644 gentoobrowse-api/unittests/testDependAll.cpp create mode 100644 gentoobrowse-api/unittests/testProcessAll.cpp diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam index 0df060c..94f2b89 100644 --- a/gentoobrowse-api/unittests/Jamfile.jam +++ b/gentoobrowse-api/unittests/Jamfile.jam @@ -69,13 +69,13 @@ run testCommon : testMasks ; -explicit testDependAll ; +explicit testProcessAll ; run - testDependAll.cpp ../service/utils/ebuildCacheParser.cpp ../service/depend.cpp + testProcessAll.cpp ../service/utils/ebuildCacheParser.cpp ../service/depend.cpp : : : BOOST_TEST_DYN_LINK testCommon - : testDependAll ; + ; run testNews.cpp ../service/news.cpp diff --git a/gentoobrowse-api/unittests/testDependAll.cpp b/gentoobrowse-api/unittests/testDependAll.cpp deleted file mode 100644 index 5fe0364..0000000 --- a/gentoobrowse-api/unittests/testDependAll.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#define BOOST_TEST_MODULE TestDependAll -#include -#include - -#include -#include -#include -#include - -void -testDependRange(const std::optional & r) -{ - if (r) { - Portage::Utils::Depend::parse(*r); - } -} - -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())) { - 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")); -} - diff --git a/gentoobrowse-api/unittests/testProcessAll.cpp b/gentoobrowse-api/unittests/testProcessAll.cpp new file mode 100644 index 0000000..cd72a8c --- /dev/null +++ b/gentoobrowse-api/unittests/testProcessAll.cpp @@ -0,0 +1,37 @@ +#define BOOST_TEST_MODULE TestProcessAll +#include +#include + +#include +#include +#include +#include + +void +testDependRange(const std::optional & r) +{ + if (r) { + Portage::Utils::Depend::parse(*r); + } +} + +auto +getFileList(const boost::filesystem::path & root, bool(*pred)(const boost::filesystem::path &)) +{ + std::vector paths; + std::copy_if(boost::filesystem::recursive_directory_iterator(root), + boost::filesystem::recursive_directory_iterator(), + std::back_inserter(paths), pred); + return paths; +} + +BOOST_DATA_TEST_CASE( ebuildCacheDependencies, boost::unit_test::data::make( + getFileList("/usr/portage/metadata/md5-cache", boost::filesystem::is_regular_file)), + path ) +{ + Gentoo::Utils::EbuildCacheParser ecp(path); + testDependRange(ecp.getRange("DEPEND")); + testDependRange(ecp.getRange("RDEPEND")); + testDependRange(ecp.getRange("PDEPEND")); +} + -- cgit v1.2.3