[vcpkg] Remove overload of StatusParagraphs::find_installed()

This commit is contained in:
Robert Schumacher 2018-01-23 02:36:39 -08:00
parent ff8a2d1726
commit 78d3302940
7 changed files with 32 additions and 23 deletions

View File

@ -6,6 +6,7 @@
#include <vcpkg/packagespec.h>
#include <vcpkg/packagespecparseresult.h>
#include <vcpkg/statusparagraph.h>
#include <vcpkg/triplet.h>
#include <memory>
@ -38,3 +39,5 @@ T&& unwrap(vcpkg::Optional<T>&& opt)
Assert::IsTrue(opt.has_value());
return std::move(*opt.get());
}
vcpkg::PackageSpec unsafe_pspec(std::string name, vcpkg::Triplet t = vcpkg::Triplet::X86_WINDOWS);

View File

@ -23,11 +23,8 @@ namespace vcpkg
std::vector<const std::unique_ptr<StatusParagraph>*> find_all_installed(const PackageSpec& spec) const;
const_iterator find_installed(const PackageSpec& spec) const
{
return find_installed(spec.name(), spec.triplet());
}
const_iterator find_installed(const std::string& name, const Triplet& triplet) const;
const_iterator find_installed(const PackageSpec& spec) const;
bool is_installed(const PackageSpec& spec) const;
iterator insert(std::unique_ptr<StatusParagraph>);

View File

@ -504,13 +504,6 @@ namespace UnitTest1
}
};
static PackageSpec unsafe_pspec(std::string name, Triplet t = Triplet::X86_WINDOWS)
{
auto m_ret = PackageSpec::from_name_and_triplet(name, t);
Assert::IsTrue(m_ret.has_value());
return m_ret.value_or_exit(VCPKG_LINE_INFO);
}
class RemovePlanTests : public TestClass<RemovePlanTests>
{
TEST_METHOD(basic_remove_scheme)

View File

@ -1,5 +1,7 @@
#include "tests.pch.h"
#include <tests.utils.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace vcpkg;
@ -25,7 +27,7 @@ Status: install ok installed
StatusParagraphs status_db(Util::fmap(
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
Assert::IsTrue(it != status_db.end());
}
@ -45,7 +47,7 @@ Status: purge ok not-installed
StatusParagraphs status_db(Util::fmap(
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
Assert::IsTrue(it == status_db.end());
}
@ -73,7 +75,7 @@ Status: purge ok not-installed
StatusParagraphs status_db(Util::fmap(
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
Assert::IsTrue(it != status_db.end());
}
};

View File

@ -59,3 +59,10 @@ std::unique_ptr<StatusParagraph> make_status_feature_pgh(const char* name,
{"Depends", depends},
{"Status", "install ok installed"}});
}
PackageSpec unsafe_pspec(std::string name, Triplet t)
{
auto m_ret = PackageSpec::from_name_and_triplet(name, t);
Assert::IsTrue(m_ret.has_value());
return m_ret.value_or_exit(VCPKG_LINE_INFO);
}

View File

@ -269,10 +269,10 @@ namespace vcpkg::Build
std::vector<PackageSpec> missing_specs;
for (auto&& dep : filter_dependencies(config.scf.core_paragraph->depends, triplet))
{
if (status_db.find_installed(dep, triplet) == status_db.end())
auto spec = PackageSpec::from_name_and_triplet(dep, triplet).value_or_exit(VCPKG_LINE_INFO);
if (!status_db.is_installed(spec))
{
missing_specs.push_back(
PackageSpec::from_name_and_triplet(dep, triplet).value_or_exit(VCPKG_LINE_INFO));
missing_specs.push_back(spec);
}
}
// Fail the build if any dependencies were missing

View File

@ -65,16 +65,23 @@ namespace vcpkg
});
}
StatusParagraphs::const_iterator StatusParagraphs::find_installed(const std::string& name,
const Triplet& triplet) const
StatusParagraphs::const_iterator StatusParagraphs::find_installed(const PackageSpec& spec) const
{
const const_iterator it = find(name, triplet);
auto it = find(spec);
if (it != end() && (*it)->is_installed())
{
return it;
}
else
{
return end();
}
}
return end();
bool vcpkg::StatusParagraphs::is_installed(const PackageSpec& spec) const
{
auto it = find(spec);
return it != end() && (*it)->is_installed();
}
StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr<StatusParagraph> pgh)