test treewide: iwyu
These changes are done by running iwyu manually under clang14.
Suppressed some obvious impl or details headers. Kept the recommended
public headers.
IWYU can increase readability, make maintenance easier, and avoid errors
in some cases. See details in
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md.
This commit also uses its best effort to correct obvious errors through
iwyu pragma.
See reference here:
https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes
Tested: unit test passed.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I983b6f75601707cbb0f2f04546c3362ff4ba7fee
diff --git a/include/ut/dbus_utility_test.cpp b/include/ut/dbus_utility_test.cpp
index a8fad63..71978d0 100644
--- a/include/ut/dbus_utility_test.cpp
+++ b/include/ut/dbus_utility_test.cpp
@@ -2,7 +2,11 @@
#include <string>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace dbus::utility
{
diff --git a/include/ut/http_utility_test.cpp b/include/ut/http_utility_test.cpp
index c92bf1e..e412e17 100644
--- a/include/ut/http_utility_test.cpp
+++ b/include/ut/http_utility_test.cpp
@@ -1,6 +1,10 @@
#include "http_utility.hpp"
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace http_helpers
{
diff --git a/include/ut/human_sort_test.cpp b/include/ut/human_sort_test.cpp
index 938b582..be21a19 100644
--- a/include/ut/human_sort_test.cpp
+++ b/include/ut/human_sort_test.cpp
@@ -3,8 +3,13 @@
#include <set>
#include <string>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
namespace
{
diff --git a/include/ut/multipart_test.cpp b/include/ut/multipart_test.cpp
index 154f018..7ad7d98 100644
--- a/include/ut/multipart_test.cpp
+++ b/include/ut/multipart_test.cpp
@@ -1,13 +1,23 @@
#include "http/http_request.hpp"
#include "multipart_parser.hpp"
+#include <boost/beast/http/fields.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/string_body.hpp>
-#include <map>
+#include <memory>
+#include <string_view>
#include <system_error>
+#include <vector>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <boost/beast/http/impl/fields.hpp>
+// IWYU pragma: no_include <boost/intrusive/detail/list_iterator.hpp>
+// IWYU pragma: no_include <boost/intrusive/detail/tree_iterator.hpp>
namespace
{
diff --git a/include/ut/openbmc_dbus_rest_test.cpp b/include/ut/openbmc_dbus_rest_test.cpp
index 7efd10d..b01e92a 100644
--- a/include/ut/openbmc_dbus_rest_test.cpp
+++ b/include/ut/openbmc_dbus_rest_test.cpp
@@ -1,7 +1,12 @@
#include "openbmc_dbus_rest.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
namespace crow::openbmc_mapper
{