Run clang-foramt over tests and remaining cpp files
MODIFY
src/tests_arguments.cpp
src/tests_arguments.cpp
@@ -10,19 +10,13 @@ using namespace vcpkg;
namespace UnitTest1
{
- TEST_CLASS(ArgumentTests)
+ struct ArgumentTests : TestClass<ArgumentTests>
{
- public:
TEST_METHOD(create_from_arg_sequence_options_lower)
{
- std::vector<std::string> t = {
- "--vcpkg-root", "C:\vcpkg",
- "--debug",
- "--sendmetrics",
- "--printmetrics"
- };
+ std::vector<std::string> t = { "--vcpkg-root", "C:\\vcpkg", "--debug", "--sendmetrics", "--printmetrics" };
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:\\vcpkg", v.vcpkg_root_dir.get()->c_str());
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.debug);
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.sendmetrics);
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.printmetrics);
@@ -30,14 +24,9 @@ namespace UnitTest1
TEST_METHOD(create_from_arg_sequence_options_upper)
{
- std::vector<std::string> t = {
- "--VCPKG-ROOT", "C:\vcpkg",
- "--DEBUG",
- "--SENDMETRICS",
- "--PRINTMETRICS"
- };
+ std::vector<std::string> t = { "--VCPKG-ROOT", "C:\\vcpkg", "--DEBUG", "--SENDMETRICS", "--PRINTMETRICS" };
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:\\vcpkg", v.vcpkg_root_dir.get()->c_str());
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.debug);
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.sendmetrics);
Assert::IsTrue(vcpkg::OptBoolC::ENABLED == v.printmetrics);

MODIFY
src/tests_dependencies.cpp
src/tests_dependencies.cpp
@@ -11,9 +11,8 @@ using namespace vcpkg;
namespace UnitTest1
{
- TEST_CLASS(DependencyTests)
+ struct ArgumentTests : TestClass<ArgumentTests>
{
- public:
TEST_METHOD(parse_depends_one)
{
auto v = expand_qualified_dependencies(parse_depends("libA [windows]"));

MODIFY
src/tests_paragraph.cpp
src/tests_paragraph.cpp
+#include "BinaryParagraph.h"
#include "CppUnitTest.h"
#include "Paragraphs.h"
-#include "BinaryParagraph.h"
#include "vcpkg_Strings.h"
#pragma comment(lib, "version")
@@ -21,15 +21,11 @@ namespace Strings = vcpkg::Strings;
namespace UnitTest1
{
- TEST_CLASS(ControlParsing)
+ struct ArgumentTests : TestClass<ArgumentTests>
{
- public:
TEST_METHOD(SourceParagraph_Construct_Minimum)
{
- vcpkg::SourceParagraph pgh({
- { "Source", "zlib" },
- { "Version", "1.2.8" }
- });
+ vcpkg::SourceParagraph pgh({ { "Source", "zlib" }, { "Version", "1.2.8" } });
Assert::AreEqual("zlib", pgh.name.c_str());
Assert::AreEqual("1.2.8", pgh.version.c_str());
@@ -40,13 +36,11 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Construct_Maximum)
{
- vcpkg::SourceParagraph pgh({
- { "Source", "s" },
+ vcpkg::SourceParagraph pgh({ { "Source", "s" },
{ "Version", "v" },
{ "Maintainer", "m" },
{ "Description", "d" },
- { "Build-Depends", "bd" }
- });
+ { "Build-Depends", "bd" } });
Assert::AreEqual("s", pgh.name.c_str());
Assert::AreEqual("v", pgh.version.c_str());
Assert::AreEqual("m", pgh.maintainer.c_str());
@@ -57,11 +51,8 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Two_Depends)
{
- vcpkg::SourceParagraph pgh({
- { "Source", "zlib" },
- { "Version", "1.2.8" },
- { "Build-Depends", "z, openssl" }
- });
+ vcpkg::SourceParagraph pgh(
+ { { "Source", "zlib" }, { "Version", "1.2.8" }, { "Build-Depends", "z, openssl" } });
Assert::AreEqual(size_t(2), pgh.depends.size());
Assert::AreEqual("z", pgh.depends[0].name.c_str());
@@ -70,11 +61,8 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Three_Depends)
{
- vcpkg::SourceParagraph pgh({
- { "Source", "zlib" },
- { "Version", "1.2.8" },
- { "Build-Depends", "z, openssl, xyz" }
- });
+ vcpkg::SourceParagraph pgh(
+ { { "Source", "zlib" }, { "Version", "1.2.8" }, { "Build-Depends", "z, openssl, xyz" } });
Assert::AreEqual(size_t(3), pgh.depends.size());
Assert::AreEqual("z", pgh.depends[0].name.c_str());
@@ -84,11 +72,8 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Construct_Qualified_Depends)
{
- vcpkg::SourceParagraph pgh({
- { "Source", "zlib" },
- { "Version", "1.2.8" },
- { "Build-Depends", "libA [windows], libB [uwp]" }
- });
+ vcpkg::SourceParagraph pgh(
+ { { "Source", "zlib" }, { "Version", "1.2.8" }, { "Build-Depends", "libA [windows], libB [uwp]" } });
Assert::AreEqual("zlib", pgh.name.c_str());
Assert::AreEqual("1.2.8", pgh.version.c_str());
@@ -120,15 +105,13 @@ namespace UnitTest1
TEST_METHOD(BinaryParagraph_Construct_Maximum)
{
- vcpkg::BinaryParagraph pgh({
- { "Package", "s" },
+ vcpkg::BinaryParagraph pgh({ { "Package", "s" },
{ "Version", "v" },
{ "Architecture", "x86-windows" },
{ "Multi-Arch", "same" },
{ "Maintainer", "m" },
{ "Description", "d" },
- { "Depends", "bd" }
- });
+ { "Depends", "bd" } });
Assert::AreEqual("s", pgh.spec.name().c_str());
Assert::AreEqual("v", pgh.version.c_str());
Assert::AreEqual("m", pgh.maintainer.c_str());
@@ -171,8 +154,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_one_pgh)
{
- const char* str =
- "f1: v1\n"
+ 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());
@@ -183,8 +165,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_two_pgh)
{
- const char* str =
- "f1: v1\n"
+ const char* str = "f1: v1\n"
"f2: v2\n"
"\n"
"f3: v3\n"
@@ -201,8 +182,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_field_names)
{
- const char* str =
- "1:\n"
+ const char* str = "1:\n"
"f:\n"
"F:\n"
"0:\n"
@@ -214,8 +194,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_multiple_blank_lines)
{
- const char* str =
- "f1: v1\n"
+ const char* str = "f1: v1\n"
"f2: v2\n"
"\n"
"\n"
@@ -227,8 +206,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_empty_fields)
{
- const char* str =
- "f1:\n"
+ 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());
@@ -240,8 +218,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_multiline_fields)
{
- const char* str =
- "f1: simple\n"
+ const char* str = "f1: simple\n"
" f1\r\n"
"f2:\r\n"
" f2\r\n"
@@ -254,8 +231,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_crlfs)
{
- const char* str =
- "f1: v1\r\n"
+ const char* str = "f1: v1\r\n"
"f2: v2\r\n"
"\r\n"
"f3: v3\r\n"
@@ -272,8 +248,7 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_comment)
{
- const char* str =
- "f1: v1\r\n"
+ const char* str = "f1: v1\r\n"
"#comment\r\n"
"f2: v2\r\n"
"#comment\r\n"
@@ -294,8 +269,7 @@ namespace UnitTest1
TEST_METHOD(parse_comment_before_single_slashN)
{
- const char* str =
- "f1: v1\r\n"
+ 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());
@@ -360,16 +334,20 @@ namespace UnitTest1
TEST_METHOD(package_spec_parse)
{
- vcpkg::Expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib", vcpkg::Triplet::X86_WINDOWS);
- Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, vcpkg::to_package_spec_parse_result(spec.error_code()));
+ vcpkg::Expected<vcpkg::PackageSpec> spec =
+ vcpkg::PackageSpec::from_string("zlib", vcpkg::Triplet::X86_WINDOWS);
+ Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS,
+ vcpkg::to_package_spec_parse_result(spec.error_code()));
Assert::AreEqual("zlib", spec.get()->name().c_str());
Assert::AreEqual(vcpkg::Triplet::X86_WINDOWS.canonical_name(), spec.get()->triplet().canonical_name());
}
TEST_METHOD(package_spec_parse_with_arch)
{
- vcpkg::Expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib:x64-uwp", vcpkg::Triplet::X86_WINDOWS);
- Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, vcpkg::to_package_spec_parse_result(spec.error_code()));
+ vcpkg::Expected<vcpkg::PackageSpec> spec =
+ vcpkg::PackageSpec::from_string("zlib:x64-uwp", vcpkg::Triplet::X86_WINDOWS);
+ Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS,
+ vcpkg::to_package_spec_parse_result(spec.error_code()));
Assert::AreEqual("zlib", spec.get()->name().c_str());
Assert::AreEqual(vcpkg::Triplet::X64_UWP.canonical_name(), spec.get()->triplet().canonical_name());
}

MODIFY
src/vcpkg.cpp
src/vcpkg.cpp
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
-#include <fstream>
-#include <memory>
-#include <cassert>
-#include "vcpkg_Commands.h"
+#include "Paragraphs.h"
#include "metrics.h"
-#include <Shlobj.h>
+#include "vcpkg_Chrono.h"
+#include "vcpkg_Commands.h"
#include "vcpkg_Files.h"
-#include "vcpkg_System.h"
#include "vcpkg_Input.h"
-#include "Paragraphs.h"
#include "vcpkg_Strings.h"
-#include "vcpkg_Chrono.h"
+#include "vcpkg_System.h"
#include "vcpkglib.h"
+#include <Shlobj.h>
+#include <cassert>
+#include <fstream>
+#include <memory>
using namespace vcpkg;
@@ -52,14 +52,19 @@ static void inner(const VcpkgCmdArguments& args)
}
else
{
- vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up(fs::stdfs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root");
+ vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up(
+ fs::stdfs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root");
}
}
Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root.");
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir);
- Checks::check_exit(VCPKG_LINE_INFO, !expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message());
+ Checks::check_exit(VCPKG_LINE_INFO,
+ !expected_paths.error_code(),
+ "Error: Invalid vcpkg root directory %s: %s",
+ vcpkg_root_dir.string(),
+ expected_paths.error_code().message());
const VcpkgPaths paths = expected_paths.value_or_exit(VCPKG_LINE_INFO);
int exit_code = _wchdir(paths.root.c_str());
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed");
@@ -76,7 +81,8 @@ static void inner(const VcpkgCmdArguments& args)
}
else
{
- const Optional<std::wstring> vcpkg_default_triplet_env = System::get_environmental_variable(L"VCPKG_DEFAULT_TRIPLET");
+ const Optional<std::wstring> vcpkg_default_triplet_env =
+ System::get_environmental_variable(L"VCPKG_DEFAULT_TRIPLET");
if (auto v = vcpkg_default_triplet_env.get())
{
default_triplet = Triplet::from_canonical_name(Strings::utf16_to_utf8(*v));
@@ -103,8 +109,7 @@ static void loadConfig()
{
// Config path in AppDataLocal
wchar_t* localappdatapath = nullptr;
- if (S_OK != SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &localappdatapath))
- __fastfail(1);
+ if (S_OK != SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &localappdatapath)) __fastfail(1);
localappdata = localappdatapath;
CoTaskMemFree(localappdatapath);
}
@@ -117,8 +122,7 @@ static void loadConfig()
const auto& pghs = *p_pghs;
std::unordered_map<std::string, std::string> keys;
- if (pghs.size() > 0)
- keys = pghs[0];
+ if (pghs.size() > 0) keys = pghs[0];
for (size_t x = 1; x < pghs.size(); ++x)
{
@@ -135,7 +139,9 @@ static void loadConfig()
}
}
}
- catch (...) { }
+ catch (...)
+ {
+ }
// config file not found, could not be read, or invalid
std::string user_id, user_time;
@@ -147,16 +153,20 @@ static void loadConfig()
auto& fs = Files::get_real_filesystem();
fs.create_directory(localappdata / "vcpkg", ec);
fs.write_contents(localappdata / "vcpkg" / "config",
- Strings::format(
- "User-Id: %s\n"
- "User-Since: %s\n", user_id, user_time));
+ Strings::format("User-Id: %s\n"
+ "User-Since: %s\n",
+ user_id,
+ user_time));
+ }
+ catch (...)
+ {
}
- catch (...) { }
}
static std::string trim_path_from_command_line(const std::string& full_command_line)
{
- Checks::check_exit(VCPKG_LINE_INFO, full_command_line.size() > 0, "Internal failure - cannot have empty command line");
+ Checks::check_exit(
+ VCPKG_LINE_INFO, full_command_line.size() > 0, "Internal failure - cannot have empty command line");
if (full_command_line[0] == '"')
{
@@ -178,12 +188,10 @@ static ElapsedTime g_timer;
int wmain(const int argc, const wchar_t* const* const argv)
{
- if (argc == 0)
- std::abort();
+ if (argc == 0) std::abort();
g_timer = ElapsedTime::create_started();
- atexit([]()
- {
+ atexit([]() {
auto elapsed_us = g_timer.microseconds();
Metrics::track_metric("elapsed_us", elapsed_us);
g_debugging = false;
@@ -199,10 +207,8 @@ int wmain(const int argc, const wchar_t* const* const argv)
const VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(argc, argv);
- if (args.printmetrics != OptBoolC::UNSPECIFIED)
- Metrics::set_print_metrics(args.printmetrics == OptBoolC::ENABLED);
- if (args.sendmetrics != OptBoolC::UNSPECIFIED)
- Metrics::set_send_metrics(args.sendmetrics == OptBoolC::ENABLED);
+ if (args.printmetrics != OptBoolC::UNSPECIFIED) Metrics::set_print_metrics(args.printmetrics == OptBoolC::ENABLED);
+ if (args.sendmetrics != OptBoolC::UNSPECIFIED) Metrics::set_send_metrics(args.sendmetrics == OptBoolC::ENABLED);
if (args.debug != OptBoolC::UNSPECIFIED)
{
@@ -232,8 +238,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
Metrics::track_property("error", exc_msg);
fflush(stdout);
- System::print(
- "vcpkg.exe has crashed.\n"
+ System::print("vcpkg.exe has crashed.\n"
"Please send an email to:\n"
" %s\n"
"containing a brief summary of what you were trying to do and the following data blob:\n"

Run clang-foramt over tests and remaining cpp files