[vcpkg] Remove overload of StatusParagraphs::find_installed()
MODIFY
include/tests.utils.h
include/tests.utils.h
#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);

MODIFY
include/vcpkg/statusparagraphs.h
include/vcpkg/statusparagraphs.h
@@ -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>);

MODIFY
src/tests.plan.cpp
src/tests.plan.cpp
@@ -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)

MODIFY
src/tests.statusparagraphs.cpp
src/tests.statusparagraphs.cpp
#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());
}
};

MODIFY
src/tests.utils.cpp
src/tests.utils.cpp
@@ -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);
+}

MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -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

MODIFY
src/vcpkg/statusparagraphs.cpp
src/vcpkg/statusparagraphs.cpp
@@ -65,17 +65,24 @@ 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();
}
+ }
+
+ 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)
{

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