From d373bc6ed0c3b97526fc350b01d2d407409d0fce Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 14 Sep 2020 02:17:43 +0300 Subject: clang-format: regroup #includes --- .clang-format | 14 +++------ src/call_stack.cpp | 2 +- src/dbghelp.cpp | 5 ++- src/error.cpp | 2 +- src/module.cpp | 5 ++- src/process.cpp | 5 ++- src/repo.cpp | 2 +- src/symbol.cpp | 5 ++- src/utils/file.cpp | 2 +- test/unit_tests/dbghelp.cpp | 7 ++--- test/unit_tests/dbghelp.hpp | 74 -------------------------------------------- test/unit_tests/fixtures.hpp | 74 ++++++++++++++++++++++++++++++++++++++++++++ test/unit_tests/paths.hpp | 37 ++++++++++++++++++++++ test/unit_tests/utils.hpp | 37 ---------------------- 14 files changed, 131 insertions(+), 140 deletions(-) delete mode 100644 test/unit_tests/dbghelp.hpp create mode 100644 test/unit_tests/fixtures.hpp create mode 100644 test/unit_tests/paths.hpp delete mode 100644 test/unit_tests/utils.hpp diff --git a/.clang-format b/.clang-format index fb0d2f6..08d4d1d 100644 --- a/.clang-format +++ b/.clang-format @@ -10,18 +10,14 @@ IndentWidth: 4 SpacesBeforeTrailingComments: 1 IncludeCategories: - - Regex: '^".*' + - Regex: '^".+' Priority: 1 - - Regex: '^$' - Priority: 5 - Regex: '^<.*\.h>$' - Priority: 6 + Priority: 4 - Regex: '.*' - Priority: 7 + Priority: 5 ... diff --git a/src/call_stack.cpp b/src/call_stack.cpp index d9e0637..aec50de 100644 --- a/src/call_stack.cpp +++ b/src/call_stack.cpp @@ -3,7 +3,7 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" +#include #include diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp index 5b66914..8f0f7d6 100644 --- a/src/dbghelp.cpp +++ b/src/dbghelp.cpp @@ -3,11 +3,10 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" - -#include +#include #include +#include #include #include diff --git a/src/error.cpp b/src/error.cpp index d305e88..74cf395 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -3,7 +3,7 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" +#include #include diff --git a/src/module.cpp b/src/module.cpp index f4f3eb9..3f4764c 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -3,11 +3,10 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" - -#include +#include #include +#include #include #include diff --git a/src/process.cpp b/src/process.cpp index c2a32f4..5ba3734 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1,8 +1,7 @@ -#include "pdb/all.hpp" - -#include +#include #include +#include #include diff --git a/src/repo.cpp b/src/repo.cpp index 6ef5252..fbdf1ae 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -3,7 +3,7 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" +#include #include #include diff --git a/src/symbol.cpp b/src/symbol.cpp index d51cc83..ad7bd3f 100644 --- a/src/symbol.cpp +++ b/src/symbol.cpp @@ -3,11 +3,10 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" - -#include +#include #include +#include #include #include diff --git a/src/utils/file.cpp b/src/utils/file.cpp index 826f470..4d7dd53 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -3,7 +3,7 @@ // For details, see https://github.com/egor-tensin/pdb-repo. // Distributed under the MIT License. -#include "pdb/all.hpp" +#include #include diff --git a/test/unit_tests/dbghelp.cpp b/test/unit_tests/dbghelp.cpp index ddf5a71..aab292f 100644 --- a/test/unit_tests/dbghelp.cpp +++ b/test/unit_tests/dbghelp.cpp @@ -1,9 +1,8 @@ -#include "dbghelp.hpp" -#include "utils.hpp" - -#include +#include "fixtures.hpp" +#include "paths.hpp" #include +#include #include diff --git a/test/unit_tests/dbghelp.hpp b/test/unit_tests/dbghelp.hpp deleted file mode 100644 index daede68..0000000 --- a/test/unit_tests/dbghelp.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include "utils.hpp" - -#include - -#include -#include - -#include -#include -#include -#include - -class DbgHelp { -public: - DbgHelp() : dbghelp{pdb::DbgHelp::post_mortem()} { BOOST_TEST_MESSAGE("Initializing DbgHelp"); } - - ~DbgHelp() { BOOST_TEST_MESSAGE("Cleaning up DbgHelp"); } - - const pdb::DbgHelp dbghelp; - -private: - DbgHelp(const DbgHelp&) = delete; - DbgHelp& operator=(const DbgHelp&) = delete; -}; - -template -using Set = std::unordered_set; - -template -Set join(Set&& xs, Set&& ys) { - xs.insert(std::make_move_iterator(ys.begin()), std::make_move_iterator(ys.end())); - return std::move(xs); -} - -class DbgHelpWithSymbols : public DbgHelp { -public: - DbgHelpWithSymbols() { load_test_lib_pdb(); } - - static const std::string& get_namespace() { - static const std::string name{"test"}; - return name; - } - - typedef Set SymbolList; - - static SymbolList expected_functions() { return make_qualified({"foo", "bar", "baz"}); } - - static SymbolList expected_variables() { return make_qualified({"var"}); } - - static SymbolList expected_symbols() { - return join(expected_functions(), expected_variables()); - } - -private: - static SymbolList make_qualified(SymbolList&& plain) { - SymbolList qualified; - for (auto&& name : plain) { - qualified.emplace(get_namespace() + "::" + std::move(name)); - } - return qualified; - } - - void load_test_lib_pdb() { - const auto pdb_path = get_test_lib_pdb_path().string(); - BOOST_TEST_MESSAGE("Loading PDB: " << pdb_path); - dbghelp.load_pdb(pdb_path); - } - - static boost::filesystem::path get_test_lib_pdb_path() { - return Paths::get().exe_dir / "test_lib.pdb"; - } -}; diff --git a/test/unit_tests/fixtures.hpp b/test/unit_tests/fixtures.hpp new file mode 100644 index 0000000..f6571d1 --- /dev/null +++ b/test/unit_tests/fixtures.hpp @@ -0,0 +1,74 @@ +#pragma once + +#include "paths.hpp" + +#include + +#include +#include + +#include +#include +#include +#include + +class DbgHelp { +public: + DbgHelp() : dbghelp{pdb::DbgHelp::post_mortem()} { BOOST_TEST_MESSAGE("Initializing DbgHelp"); } + + ~DbgHelp() { BOOST_TEST_MESSAGE("Cleaning up DbgHelp"); } + + const pdb::DbgHelp dbghelp; + +private: + DbgHelp(const DbgHelp&) = delete; + DbgHelp& operator=(const DbgHelp&) = delete; +}; + +template +using Set = std::unordered_set; + +template +Set join(Set&& xs, Set&& ys) { + xs.insert(std::make_move_iterator(ys.begin()), std::make_move_iterator(ys.end())); + return std::move(xs); +} + +class DbgHelpWithSymbols : public DbgHelp { +public: + DbgHelpWithSymbols() { load_test_lib_pdb(); } + + static const std::string& get_namespace() { + static const std::string name{"test"}; + return name; + } + + typedef Set SymbolList; + + static SymbolList expected_functions() { return make_qualified({"foo", "bar", "baz"}); } + + static SymbolList expected_variables() { return make_qualified({"var"}); } + + static SymbolList expected_symbols() { + return join(expected_functions(), expected_variables()); + } + +private: + static SymbolList make_qualified(SymbolList&& plain) { + SymbolList qualified; + for (auto&& name : plain) { + qualified.emplace(get_namespace() + "::" + std::move(name)); + } + return qualified; + } + + void load_test_lib_pdb() { + const auto pdb_path = get_test_lib_pdb_path().string(); + BOOST_TEST_MESSAGE("Loading PDB: " << pdb_path); + dbghelp.load_pdb(pdb_path); + } + + static boost::filesystem::path get_test_lib_pdb_path() { + return Paths::get().exe_dir / "test_lib.pdb"; + } +}; diff --git a/test/unit_tests/paths.hpp b/test/unit_tests/paths.hpp new file mode 100644 index 0000000..561ca4d --- /dev/null +++ b/test/unit_tests/paths.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +using path = boost::filesystem::path; + +class FixFilesystem { +public: + FixFilesystem() { boost::nowide::nowide_filesystem(); } +}; + +class Paths { +public: + typedef boost::filesystem::path path; + + static Paths& get() { + static FixFilesystem fix_filesystem; + static Paths instance; + return instance; + } + + Paths() : exe_path{get_executable_path()}, exe_dir{exe_path.parent_path()} {} + + const path exe_path; + const path exe_dir; + +private: + static path get_executable_path() { + const auto argv0 = boost::unit_test::framework::master_test_suite().argv[0]; + return boost::filesystem::system_complete(argv0); + } + + Paths(const Paths&) = delete; + Paths& operator=(const Paths&) = delete; +}; diff --git a/test/unit_tests/utils.hpp b/test/unit_tests/utils.hpp deleted file mode 100644 index 561ca4d..0000000 --- a/test/unit_tests/utils.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include -#include -#include - -using path = boost::filesystem::path; - -class FixFilesystem { -public: - FixFilesystem() { boost::nowide::nowide_filesystem(); } -}; - -class Paths { -public: - typedef boost::filesystem::path path; - - static Paths& get() { - static FixFilesystem fix_filesystem; - static Paths instance; - return instance; - } - - Paths() : exe_path{get_executable_path()}, exe_dir{exe_path.parent_path()} {} - - const path exe_path; - const path exe_dir; - -private: - static path get_executable_path() { - const auto argv0 = boost::unit_test::framework::master_test_suite().argv[0]; - return boost::filesystem::system_complete(argv0); - } - - Paths(const Paths&) = delete; - Paths& operator=(const Paths&) = delete; -}; -- cgit v1.2.3