diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-12 20:53:16 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-04-12 20:53:16 +0100 |
commit | 5a3ad9dfa9976a72cfbc587913c55fa4a7e0757f (patch) | |
tree | d7c63b9f83c5612d7e0ba30872f6bc4dd8be9e86 | |
parent | Apply some C++17 love. (diff) | |
download | gentoobrowse-api-5a3ad9dfa9976a72cfbc587913c55fa4a7e0757f.tar.bz2 gentoobrowse-api-5a3ad9dfa9976a72cfbc587913c55fa4a7e0757f.tar.xz gentoobrowse-api-5a3ad9dfa9976a72cfbc587913c55fa4a7e0757f.zip |
Data-driven testDependAll
Refactor testDependAll to be a Boost data-driven test. Now a new test
case is created for each ebuild cache.
-rw-r--r-- | gentoobrowse-api/unittests/testDependAll.cpp | 24 |
1 files 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 <boost/test/unit_test.hpp> +#include <boost/test/data/test_case.hpp> #include <depend.h> #include <utils/ebuildCacheParser.h> @@ -7,24 +8,31 @@ #include <boost/filesystem/convenience.hpp> void -testDependRange(const boost::optional<Gentoo::Utils::EbuildCacheParser::Range> & r) +testDependRange(const std::optional<std::string_view> & 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<boost::filesystem::path> 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")); } |