Rewrite the tests! now they're cross-platform! (#7315)
* begin exploratory rewriting of tests * continue working on tests * more test work! holy butts vcpkg-tests/plan.cpp was a bunch of work * finish writing new tests - [x] write catch2 tests - [ ] rewrite/at least delete the VS project files - [ ] document running tests * Fix tests to work on WSL, rewrite test vcxproj still need to test on macOS also, delete tests.pch.h * Condense add_test calls
This commit is contained in:
Родитель
304480338c
Коммит
5cdd8d3a46
|
@ -28,6 +28,7 @@ Cpp11BracedListStyle: true
|
|||
IndentCaseLabels: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
NamespaceIndentation: All
|
||||
ForEachMacros: [TEST_CASE, SECTION]
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
|
|
|
@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.3)
|
|||
|
||||
project(vcpkg C CXX)
|
||||
|
||||
enable_testing()
|
||||
|
||||
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
|
||||
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
|
||||
|
||||
|
@ -33,6 +35,7 @@ if(GCC OR CLANG)
|
|||
endif()
|
||||
|
||||
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
|
||||
file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-tests/*.cpp)
|
||||
|
||||
if (DEFINE_DISABLE_METRICS)
|
||||
set(DISABLE_METRICS_VALUE "1")
|
||||
|
@ -44,6 +47,15 @@ add_executable(vcpkg src/vcpkg.cpp ${VCPKGLIB_SOURCES})
|
|||
target_compile_definitions(vcpkg PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
|
||||
target_include_directories(vcpkg PRIVATE include)
|
||||
|
||||
|
||||
add_executable(vcpkg-test EXCLUDE_FROM_ALL ${VCPKGTEST_SOURCES} ${VCPKGLIB_SOURCES})
|
||||
target_compile_definitions(vcpkg-test PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
|
||||
target_include_directories(vcpkg-test PRIVATE include)
|
||||
|
||||
foreach(TEST_NAME arguments chrono dependencies paragraph plan specifier supports)
|
||||
add_test(${TEST_NAME} vcpkg-test [${TEST_NAME}])
|
||||
endforeach()
|
||||
|
||||
if(CLANG)
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("#include <iostream>
|
||||
|
@ -57,8 +69,10 @@ endif()
|
|||
|
||||
if(GCC OR (CLANG AND USES_LIBSTDCXX))
|
||||
target_link_libraries(vcpkg PRIVATE stdc++fs)
|
||||
target_link_libraries(vcpkg-test PRIVATE stdc++fs)
|
||||
elseif(CLANG)
|
||||
target_link_libraries(vcpkg PRIVATE c++fs)
|
||||
target_link_libraries(vcpkg-test PRIVATE c++fs)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <CppUnitTest.h>
|
||||
|
||||
#include <vcpkg/base/chrono.h>
|
||||
#include <vcpkg/base/sortedvector.h>
|
||||
#include <vcpkg/base/strings.h>
|
||||
#include <vcpkg/base/util.h>
|
||||
#include <vcpkg/binaryparagraph.h>
|
||||
#include <vcpkg/dependencies.h>
|
||||
#include <vcpkg/packagespec.h>
|
||||
#include <vcpkg/packagespecparseresult.h>
|
||||
#include <vcpkg/paragraphs.h>
|
||||
#include <vcpkg/sourceparagraph.h>
|
||||
#include <vcpkg/statusparagraph.h>
|
||||
#include <vcpkg/statusparagraphs.h>
|
||||
#include <vcpkg/triplet.h>
|
||||
#include <vcpkg/update.h>
|
||||
#include <vcpkg/vcpkgcmdarguments.h>
|
|
@ -1,76 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <CppUnitTest.h>
|
||||
|
||||
#include <vcpkg/dependencies.h>
|
||||
#include <vcpkg/packagespec.h>
|
||||
#include <vcpkg/packagespecparseresult.h>
|
||||
#include <vcpkg/statusparagraph.h>
|
||||
#include <vcpkg/triplet.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Microsoft::VisualStudio::CppUnitTestFramework
|
||||
{
|
||||
template<>
|
||||
inline std::wstring ToString<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case vcpkg::Dependencies::InstallPlanType::ALREADY_INSTALLED: return L"ALREADY_INSTALLED";
|
||||
case vcpkg::Dependencies::InstallPlanType::BUILD_AND_INSTALL: return L"BUILD_AND_INSTALL";
|
||||
case vcpkg::Dependencies::InstallPlanType::EXCLUDED: return L"EXCLUDED";
|
||||
case vcpkg::Dependencies::InstallPlanType::UNKNOWN: return L"UNKNOWN";
|
||||
default: return ToString(static_cast<int>(t));
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case vcpkg::Dependencies::RequestType::AUTO_SELECTED: return L"AUTO_SELECTED";
|
||||
case vcpkg::Dependencies::RequestType::USER_REQUESTED: return L"USER_REQUESTED";
|
||||
case vcpkg::Dependencies::RequestType::UNKNOWN: return L"UNKNOWN";
|
||||
default: return ToString(static_cast<int>(t));
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t)
|
||||
{
|
||||
return ToString(static_cast<uint32_t>(t));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::wstring ToString<vcpkg::PackageSpec>(const vcpkg::PackageSpec& t)
|
||||
{
|
||||
return ToString(t.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
|
||||
const char* depends = "",
|
||||
const char* default_features = "",
|
||||
const char* triplet = "x86-windows");
|
||||
std::unique_ptr<vcpkg::StatusParagraph> make_status_feature_pgh(const char* name,
|
||||
const char* feature,
|
||||
const char* depends = "",
|
||||
const char* triplet = "x86-windows");
|
||||
|
||||
template<class T, class S>
|
||||
T&& unwrap(vcpkg::ExpectedT<T, S>&& p)
|
||||
{
|
||||
Assert::IsTrue(p.has_value());
|
||||
return std::move(*p.get());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
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);
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,33 @@
|
|||
#include <vcpkg/statusparagraph.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace vcpkg::Test {
|
||||
|
||||
std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
|
||||
const char* depends = "",
|
||||
const char* default_features = "",
|
||||
const char* triplet = "x86-windows");
|
||||
|
||||
std::unique_ptr<vcpkg::StatusParagraph> make_status_feature_pgh(const char* name,
|
||||
const char* feature,
|
||||
const char* depends = "",
|
||||
const char* triplet = "x86-windows");
|
||||
|
||||
vcpkg::PackageSpec unsafe_pspec(std::string name, vcpkg::Triplet t = vcpkg::Triplet::X86_WINDOWS);
|
||||
|
||||
template<class T, class S>
|
||||
T&& unwrap(vcpkg::ExpectedT<T, S>&& p)
|
||||
{
|
||||
REQUIRE(p.has_value());
|
||||
return std::move(*p.get());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T&& unwrap(vcpkg::Optional<T>&& opt)
|
||||
{
|
||||
REQUIRE(opt.has_value());
|
||||
return std::move(*opt.get());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma comment(lib, "version")
|
||||
#pragma comment(lib, "winhttp")
|
||||
#endif
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
using namespace vcpkg;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
class ArgumentTests : public TestClass<ArgumentTests>
|
||||
{
|
||||
TEST_METHOD(create_from_arg_sequence_options_lower)
|
||||
{
|
||||
std::vector<std::string> t = {
|
||||
"--vcpkg-root", "C:\\vcpkg",
|
||||
"--scripts-root=C:\\scripts",
|
||||
"--debug",
|
||||
"--sendmetrics",
|
||||
"--printmetrics",
|
||||
"--overlay-ports=C:\\ports1",
|
||||
"--overlay-ports=C:\\ports2",
|
||||
"--overlay-triplets=C:\\tripletsA",
|
||||
"--overlay-triplets=C:\\tripletsB"
|
||||
};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
Assert::AreEqual("C:\\vcpkg", v.vcpkg_root_dir.get()->c_str());
|
||||
Assert::AreEqual("C:\\scripts", v.scripts_root_dir.get()->c_str());
|
||||
Assert::IsTrue(v.debug && *v.debug.get());
|
||||
Assert::IsTrue(v.sendmetrics && v.sendmetrics.get());
|
||||
Assert::IsTrue(v.printmetrics && *v.printmetrics.get());
|
||||
|
||||
Assert::IsTrue(v.overlay_ports.get()->size() == 2);
|
||||
Assert::AreEqual("C:\\ports1", v.overlay_ports.get()->at(0).c_str());
|
||||
Assert::AreEqual("C:\\ports2", v.overlay_ports.get()->at(1).c_str());
|
||||
|
||||
Assert::IsTrue(v.overlay_triplets.get()->size() == 2);
|
||||
Assert::AreEqual("C:\\tripletsA", v.overlay_triplets.get()->at(0).c_str());
|
||||
Assert::AreEqual("C:\\tripletsB", v.overlay_triplets.get()->at(1).c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(create_from_arg_sequence_options_upper)
|
||||
{
|
||||
std::vector<std::string> t = {
|
||||
"--VCPKG-ROOT", "C:\\vcpkg",
|
||||
"--SCRIPTS-ROOT=C:\\scripts",
|
||||
"--DEBUG",
|
||||
"--SENDMETRICS",
|
||||
"--PRINTMETRICS",
|
||||
"--OVERLAY-PORTS=C:\\ports1",
|
||||
"--OVERLAY-PORTS=C:\\ports2",
|
||||
"--OVERLAY-TRIPLETS=C:\\tripletsA",
|
||||
"--OVERLAY-TRIPLETS=C:\\tripletsB"
|
||||
};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
Assert::AreEqual("C:\\vcpkg", v.vcpkg_root_dir.get()->c_str());
|
||||
Assert::AreEqual("C:\\scripts", v.scripts_root_dir.get()->c_str());
|
||||
Assert::IsTrue(v.debug && *v.debug.get());
|
||||
Assert::IsTrue(v.sendmetrics && v.sendmetrics.get());
|
||||
Assert::IsTrue(v.printmetrics && *v.printmetrics.get());
|
||||
|
||||
Assert::IsTrue(v.overlay_ports.get()->size() == 2);
|
||||
Assert::AreEqual("C:\\ports1", v.overlay_ports.get()->at(0).c_str());
|
||||
Assert::AreEqual("C:\\ports2", v.overlay_ports.get()->at(1).c_str());
|
||||
|
||||
Assert::IsTrue(v.overlay_triplets.get()->size() == 2);
|
||||
Assert::AreEqual("C:\\tripletsA", v.overlay_triplets.get()->at(0).c_str());
|
||||
Assert::AreEqual("C:\\tripletsB", v.overlay_triplets.get()->at(1).c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(create_from_arg_sequence_valued_options)
|
||||
{
|
||||
std::array<CommandSetting, 1> settings = {{{"--a", ""}}};
|
||||
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr};
|
||||
|
||||
std::vector<std::string> t = {"--a=b", "command", "argument"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
auto opts = v.parse_arguments(cmdstruct);
|
||||
Assert::AreEqual("b", opts.settings["--a"].c_str());
|
||||
Assert::AreEqual(size_t{1}, v.command_arguments.size());
|
||||
Assert::AreEqual("argument", v.command_arguments[0].c_str());
|
||||
Assert::AreEqual("command", v.command.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(create_from_arg_sequence_valued_options2)
|
||||
{
|
||||
std::array<CommandSwitch, 2> switches = {{{"--a", ""}, {"--c", ""}}};
|
||||
std::array<CommandSetting, 2> settings = {{{"--b", ""}, {"--d", ""}}};
|
||||
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr};
|
||||
|
||||
std::vector<std::string> t = {"--a", "--b=c"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
auto opts = v.parse_arguments(cmdstruct);
|
||||
Assert::AreEqual("c", opts.settings["--b"].c_str());
|
||||
Assert::IsTrue(opts.settings.find("--d") == opts.settings.end());
|
||||
Assert::IsTrue(opts.switches.find("--a") != opts.switches.end());
|
||||
Assert::IsTrue(opts.settings.find("--c") == opts.settings.end());
|
||||
Assert::AreEqual(size_t{0}, v.command_arguments.size());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace Chrono = vcpkg::Chrono;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
class ChronoTests : public TestClass<ChronoTests>
|
||||
{
|
||||
TEST_METHOD(parse_time)
|
||||
{
|
||||
auto timestring = "1990-02-03T04:05:06.0Z";
|
||||
auto maybe_time = Chrono::CTime::parse(timestring);
|
||||
|
||||
Assert::IsTrue(maybe_time.has_value());
|
||||
|
||||
Assert::AreEqual(timestring, maybe_time.get()->to_string().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_time_blank)
|
||||
{
|
||||
auto maybe_time = Chrono::CTime::parse("");
|
||||
|
||||
Assert::IsFalse(maybe_time.has_value());
|
||||
}
|
||||
|
||||
TEST_METHOD(time_difference)
|
||||
{
|
||||
auto maybe_time1 = Chrono::CTime::parse("1990-02-03T04:05:06.0Z");
|
||||
auto maybe_time2 = Chrono::CTime::parse("1990-02-10T04:05:06.0Z");
|
||||
|
||||
Assert::IsTrue(maybe_time1.has_value());
|
||||
Assert::IsTrue(maybe_time2.has_value());
|
||||
|
||||
auto delta = maybe_time2.get()->to_time_point() - maybe_time1.get()->to_time_point();
|
||||
|
||||
Assert::AreEqual(24 * 7, std::chrono::duration_cast<std::chrono::hours>(delta).count());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma comment(lib, "version")
|
||||
#pragma comment(lib, "winhttp")
|
||||
#endif
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
using namespace vcpkg;
|
||||
using Parse::parse_comma_list;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
class DependencyTests : public TestClass<DependencyTests>
|
||||
{
|
||||
TEST_METHOD(parse_depends_one)
|
||||
{
|
||||
auto v = expand_qualified_dependencies(parse_comma_list("libA (windows)"));
|
||||
Assert::AreEqual(size_t(1), v.size());
|
||||
Assert::AreEqual("libA", v[0].depend.name.c_str());
|
||||
Assert::AreEqual("windows", v[0].qualifier.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(filter_depends)
|
||||
{
|
||||
auto deps = expand_qualified_dependencies(parse_comma_list("libA (windows), libB, libC (uwp)"));
|
||||
auto v = filter_dependencies(deps, Triplet::X64_WINDOWS);
|
||||
Assert::AreEqual(size_t(2), v.size());
|
||||
Assert::AreEqual("libA", v[0].c_str());
|
||||
Assert::AreEqual("libB", v[1].c_str());
|
||||
|
||||
auto v2 = filter_dependencies(deps, Triplet::ARM_UWP);
|
||||
Assert::AreEqual(size_t(2), v.size());
|
||||
Assert::AreEqual("libB", v2[0].c_str());
|
||||
Assert::AreEqual("libC", v2[1].c_str());
|
||||
}
|
||||
};
|
||||
|
||||
class SupportsTests : public TestClass<SupportsTests>
|
||||
{
|
||||
TEST_METHOD(parse_supports_all)
|
||||
{
|
||||
auto v = Supports::parse({
|
||||
"x64",
|
||||
"x86",
|
||||
"arm",
|
||||
"windows",
|
||||
"uwp",
|
||||
"v140",
|
||||
"v141",
|
||||
"crt-static",
|
||||
"crt-dynamic",
|
||||
});
|
||||
Assert::AreNotEqual(uintptr_t(0), uintptr_t(v.get()));
|
||||
|
||||
Assert::IsTrue(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::UWP,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
Assert::IsTrue(v.get()->is_supported(System::CPUArchitecture::ARM,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::STATIC,
|
||||
Supports::ToolsetVersion::V141));
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_supports_invalid)
|
||||
{
|
||||
auto v = Supports::parse({"arm64"});
|
||||
Assert::AreEqual(uintptr_t(0), uintptr_t(v.get()));
|
||||
Assert::AreEqual(size_t(1), v.error().size());
|
||||
Assert::AreEqual("arm64", v.error()[0].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_supports_case_sensitive)
|
||||
{
|
||||
auto v = Supports::parse({"Windows"});
|
||||
Assert::AreEqual(uintptr_t(0), uintptr_t(v.get()));
|
||||
Assert::AreEqual(size_t(1), v.error().size());
|
||||
Assert::AreEqual("Windows", v.error()[0].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_supports_some)
|
||||
{
|
||||
auto v = Supports::parse({
|
||||
"x64",
|
||||
"x86",
|
||||
"windows",
|
||||
});
|
||||
Assert::AreNotEqual(uintptr_t(0), uintptr_t(v.get()));
|
||||
|
||||
Assert::IsTrue(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
Assert::IsFalse(v.get()->is_supported(System::CPUArchitecture::ARM,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
Assert::IsFalse(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::UWP,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
Assert::IsTrue(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::STATIC,
|
||||
Supports::ToolsetVersion::V141));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#include <tests.utils.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma comment(lib, "version")
|
||||
#pragma comment(lib, "winhttp")
|
||||
#endif
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
using namespace vcpkg;
|
||||
|
||||
class SpecifierConversion : public TestClass<SpecifierConversion>
|
||||
{
|
||||
TEST_METHOD(full_package_spec_to_feature_specs)
|
||||
{
|
||||
auto a_spec = PackageSpec::from_name_and_triplet("a", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto b_spec = PackageSpec::from_name_and_triplet("b", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
auto fspecs = FullPackageSpec::to_feature_specs({{a_spec, {"0", "1"}}, {b_spec, {"2", "3"}}});
|
||||
|
||||
Assert::AreEqual(size_t(6), fspecs.size());
|
||||
|
||||
std::array<const char*, 6> features = {"", "0", "1", "", "2", "3"};
|
||||
std::array<PackageSpec*, 6> specs = {&a_spec, &a_spec, &a_spec, &b_spec, &b_spec, &b_spec};
|
||||
|
||||
for (size_t i = 0; i < features.size(); ++i)
|
||||
{
|
||||
Assert::AreEqual(features[i], fspecs[i].feature().c_str());
|
||||
Assert::AreEqual(*specs[i], fspecs[i].spec());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SpecifierParsing : public TestClass<SpecifierParsing>
|
||||
{
|
||||
TEST_METHOD(parsed_specifier_from_string)
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib");
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, maybe_spec.error());
|
||||
auto spec = maybe_spec.get();
|
||||
Assert::AreEqual("zlib", spec->name.c_str());
|
||||
Assert::AreEqual(size_t(0), spec->features.size());
|
||||
Assert::AreEqual("", spec->triplet.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parsed_specifier_from_string_with_triplet)
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib:x64-uwp");
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, maybe_spec.error());
|
||||
auto spec = maybe_spec.get();
|
||||
Assert::AreEqual("zlib", spec->name.c_str());
|
||||
Assert::AreEqual("x64-uwp", spec->triplet.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parsed_specifier_from_string_with_colons)
|
||||
{
|
||||
auto ec = vcpkg::ParsedSpecifier::from_string("zlib:x86-uwp:").error();
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::TOO_MANY_COLONS, ec);
|
||||
}
|
||||
|
||||
TEST_METHOD(parsed_specifier_from_string_with_feature)
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[feature]:x64-uwp");
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, maybe_spec.error());
|
||||
auto spec = maybe_spec.get();
|
||||
Assert::AreEqual("zlib", spec->name.c_str());
|
||||
Assert::IsTrue(spec->features.size() == 1);
|
||||
Assert::AreEqual("feature", spec->features.front().c_str());
|
||||
Assert::AreEqual("x64-uwp", spec->triplet.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parsed_specifier_from_string_with_many_features)
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[0, 1,2]");
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, maybe_spec.error());
|
||||
auto spec = maybe_spec.get();
|
||||
Assert::AreEqual("zlib", spec->name.c_str());
|
||||
Assert::IsTrue(spec->features.size() == 3);
|
||||
Assert::AreEqual("0", spec->features[0].c_str());
|
||||
Assert::AreEqual("1", spec->features[1].c_str());
|
||||
Assert::AreEqual("2", spec->features[2].c_str());
|
||||
Assert::AreEqual("", spec->triplet.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parsed_specifier_wildcard_feature)
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[*]");
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, maybe_spec.error());
|
||||
auto spec = maybe_spec.get();
|
||||
Assert::AreEqual("zlib", spec->name.c_str());
|
||||
Assert::IsTrue(spec->features.size() == 1);
|
||||
Assert::AreEqual("*", spec->features[0].c_str());
|
||||
Assert::AreEqual("", spec->triplet.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(expand_wildcards)
|
||||
{
|
||||
auto zlib =
|
||||
vcpkg::FullPackageSpec::from_string("zlib[0,1]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto openssl =
|
||||
vcpkg::FullPackageSpec::from_string("openssl[*]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto specs = FullPackageSpec::to_feature_specs({zlib, openssl});
|
||||
Util::sort(specs);
|
||||
auto spectargets = FeatureSpec::from_strings_and_triplet(
|
||||
{
|
||||
"openssl",
|
||||
"zlib",
|
||||
"openssl[*]",
|
||||
"zlib[0]",
|
||||
"zlib[1]",
|
||||
},
|
||||
Triplet::X86_UWP);
|
||||
Util::sort(spectargets);
|
||||
Assert::IsTrue(specs.size() == spectargets.size());
|
||||
Assert::IsTrue(Util::all_equal(specs, spectargets));
|
||||
}
|
||||
|
||||
TEST_METHOD(utf8_to_utf16)
|
||||
{
|
||||
auto str = vcpkg::Strings::to_utf16("abc");
|
||||
Assert::AreEqual(L"abc", str.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(utf8_to_utf16_with_whitespace)
|
||||
{
|
||||
auto str = vcpkg::Strings::to_utf16("abc -x86-windows");
|
||||
Assert::AreEqual(L"abc -x86-windows", str.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS(Metrics){};
|
||||
}
|
|
@ -1,441 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma comment(lib, "version")
|
||||
#pragma comment(lib, "winhttp")
|
||||
#endif
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace Strings = vcpkg::Strings;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
class ControlParsing : public TestClass<ControlParsing>
|
||||
{
|
||||
TEST_METHOD(SourceParagraph_Construct_Minimum)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
}});
|
||||
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual("zlib", pgh->core_paragraph->name.c_str());
|
||||
Assert::AreEqual("1.2.8", pgh->core_paragraph->version.c_str());
|
||||
Assert::AreEqual("", pgh->core_paragraph->maintainer.c_str());
|
||||
Assert::AreEqual("", pgh->core_paragraph->description.c_str());
|
||||
Assert::AreEqual(size_t(0), pgh->core_paragraph->depends.size());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Construct_Maximum)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "s"},
|
||||
{"Version", "v"},
|
||||
{"Maintainer", "m"},
|
||||
{"Description", "d"},
|
||||
{"Build-Depends", "bd"},
|
||||
{"Default-Features", "df"},
|
||||
{"Supports", "x64"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual("s", pgh->core_paragraph->name.c_str());
|
||||
Assert::AreEqual("v", pgh->core_paragraph->version.c_str());
|
||||
Assert::AreEqual("m", pgh->core_paragraph->maintainer.c_str());
|
||||
Assert::AreEqual("d", pgh->core_paragraph->description.c_str());
|
||||
Assert::AreEqual(size_t(1), pgh->core_paragraph->depends.size());
|
||||
Assert::AreEqual("bd", pgh->core_paragraph->depends[0].name().c_str());
|
||||
Assert::AreEqual(size_t(1), pgh->core_paragraph->default_features.size());
|
||||
Assert::AreEqual("df", pgh->core_paragraph->default_features[0].c_str());
|
||||
Assert::AreEqual(size_t(1), pgh->core_paragraph->supports.size());
|
||||
Assert::AreEqual("x64", pgh->core_paragraph->supports[0].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Two_Depends)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "z, openssl"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual(size_t(2), pgh->core_paragraph->depends.size());
|
||||
Assert::AreEqual("z", pgh->core_paragraph->depends[0].name().c_str());
|
||||
Assert::AreEqual("openssl", pgh->core_paragraph->depends[1].name().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Three_Depends)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "z, openssl, xyz"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual(size_t(3), pgh->core_paragraph->depends.size());
|
||||
Assert::AreEqual("z", pgh->core_paragraph->depends[0].name().c_str());
|
||||
Assert::AreEqual("openssl", pgh->core_paragraph->depends[1].name().c_str());
|
||||
Assert::AreEqual("xyz", pgh->core_paragraph->depends[2].name().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Three_Supports)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Supports", "x64, windows, uwp"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual(size_t(3), pgh->core_paragraph->supports.size());
|
||||
Assert::AreEqual("x64", pgh->core_paragraph->supports[0].c_str());
|
||||
Assert::AreEqual("windows", pgh->core_paragraph->supports[1].c_str());
|
||||
Assert::AreEqual("uwp", pgh->core_paragraph->supports[2].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Construct_Qualified_Depends)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "libA (windows), libB (uwp)"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual("zlib", pgh->core_paragraph->name.c_str());
|
||||
Assert::AreEqual("1.2.8", pgh->core_paragraph->version.c_str());
|
||||
Assert::AreEqual("", pgh->core_paragraph->maintainer.c_str());
|
||||
Assert::AreEqual("", pgh->core_paragraph->description.c_str());
|
||||
Assert::AreEqual(size_t(2), pgh->core_paragraph->depends.size());
|
||||
Assert::AreEqual("libA", pgh->core_paragraph->depends[0].name().c_str());
|
||||
Assert::AreEqual("windows", pgh->core_paragraph->depends[0].qualifier.c_str());
|
||||
Assert::AreEqual("libB", pgh->core_paragraph->depends[1].name().c_str());
|
||||
Assert::AreEqual("uwp", pgh->core_paragraph->depends[1].qualifier.c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(SourceParagraph_Default_Features)
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "a"},
|
||||
{"Version", "1.0"},
|
||||
{"Default-Features", "a1"},
|
||||
}});
|
||||
Assert::IsTrue(m_pgh.has_value());
|
||||
auto& pgh = *m_pgh.get();
|
||||
|
||||
Assert::AreEqual(size_t(1), pgh->core_paragraph->default_features.size());
|
||||
Assert::AreEqual("a1", pgh->core_paragraph->default_features[0].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_Construct_Minimum)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
|
||||
Assert::AreEqual("zlib", pgh.spec.name().c_str());
|
||||
Assert::AreEqual("1.2.8", pgh.version.c_str());
|
||||
Assert::AreEqual("", pgh.maintainer.c_str());
|
||||
Assert::AreEqual("", pgh.description.c_str());
|
||||
Assert::AreEqual("x86-windows", pgh.spec.triplet().canonical_name().c_str());
|
||||
Assert::AreEqual(size_t(0), pgh.depends.size());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_Construct_Maximum)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "s"},
|
||||
{"Version", "v"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Maintainer", "m"},
|
||||
{"Description", "d"},
|
||||
{"Depends", "bd"},
|
||||
});
|
||||
Assert::AreEqual("s", pgh.spec.name().c_str());
|
||||
Assert::AreEqual("v", pgh.version.c_str());
|
||||
Assert::AreEqual("m", pgh.maintainer.c_str());
|
||||
Assert::AreEqual("d", pgh.description.c_str());
|
||||
Assert::AreEqual(size_t(1), pgh.depends.size());
|
||||
Assert::AreEqual("bd", pgh.depends[0].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_Three_Depends)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
});
|
||||
|
||||
Assert::AreEqual(size_t(3), pgh.depends.size());
|
||||
Assert::AreEqual("a", pgh.depends[0].c_str());
|
||||
Assert::AreEqual("b", pgh.depends[1].c_str());
|
||||
Assert::AreEqual("c", pgh.depends[2].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_Abi)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Abi", "abcd123"},
|
||||
});
|
||||
|
||||
Assert::AreEqual(size_t(0), pgh.depends.size());
|
||||
Assert::IsTrue(pgh.abi == "abcd123");
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_Default_Features)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "a"},
|
||||
{"Version", "1.0"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Default-Features", "a1"},
|
||||
});
|
||||
|
||||
Assert::AreEqual(size_t(0), pgh.depends.size());
|
||||
Assert::AreEqual(size_t(1), pgh.default_features.size());
|
||||
Assert::IsTrue(pgh.default_features[0] == "a1");
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_empty)
|
||||
{
|
||||
const char* str = "";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::IsTrue(pghs.empty());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_one_field)
|
||||
{
|
||||
const char* str = "f1: v1";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(1), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_one_pgh)
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_two_pgh)
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2\n"
|
||||
"\n"
|
||||
"f3: v3\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(2), pghs.size());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
||||
Assert::AreEqual(size_t(2), pghs[1].size());
|
||||
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
||||
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_field_names)
|
||||
{
|
||||
const char* str = "1:\n"
|
||||
"f:\n"
|
||||
"F:\n"
|
||||
"0:\n"
|
||||
"F-2:\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(5), pghs[0].size());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_multiple_blank_lines)
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"f3: v3\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(2), pghs.size());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_empty_fields)
|
||||
{
|
||||
const char* str = "f1:\n"
|
||||
"f2: ";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
Assert::AreEqual("", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("", pghs[0]["f2"].c_str());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_multiline_fields)
|
||||
{
|
||||
const char* str = "f1: simple\n"
|
||||
" f1\r\n"
|
||||
"f2:\r\n"
|
||||
" f2\r\n"
|
||||
" continue\r\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual("simple\n f1", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("\n f2\n continue", pghs[0]["f2"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_crlfs)
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"f2: v2\r\n"
|
||||
"\r\n"
|
||||
"f3: v3\r\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(2), pghs.size());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
||||
Assert::AreEqual(size_t(2), pghs[1].size());
|
||||
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
||||
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_paragraphs_comment)
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"#comment\r\n"
|
||||
"f2: v2\r\n"
|
||||
"#comment\r\n"
|
||||
"\r\n"
|
||||
"#comment\r\n"
|
||||
"f3: v3\r\n"
|
||||
"#comment\r\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(2), pghs.size());
|
||||
Assert::AreEqual(size_t(2), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
||||
Assert::AreEqual(size_t(2), pghs[1].size());
|
||||
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
||||
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_comment_before_single_slashN)
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"#comment\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_serialize_min)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(4), pghs[0].size());
|
||||
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
|
||||
Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str());
|
||||
Assert::AreEqual("x86-windows", pghs[0]["Architecture"].c_str());
|
||||
Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_serialize_max)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Description", "first line\n second line"},
|
||||
{"Maintainer", "abc <abc@abc.abc>"},
|
||||
{"Depends", "dep"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual(size_t(7), pghs[0].size());
|
||||
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
|
||||
Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str());
|
||||
Assert::AreEqual("x86-windows", pghs[0]["Architecture"].c_str());
|
||||
Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str());
|
||||
Assert::AreEqual("first line\n second line", pghs[0]["Description"].c_str());
|
||||
Assert::AreEqual("dep", pghs[0]["Depends"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_serialize_multiple_deps)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_serialize_abi)
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
{"Abi", "123abc"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs.size());
|
||||
Assert::AreEqual("123abc", pghs[0]["Abi"].c_str());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#include "tests.pch.h"
|
1261
src/tests.plan.cpp
1261
src/tests.plan.cpp
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,115 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#include <tests.utils.h>
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
using namespace vcpkg;
|
||||
using namespace vcpkg::Paragraphs;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
class StatusParagraphsTests : public TestClass<StatusParagraphsTests>
|
||||
{
|
||||
TEST_METHOD(find_installed)
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
)");
|
||||
Assert::IsTrue(!!pghs);
|
||||
if (!pghs) return;
|
||||
|
||||
StatusParagraphs status_db(Util::fmap(
|
||||
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
Assert::IsTrue(it != status_db.end());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_not_installed)
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: purge ok not-installed
|
||||
)");
|
||||
Assert::IsTrue(!!pghs);
|
||||
if (!pghs) return;
|
||||
|
||||
StatusParagraphs status_db(Util::fmap(
|
||||
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
Assert::IsTrue(it == status_db.end());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_with_feature_packages)
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
|
||||
Package: ffmpeg
|
||||
Feature: openssl
|
||||
Depends: openssl
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: purge ok not-installed
|
||||
)");
|
||||
Assert::IsTrue(!!pghs);
|
||||
if (!pghs) return;
|
||||
|
||||
StatusParagraphs status_db(Util::fmap(
|
||||
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
Assert::IsTrue(it != status_db.end());
|
||||
|
||||
// Feature "openssl" is not installed and should not be found
|
||||
auto it1 = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"});
|
||||
Assert::IsTrue(it1 == status_db.end());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_for_feature_packages)
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
|
||||
Package: ffmpeg
|
||||
Feature: openssl
|
||||
Depends: openssl
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
)");
|
||||
Assert::IsTrue(!!pghs);
|
||||
if (!pghs) return;
|
||||
|
||||
StatusParagraphs status_db(Util::fmap(
|
||||
*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
// Feature "openssl" is installed and should therefore be found
|
||||
auto it = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"});
|
||||
Assert::IsTrue(it != status_db.end());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#include <tests.utils.h>
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
using namespace vcpkg;
|
||||
using namespace vcpkg::Update;
|
||||
|
||||
namespace UnitTest1
|
||||
{
|
||||
using Pgh = std::vector<std::unordered_map<std::string, std::string>>;
|
||||
|
||||
class UpdateTests : public TestClass<UpdateTests>
|
||||
{
|
||||
TEST_METHOD(find_outdated_packages_basic)
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation { std::move(scf), "" });
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
Assert::AreEqual(size_t(1), pkgs.size());
|
||||
Assert::AreEqual("2", pkgs[0].version_diff.left.to_string().c_str());
|
||||
Assert::AreEqual("0", pkgs[0].version_diff.right.to_string().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_outdated_packages_features)
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation { std::move(scf), "" });
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
Assert::AreEqual(size_t(1), pkgs.size());
|
||||
Assert::AreEqual("2", pkgs[0].version_diff.left.to_string().c_str());
|
||||
Assert::AreEqual("0", pkgs[0].version_diff.right.to_string().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_outdated_packages_features_2)
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
|
||||
status_paragraphs.back()->package.version = "0";
|
||||
status_paragraphs.back()->state = InstallState::NOT_INSTALLED;
|
||||
status_paragraphs.back()->want = Want::PURGE;
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{ std::move(scf), "" });
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
Assert::AreEqual(size_t(1), pkgs.size());
|
||||
Assert::AreEqual("2", pkgs[0].version_diff.left.to_string().c_str());
|
||||
Assert::AreEqual("0", pkgs[0].version_diff.right.to_string().c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(find_outdated_packages_none)
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "2"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{ std::move(scf), "" });
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
Assert::AreEqual(size_t(0), pkgs.size());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
#include "tests.pch.h"
|
||||
|
||||
#include "tests.utils.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace vcpkg;
|
||||
|
||||
std::unique_ptr<StatusParagraph> make_status_pgh(const char* name,
|
||||
const char* depends,
|
||||
const char* default_features,
|
||||
const char* triplet)
|
||||
{
|
||||
using Pgh = std::unordered_map<std::string, std::string>;
|
||||
return std::make_unique<StatusParagraph>(Pgh{{"Package", name},
|
||||
{"Version", "1"},
|
||||
{"Architecture", triplet},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", depends},
|
||||
{"Default-Features", default_features},
|
||||
{"Status", "install ok installed"}});
|
||||
}
|
||||
std::unique_ptr<StatusParagraph> make_status_feature_pgh(const char* name,
|
||||
const char* feature,
|
||||
const char* depends,
|
||||
const char* triplet)
|
||||
{
|
||||
using Pgh = std::unordered_map<std::string, std::string>;
|
||||
return std::make_unique<StatusParagraph>(Pgh{{"Package", name},
|
||||
{"Version", "1"},
|
||||
{"Feature", feature},
|
||||
{"Architecture", triplet},
|
||||
{"Multi-Arch", "same"},
|
||||
{"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);
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/vcpkgcmdarguments.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
using vcpkg::CommandSetting;
|
||||
using vcpkg::CommandStructure;
|
||||
using vcpkg::CommandSwitch;
|
||||
using vcpkg::VcpkgCmdArguments;
|
||||
|
||||
TEST_CASE ("VcpkgCmdArguments from lowercase argument sequence", "[arguments]")
|
||||
{
|
||||
std::vector<std::string> t = {"--vcpkg-root",
|
||||
"C:\\vcpkg",
|
||||
"--scripts-root=C:\\scripts",
|
||||
"--debug",
|
||||
"--sendmetrics",
|
||||
"--printmetrics",
|
||||
"--overlay-ports=C:\\ports1",
|
||||
"--overlay-ports=C:\\ports2",
|
||||
"--overlay-triplets=C:\\tripletsA",
|
||||
"--overlay-triplets=C:\\tripletsB"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
|
||||
REQUIRE(*v.vcpkg_root_dir == "C:\\vcpkg");
|
||||
REQUIRE(*v.scripts_root_dir == "C:\\scripts");
|
||||
REQUIRE(v.debug);
|
||||
REQUIRE(*v.debug.get());
|
||||
REQUIRE(v.sendmetrics);
|
||||
REQUIRE(*v.sendmetrics.get());
|
||||
REQUIRE(v.printmetrics);
|
||||
REQUIRE(*v.printmetrics.get());
|
||||
|
||||
REQUIRE(v.overlay_ports->size() == 2);
|
||||
REQUIRE(v.overlay_ports->at(0) == "C:\\ports1");
|
||||
REQUIRE(v.overlay_ports->at(1) == "C:\\ports2");
|
||||
|
||||
REQUIRE(v.overlay_triplets->size() == 2);
|
||||
REQUIRE(v.overlay_triplets->at(0) == "C:\\tripletsA");
|
||||
REQUIRE(v.overlay_triplets->at(1) == "C:\\tripletsB");
|
||||
}
|
||||
|
||||
TEST_CASE ("VcpkgCmdArguments from uppercase argument sequence", "[arguments]")
|
||||
{
|
||||
std::vector<std::string> t = {"--VCPKG-ROOT",
|
||||
"C:\\vcpkg",
|
||||
"--SCRIPTS-ROOT=C:\\scripts",
|
||||
"--DEBUG",
|
||||
"--SENDMETRICS",
|
||||
"--PRINTMETRICS",
|
||||
"--OVERLAY-PORTS=C:\\ports1",
|
||||
"--OVERLAY-PORTS=C:\\ports2",
|
||||
"--OVERLAY-TRIPLETS=C:\\tripletsA",
|
||||
"--OVERLAY-TRIPLETS=C:\\tripletsB"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
|
||||
REQUIRE(*v.vcpkg_root_dir == "C:\\vcpkg");
|
||||
REQUIRE(*v.scripts_root_dir == "C:\\scripts");
|
||||
REQUIRE(v.debug);
|
||||
REQUIRE(*v.debug.get());
|
||||
REQUIRE(v.sendmetrics);
|
||||
REQUIRE(*v.sendmetrics.get());
|
||||
REQUIRE(v.printmetrics);
|
||||
REQUIRE(*v.printmetrics.get());
|
||||
|
||||
REQUIRE(v.overlay_ports->size() == 2);
|
||||
REQUIRE(v.overlay_ports->at(0) == "C:\\ports1");
|
||||
REQUIRE(v.overlay_ports->at(1) == "C:\\ports2");
|
||||
|
||||
REQUIRE(v.overlay_triplets->size() == 2);
|
||||
REQUIRE(v.overlay_triplets->at(0) == "C:\\tripletsA");
|
||||
REQUIRE(v.overlay_triplets->at(1) == "C:\\tripletsB");
|
||||
}
|
||||
|
||||
TEST_CASE ("VcpkgCmdArguments from argument sequence with valued options", "[arguments]")
|
||||
{
|
||||
SECTION ("case 1")
|
||||
{
|
||||
std::array<CommandSetting, 1> settings = {{{"--a", ""}}};
|
||||
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr};
|
||||
|
||||
std::vector<std::string> t = {"--a=b", "command", "argument"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
auto opts = v.parse_arguments(cmdstruct);
|
||||
|
||||
REQUIRE(opts.settings["--a"] == "b");
|
||||
REQUIRE(v.command_arguments.size() == 1);
|
||||
REQUIRE(v.command_arguments[0] == "argument");
|
||||
REQUIRE(v.command == "command");
|
||||
}
|
||||
|
||||
SECTION ("case 2")
|
||||
{
|
||||
std::array<CommandSwitch, 2> switches = {{{"--a", ""}, {"--c", ""}}};
|
||||
std::array<CommandSetting, 2> settings = {{{"--b", ""}, {"--d", ""}}};
|
||||
CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr};
|
||||
|
||||
std::vector<std::string> t = {"--a", "--b=c"};
|
||||
auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
|
||||
auto opts = v.parse_arguments(cmdstruct);
|
||||
|
||||
REQUIRE(opts.settings["--b"] == "c");
|
||||
REQUIRE(opts.settings.find("--d") == opts.settings.end());
|
||||
REQUIRE(opts.switches.find("--a") != opts.switches.end());
|
||||
REQUIRE(opts.settings.find("--c") == opts.settings.end());
|
||||
REQUIRE(v.command_arguments.size() == 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#define CATCH_CONFIG_RUNNER
|
||||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/base/system.debug.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
vcpkg::Debug::g_debugging = true;
|
||||
|
||||
return Catch::Session().run(argc, argv);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/base/chrono.h>
|
||||
|
||||
namespace Chrono = vcpkg::Chrono;
|
||||
|
||||
TEST_CASE ("parse time", "[chrono]")
|
||||
{
|
||||
auto timestring = "1990-02-03T04:05:06.0Z";
|
||||
auto maybe_time = Chrono::CTime::parse(timestring);
|
||||
|
||||
REQUIRE(maybe_time.has_value());
|
||||
REQUIRE(maybe_time.get()->to_string() == timestring);
|
||||
}
|
||||
|
||||
TEST_CASE ("parse blank time", "[chrono]")
|
||||
{
|
||||
auto maybe_time = Chrono::CTime::parse("");
|
||||
|
||||
REQUIRE_FALSE(maybe_time.has_value());
|
||||
}
|
||||
|
||||
TEST_CASE ("difference of times", "[chrono]")
|
||||
{
|
||||
auto maybe_time1 = Chrono::CTime::parse("1990-02-03T04:05:06.0Z");
|
||||
auto maybe_time2 = Chrono::CTime::parse("1990-02-10T04:05:06.0Z");
|
||||
|
||||
REQUIRE(maybe_time1.has_value());
|
||||
REQUIRE(maybe_time2.has_value());
|
||||
|
||||
auto delta = maybe_time2.get()->to_time_point() - maybe_time1.get()->to_time_point();
|
||||
|
||||
REQUIRE(std::chrono::duration_cast<std::chrono::hours>(delta).count() == 24 * 7);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/sourceparagraph.h>
|
||||
|
||||
using namespace vcpkg;
|
||||
using Parse::parse_comma_list;
|
||||
|
||||
TEST_CASE ("parse depends", "[dependencies]")
|
||||
{
|
||||
auto v = expand_qualified_dependencies(parse_comma_list("libA (windows)"));
|
||||
REQUIRE(v.size() == 1);
|
||||
REQUIRE(v.at(0).depend.name == "libA");
|
||||
REQUIRE(v.at(0).qualifier == "windows");
|
||||
}
|
||||
|
||||
TEST_CASE ("filter depends", "[dependencies]")
|
||||
{
|
||||
auto deps = expand_qualified_dependencies(parse_comma_list("libA (windows), libB, libC (uwp)"));
|
||||
auto v = filter_dependencies(deps, Triplet::X64_WINDOWS);
|
||||
REQUIRE(v.size() == 2);
|
||||
REQUIRE(v.at(0) == "libA");
|
||||
REQUIRE(v.at(1) == "libB");
|
||||
|
||||
auto v2 = filter_dependencies(deps, Triplet::ARM_UWP);
|
||||
REQUIRE(v.size() == 2);
|
||||
REQUIRE(v2.at(0) == "libB");
|
||||
REQUIRE(v2.at(1) == "libC");
|
||||
}
|
|
@ -0,0 +1,445 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
#include <vcpkg-tests/util.h>
|
||||
|
||||
#include <vcpkg/base/strings.h>
|
||||
|
||||
#include <vcpkg/paragraphs.h>
|
||||
|
||||
namespace Strings = vcpkg::Strings;
|
||||
|
||||
TEST_CASE ("SourceParagraph construct minimum", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
}});
|
||||
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version == "1.2.8");
|
||||
REQUIRE(pgh.core_paragraph->maintainer == "");
|
||||
REQUIRE(pgh.core_paragraph->description == "");
|
||||
REQUIRE(pgh.core_paragraph->depends.size() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph construct maximum", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "s"},
|
||||
{"Version", "v"},
|
||||
{"Maintainer", "m"},
|
||||
{"Description", "d"},
|
||||
{"Build-Depends", "bd"},
|
||||
{"Default-Features", "df"},
|
||||
{"Supports", "x64"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "s");
|
||||
REQUIRE(pgh.core_paragraph->version == "v");
|
||||
REQUIRE(pgh.core_paragraph->maintainer == "m");
|
||||
REQUIRE(pgh.core_paragraph->description == "d");
|
||||
REQUIRE(pgh.core_paragraph->depends.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->depends[0].name() == "bd");
|
||||
REQUIRE(pgh.core_paragraph->default_features.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->default_features[0] == "df");
|
||||
REQUIRE(pgh.core_paragraph->supports.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->supports[0] == "x64");
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph two depends", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "z, openssl"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->depends.size() == 2);
|
||||
REQUIRE(pgh.core_paragraph->depends[0].name() == "z");
|
||||
REQUIRE(pgh.core_paragraph->depends[1].name() == "openssl");
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph three depends", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "z, openssl, xyz"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->depends.size() == 3);
|
||||
REQUIRE(pgh.core_paragraph->depends[0].name() == "z");
|
||||
REQUIRE(pgh.core_paragraph->depends[1].name() == "openssl");
|
||||
REQUIRE(pgh.core_paragraph->depends[2].name() == "xyz");
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph three supports", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Supports", "x64, windows, uwp"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->supports.size() == 3);
|
||||
REQUIRE(pgh.core_paragraph->supports[0] == "x64");
|
||||
REQUIRE(pgh.core_paragraph->supports[1] == "windows");
|
||||
REQUIRE(pgh.core_paragraph->supports[2] == "uwp");
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph construct qualified depends", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Build-Depends", "libA (windows), libB (uwp)"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->name == "zlib");
|
||||
REQUIRE(pgh.core_paragraph->version == "1.2.8");
|
||||
REQUIRE(pgh.core_paragraph->maintainer == "");
|
||||
REQUIRE(pgh.core_paragraph->description == "");
|
||||
REQUIRE(pgh.core_paragraph->depends.size() == 2);
|
||||
REQUIRE(pgh.core_paragraph->depends[0].name() == "libA");
|
||||
REQUIRE(pgh.core_paragraph->depends[0].qualifier == "windows");
|
||||
REQUIRE(pgh.core_paragraph->depends[1].name() == "libB");
|
||||
REQUIRE(pgh.core_paragraph->depends[1].qualifier == "uwp");
|
||||
}
|
||||
|
||||
TEST_CASE ("SourceParagraph default features", "[paragraph]")
|
||||
{
|
||||
auto m_pgh =
|
||||
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
||||
{"Source", "a"},
|
||||
{"Version", "1.0"},
|
||||
{"Default-Features", "a1"},
|
||||
}});
|
||||
REQUIRE(m_pgh.has_value());
|
||||
auto& pgh = **m_pgh.get();
|
||||
|
||||
REQUIRE(pgh.core_paragraph->default_features.size() == 1);
|
||||
REQUIRE(pgh.core_paragraph->default_features[0] == "a1");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph construct minimum", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
|
||||
REQUIRE(pgh.spec.name() == "zlib");
|
||||
REQUIRE(pgh.version == "1.2.8");
|
||||
REQUIRE(pgh.maintainer == "");
|
||||
REQUIRE(pgh.description == "");
|
||||
REQUIRE(pgh.spec.triplet().canonical_name() == "x86-windows");
|
||||
REQUIRE(pgh.depends.size() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph construct maximum", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "s"},
|
||||
{"Version", "v"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Maintainer", "m"},
|
||||
{"Description", "d"},
|
||||
{"Depends", "bd"},
|
||||
});
|
||||
|
||||
REQUIRE(pgh.spec.name() == "s");
|
||||
REQUIRE(pgh.version == "v");
|
||||
REQUIRE(pgh.maintainer == "m");
|
||||
REQUIRE(pgh.description == "d");
|
||||
REQUIRE(pgh.depends.size() == 1);
|
||||
REQUIRE(pgh.depends[0] == "bd");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph three depends", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
});
|
||||
|
||||
REQUIRE(pgh.depends.size() == 3);
|
||||
REQUIRE(pgh.depends[0] == "a");
|
||||
REQUIRE(pgh.depends[1] == "b");
|
||||
REQUIRE(pgh.depends[2] == "c");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph abi", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Abi", "abcd123"},
|
||||
});
|
||||
|
||||
REQUIRE(pgh.depends.size() == 0);
|
||||
REQUIRE(pgh.abi == "abcd123");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph default features", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "a"},
|
||||
{"Version", "1.0"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Default-Features", "a1"},
|
||||
});
|
||||
|
||||
REQUIRE(pgh.depends.size() == 0);
|
||||
REQUIRE(pgh.default_features.size() == 1);
|
||||
REQUIRE(pgh.default_features[0] == "a1");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs empty", "[paragraph]")
|
||||
{
|
||||
const char* str = "";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
REQUIRE(pghs.empty());
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs one field", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 1);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs one pgh", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
REQUIRE(pghs[0]["f2"] == "v2");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs two pgh", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2\n"
|
||||
"\n"
|
||||
"f3: v3\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 2);
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
REQUIRE(pghs[0]["f2"] == "v2");
|
||||
REQUIRE(pghs[1].size() == 2);
|
||||
REQUIRE(pghs[1]["f3"] == "v3");
|
||||
REQUIRE(pghs[1]["f4"] == "v4");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs field names", "[paragraph]")
|
||||
{
|
||||
const char* str = "1:\n"
|
||||
"f:\n"
|
||||
"F:\n"
|
||||
"0:\n"
|
||||
"F-2:\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 5);
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs multiple blank lines", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\n"
|
||||
"f2: v2\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"f3: v3\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs empty fields", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1:\n"
|
||||
"f2: ";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
REQUIRE(pghs[0]["f1"] == "");
|
||||
REQUIRE(pghs[0]["f2"] == "");
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs multiline fields", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: simple\n"
|
||||
" f1\r\n"
|
||||
"f2:\r\n"
|
||||
" f2\r\n"
|
||||
" continue\r\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0]["f1"] == "simple\n f1");
|
||||
REQUIRE(pghs[0]["f2"] == "\n f2\n continue");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs crlfs", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"f2: v2\r\n"
|
||||
"\r\n"
|
||||
"f3: v3\r\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 2);
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
REQUIRE(pghs[0]["f2"] == "v2");
|
||||
REQUIRE(pghs[1].size() == 2);
|
||||
REQUIRE(pghs[1]["f3"] == "v3");
|
||||
REQUIRE(pghs[1]["f4"] == "v4");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse paragraphs comment", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"#comment\r\n"
|
||||
"f2: v2\r\n"
|
||||
"#comment\r\n"
|
||||
"\r\n"
|
||||
"#comment\r\n"
|
||||
"f3: v3\r\n"
|
||||
"#comment\r\n"
|
||||
"f4: v4";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 2);
|
||||
REQUIRE(pghs[0].size() == 2);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
REQUIRE(pghs[0]["f2"] == "v2");
|
||||
REQUIRE(pghs[1].size());
|
||||
REQUIRE(pghs[1]["f3"] == "v3");
|
||||
REQUIRE(pghs[1]["f4"] == "v4");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse comment before single line feed", "[paragraph]")
|
||||
{
|
||||
const char* str = "f1: v1\r\n"
|
||||
"#comment\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
REQUIRE(pghs[0].size() == 1);
|
||||
REQUIRE(pghs[0]["f1"] == "v1");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph serialize min", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 4);
|
||||
REQUIRE(pghs[0]["Package"] == "zlib");
|
||||
REQUIRE(pghs[0]["Version"] == "1.2.8");
|
||||
REQUIRE(pghs[0]["Architecture"] == "x86-windows");
|
||||
REQUIRE(pghs[0]["Multi-Arch"] == "same");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph serialize max", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Description", "first line\n second line"},
|
||||
{"Maintainer", "abc <abc@abc.abc>"},
|
||||
{"Depends", "dep"},
|
||||
{"Multi-Arch", "same"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0].size() == 7);
|
||||
REQUIRE(pghs[0]["Package"] == "zlib");
|
||||
REQUIRE(pghs[0]["Version"] == "1.2.8");
|
||||
REQUIRE(pghs[0]["Architecture"] == "x86-windows");
|
||||
REQUIRE(pghs[0]["Multi-Arch"] == "same");
|
||||
REQUIRE(pghs[0]["Description"] == "first line\n second line");
|
||||
REQUIRE(pghs[0]["Depends"] == "dep");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph serialize multiple deps", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0]["Depends"] == "a, b, c");
|
||||
}
|
||||
|
||||
TEST_CASE ("BinaryParagraph serialize abi", "[paragraph]")
|
||||
{
|
||||
vcpkg::BinaryParagraph pgh({
|
||||
{"Package", "zlib"},
|
||||
{"Version", "1.2.8"},
|
||||
{"Architecture", "x86-windows"},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", "a, b, c"},
|
||||
{"Abi", "123abc"},
|
||||
});
|
||||
std::string ss = Strings::serialize(pgh);
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
REQUIRE(pghs.size() == 1);
|
||||
REQUIRE(pghs[0]["Abi"] == "123abc");
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,134 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/base/util.h>
|
||||
#include <vcpkg/packagespec.h>
|
||||
|
||||
using namespace vcpkg;
|
||||
|
||||
TEST_CASE ("specifier conversion", "[specifier]")
|
||||
{
|
||||
SECTION ("full package spec to feature specs")
|
||||
{
|
||||
constexpr std::size_t SPEC_SIZE = 6;
|
||||
|
||||
auto a_spec = PackageSpec::from_name_and_triplet("a", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto b_spec = PackageSpec::from_name_and_triplet("b", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
auto fspecs = FullPackageSpec::to_feature_specs({{a_spec, {"0", "1"}}, {b_spec, {"2", "3"}}});
|
||||
|
||||
REQUIRE(fspecs.size() == SPEC_SIZE);
|
||||
|
||||
std::array<const char*, SPEC_SIZE> features = {"", "0", "1", "", "2", "3"};
|
||||
std::array<PackageSpec*, SPEC_SIZE> specs = {&a_spec, &a_spec, &a_spec, &b_spec, &b_spec, &b_spec};
|
||||
|
||||
for (std::size_t i = 0; i < SPEC_SIZE; ++i)
|
||||
{
|
||||
REQUIRE(features.at(i) == fspecs.at(i).feature());
|
||||
REQUIRE(*specs.at(i) == fspecs.at(i).spec());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE ("specifier parsing", "[specifier]")
|
||||
{
|
||||
SECTION ("parsed specifier from string")
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib");
|
||||
REQUIRE(maybe_spec.error() == vcpkg::PackageSpecParseResult::SUCCESS);
|
||||
|
||||
auto& spec = *maybe_spec.get();
|
||||
REQUIRE(spec.name == "zlib");
|
||||
REQUIRE(spec.features.size() == 0);
|
||||
REQUIRE(spec.triplet == "");
|
||||
}
|
||||
|
||||
SECTION ("parsed specifier from string with triplet")
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib:x64-uwp");
|
||||
REQUIRE(maybe_spec.error() == vcpkg::PackageSpecParseResult::SUCCESS);
|
||||
|
||||
auto& spec = *maybe_spec.get();
|
||||
REQUIRE(spec.name == "zlib");
|
||||
REQUIRE(spec.triplet == "x64-uwp");
|
||||
}
|
||||
|
||||
SECTION ("parsed specifier from string with colons")
|
||||
{
|
||||
auto ec = vcpkg::ParsedSpecifier::from_string("zlib:x86-uwp:").error();
|
||||
REQUIRE(ec == vcpkg::PackageSpecParseResult::TOO_MANY_COLONS);
|
||||
}
|
||||
|
||||
SECTION ("parsed specifier from string with feature")
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[feature]:x64-uwp");
|
||||
REQUIRE(maybe_spec.error() == vcpkg::PackageSpecParseResult::SUCCESS);
|
||||
|
||||
auto& spec = *maybe_spec.get();
|
||||
REQUIRE(spec.name == "zlib");
|
||||
REQUIRE(spec.features.size() == 1);
|
||||
REQUIRE(spec.features.at(0) == "feature");
|
||||
REQUIRE(spec.triplet == "x64-uwp");
|
||||
}
|
||||
|
||||
SECTION ("parsed specifier from string with many features")
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[0, 1,2]");
|
||||
REQUIRE(maybe_spec.error() == vcpkg::PackageSpecParseResult::SUCCESS);
|
||||
|
||||
auto& spec = *maybe_spec.get();
|
||||
REQUIRE(spec.name == "zlib");
|
||||
REQUIRE(spec.features.size() == 3);
|
||||
REQUIRE(spec.features.at(0) == "0");
|
||||
REQUIRE(spec.features.at(1) == "1");
|
||||
REQUIRE(spec.features.at(2) == "2");
|
||||
REQUIRE(spec.triplet == "");
|
||||
}
|
||||
|
||||
SECTION ("parsed specifier wildcard feature")
|
||||
{
|
||||
auto maybe_spec = vcpkg::ParsedSpecifier::from_string("zlib[*]");
|
||||
REQUIRE(maybe_spec.error() == vcpkg::PackageSpecParseResult::SUCCESS);
|
||||
|
||||
auto& spec = *maybe_spec.get();
|
||||
REQUIRE(spec.name == "zlib");
|
||||
REQUIRE(spec.features.size() == 1);
|
||||
REQUIRE(spec.features.at(0) == "*");
|
||||
REQUIRE(spec.triplet == "");
|
||||
}
|
||||
|
||||
SECTION ("expand wildcards")
|
||||
{
|
||||
auto zlib = vcpkg::FullPackageSpec::from_string("zlib[0,1]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto openssl =
|
||||
vcpkg::FullPackageSpec::from_string("openssl[*]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
|
||||
auto specs = FullPackageSpec::to_feature_specs({zlib, openssl});
|
||||
Util::sort(specs);
|
||||
auto spectargets = FeatureSpec::from_strings_and_triplet(
|
||||
{
|
||||
"openssl",
|
||||
"zlib",
|
||||
"openssl[*]",
|
||||
"zlib[0]",
|
||||
"zlib[1]",
|
||||
},
|
||||
Triplet::X86_UWP);
|
||||
Util::sort(spectargets);
|
||||
|
||||
REQUIRE(specs.size() == spectargets.size());
|
||||
REQUIRE(Util::all_equal(specs, spectargets));
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
SECTION ("ASCII to utf16")
|
||||
{
|
||||
auto str = vcpkg::Strings::to_utf16("abc");
|
||||
REQUIRE(str == L"abc");
|
||||
}
|
||||
|
||||
SECTION ("ASCII to utf16 with whitespace")
|
||||
{
|
||||
auto str = vcpkg::Strings::to_utf16("abc -x86-windows");
|
||||
REQUIRE(str == L"abc -x86-windows");
|
||||
}
|
||||
#endif
|
||||
};
|
|
@ -0,0 +1,110 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
#include <vcpkg-tests/util.h>
|
||||
|
||||
#include <vcpkg/base/util.h>
|
||||
#include <vcpkg/paragraphs.h>
|
||||
#include <vcpkg/statusparagraphs.h>
|
||||
|
||||
using namespace vcpkg;
|
||||
using namespace vcpkg::Paragraphs;
|
||||
using namespace vcpkg::Test;
|
||||
|
||||
TEST_CASE ("find installed", "[statusparagraphs]")
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
)");
|
||||
|
||||
REQUIRE(pghs);
|
||||
|
||||
StatusParagraphs status_db(
|
||||
Util::fmap(*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
REQUIRE(it != status_db.end());
|
||||
}
|
||||
|
||||
TEST_CASE ("find not installed", "[statusparagraphs]")
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: purge ok not-installed
|
||||
)");
|
||||
|
||||
REQUIRE(pghs);
|
||||
|
||||
StatusParagraphs status_db(
|
||||
Util::fmap(*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
REQUIRE(it == status_db.end());
|
||||
}
|
||||
|
||||
TEST_CASE ("find with feature packages", "[statusparagraphs]")
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
|
||||
Package: ffmpeg
|
||||
Feature: openssl
|
||||
Depends: openssl
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: purge ok not-installed
|
||||
)");
|
||||
|
||||
REQUIRE(pghs);
|
||||
|
||||
StatusParagraphs status_db(
|
||||
Util::fmap(*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
||||
REQUIRE(it != status_db.end());
|
||||
|
||||
// Feature "openssl" is not installed and should not be found
|
||||
auto it1 = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"});
|
||||
REQUIRE(it1 == status_db.end());
|
||||
}
|
||||
|
||||
TEST_CASE ("find for feature packages", "[statusparagraphs]")
|
||||
{
|
||||
auto pghs = parse_paragraphs(R"(
|
||||
Package: ffmpeg
|
||||
Version: 3.3.3
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
|
||||
Package: ffmpeg
|
||||
Feature: openssl
|
||||
Depends: openssl
|
||||
Architecture: x64-windows
|
||||
Multi-Arch: same
|
||||
Description:
|
||||
Status: install ok installed
|
||||
)");
|
||||
REQUIRE(pghs);
|
||||
|
||||
StatusParagraphs status_db(
|
||||
Util::fmap(*pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
|
||||
|
||||
// Feature "openssl" is installed and should therefore be found
|
||||
auto it = status_db.find_installed({unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS), "openssl"});
|
||||
REQUIRE(it != status_db.end());
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
|
||||
#include <vcpkg/sourceparagraph.h>
|
||||
|
||||
using namespace vcpkg;
|
||||
using Parse::parse_comma_list;
|
||||
|
||||
TEST_CASE ("parse supports all", "[supports]")
|
||||
{
|
||||
auto v = Supports::parse({
|
||||
"x64",
|
||||
"x86",
|
||||
"arm",
|
||||
"windows",
|
||||
"uwp",
|
||||
"v140",
|
||||
"v141",
|
||||
"crt-static",
|
||||
"crt-dynamic",
|
||||
});
|
||||
|
||||
REQUIRE(v.has_value());
|
||||
|
||||
REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::UWP,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
REQUIRE(v.get()->is_supported(System::CPUArchitecture::ARM,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::STATIC,
|
||||
Supports::ToolsetVersion::V141));
|
||||
}
|
||||
|
||||
TEST_CASE ("parse supports invalid", "[supports]")
|
||||
{
|
||||
auto v = Supports::parse({"arm64"});
|
||||
|
||||
REQUIRE_FALSE(v.has_value());
|
||||
|
||||
REQUIRE(v.error().size() == 1);
|
||||
REQUIRE(v.error().at(0) == "arm64");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse supports case sensitive", "[supports]")
|
||||
{
|
||||
auto v = Supports::parse({"Windows"});
|
||||
|
||||
REQUIRE_FALSE(v.has_value());
|
||||
REQUIRE(v.error().size() == 1);
|
||||
REQUIRE(v.error().at(0) == "Windows");
|
||||
}
|
||||
|
||||
TEST_CASE ("parse supports some", "[supports]")
|
||||
{
|
||||
auto v = Supports::parse({
|
||||
"x64",
|
||||
"x86",
|
||||
"windows",
|
||||
});
|
||||
|
||||
REQUIRE(v.has_value());
|
||||
|
||||
REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
REQUIRE_FALSE(v.get()->is_supported(System::CPUArchitecture::ARM,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
REQUIRE_FALSE(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::UWP,
|
||||
Supports::Linkage::DYNAMIC,
|
||||
Supports::ToolsetVersion::V140));
|
||||
REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
|
||||
Supports::Platform::WINDOWS,
|
||||
Supports::Linkage::STATIC,
|
||||
Supports::ToolsetVersion::V141));
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
#include <vcpkg-tests/util.h>
|
||||
|
||||
#include <vcpkg/base/sortedvector.h>
|
||||
|
||||
#include <vcpkg/update.h>
|
||||
|
||||
using namespace vcpkg;
|
||||
using namespace vcpkg::Update;
|
||||
using namespace vcpkg::Test;
|
||||
|
||||
using Pgh = std::vector<std::unordered_map<std::string, std::string>>;
|
||||
|
||||
TEST_CASE ("find outdated packages basic", "[update]")
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
REQUIRE(pkgs.size() == 1);
|
||||
REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
|
||||
REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
|
||||
}
|
||||
|
||||
TEST_CASE ("find outdated packages features", "[update]")
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
REQUIRE(pkgs.size() == 1);
|
||||
REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
|
||||
REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
|
||||
}
|
||||
|
||||
TEST_CASE ("find outdated packages features 2", "[update]")
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
|
||||
status_paragraphs.back()->package.version = "0";
|
||||
status_paragraphs.back()->state = InstallState::NOT_INSTALLED;
|
||||
status_paragraphs.back()->want = Want::PURGE;
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
REQUIRE(pkgs.size() == 1);
|
||||
REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
|
||||
REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
|
||||
}
|
||||
|
||||
TEST_CASE ("find outdated packages none", "[update]")
|
||||
{
|
||||
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
|
||||
status_paragraphs.push_back(make_status_pgh("a"));
|
||||
status_paragraphs.back()->package.version = "2";
|
||||
|
||||
StatusParagraphs status_db(std::move(status_paragraphs));
|
||||
|
||||
std::unordered_map<std::string, SourceControlFileLocation> map;
|
||||
auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "2"}}}));
|
||||
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
|
||||
Dependencies::MapPortFileProvider provider(map);
|
||||
|
||||
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
|
||||
&OutdatedPackage::compare_by_name);
|
||||
|
||||
REQUIRE(pkgs.size() == 0);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#include <vcpkg-tests/catch.h>
|
||||
#include <vcpkg-tests/util.h>
|
||||
|
||||
#include <vcpkg/statusparagraph.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace vcpkg::Test
|
||||
{
|
||||
std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
|
||||
const char* depends,
|
||||
const char* default_features,
|
||||
const char* triplet)
|
||||
{
|
||||
using Pgh = std::unordered_map<std::string, std::string>;
|
||||
return std::make_unique<StatusParagraph>(Pgh{{"Package", name},
|
||||
{"Version", "1"},
|
||||
{"Architecture", triplet},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", depends},
|
||||
{"Default-Features", default_features},
|
||||
{"Status", "install ok installed"}});
|
||||
}
|
||||
|
||||
std::unique_ptr<StatusParagraph> make_status_feature_pgh(const char* name,
|
||||
const char* feature,
|
||||
const char* depends,
|
||||
const char* triplet)
|
||||
{
|
||||
using Pgh = std::unordered_map<std::string, std::string>;
|
||||
return std::make_unique<StatusParagraph>(Pgh{{"Package", name},
|
||||
{"Version", "1"},
|
||||
{"Feature", feature},
|
||||
{"Architecture", triplet},
|
||||
{"Multi-Arch", "same"},
|
||||
{"Depends", depends},
|
||||
{"Status", "install ok installed"}});
|
||||
}
|
||||
|
||||
PackageSpec unsafe_pspec(std::string name, Triplet t)
|
||||
{
|
||||
auto m_ret = PackageSpec::from_name_and_triplet(name, t);
|
||||
REQUIRE(m_ret.has_value());
|
||||
return m_ret.value_or_exit(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,21 +19,17 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\tests.arguments.cpp" />
|
||||
<ClCompile Include="..\src\tests.chrono.cpp" />
|
||||
<ClCompile Include="..\src\tests.dependencies.cpp" />
|
||||
<ClCompile Include="..\src\tests.packagespec.cpp" />
|
||||
<ClCompile Include="..\src\tests.paragraph.cpp" />
|
||||
<ClCompile Include="..\src\tests.pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.plan.cpp" />
|
||||
<ClCompile Include="..\src\tests.statusparagraphs.cpp" />
|
||||
<ClCompile Include="..\src\tests.update.cpp" />
|
||||
<ClCompile Include="..\src\tests.utils.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\arguments.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\catch.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\chrono.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\dependencies.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\paragraph.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\plan.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\specifier.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\statusparagraphs.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\supports.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\update.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg-tests\util.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\vcpkglib\vcpkglib.vcxproj">
|
||||
|
@ -41,8 +37,8 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\tests.pch.h" />
|
||||
<ClInclude Include="..\include\tests.utils.h" />
|
||||
<ClInclude Include="..\include\vcpkg-tests\catch.h" />
|
||||
<ClInclude Include="..\include\vcpkg-tests\util.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}</ProjectGuid>
|
||||
|
@ -66,7 +62,7 @@
|
|||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
|
@ -110,38 +106,34 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;$(VCInstallDir)UnitTest\include;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>tests.pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;$(VCInstallDir)UnitTest\include;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>tests.pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
|
@ -149,19 +141,17 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>..\include;$(VCInstallDir)UnitTest\include;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>tests.pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
|
@ -171,19 +161,17 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>..\include;$(VCInstallDir)UnitTest\include;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<PrecompiledHeaderFile>tests.pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;$(VsInstallRoot)\VC\Auxiliary\VS\UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
|
|
|
@ -15,42 +15,45 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\tests.arguments.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\arguments.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.dependencies.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\catch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.packagespec.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\chrono.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.paragraph.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\dependencies.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.statusparagraphs.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\paragraph.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.plan.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\plan.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.update.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\specifier.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.pch.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\statusparagraphs.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.utils.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\supports.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tests.chrono.cpp">
|
||||
<ClCompile Include="..\src\vcpkg-tests\update.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\vcpkg-tests\util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\tests.pch.h">
|
||||
<ClInclude Include="..\include\vcpkg-tests\catch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\tests.utils.h">
|
||||
<ClInclude Include="..\include\vcpkg-tests\util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче