clang-tidy: wrap test_utils.hpp in cpp
Introduced a temporary wrapper `.cpp` file that includes
`test_utils.hpp` to allow clang-tidy to analyze the header
in the correct compilation context.
clang-tidy was failing to resolve includes like `actions/action.hpp`
when run directly on `test_utils.hpp`, due to missing include path
context in the compilation database. This is a known limitation when
analyzing header files outside of a translation unit.
By wrapping the header in a `.cpp` file and running clang-tidy on
that instead, we ensure that all include paths and macros are
correctly applied, resolving false-positive errors and improving
static analysis reliability.
Change-Id: I9a72d14ab844c0b53eebea6229e0bc22ff8aa273
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
diff --git a/phosphor-regulators/test/meson.build b/phosphor-regulators/test/meson.build
index 3db580f..20fa19d 100644
--- a/phosphor-regulators/test/meson.build
+++ b/phosphor-regulators/test/meson.build
@@ -24,6 +24,7 @@
'sensor_monitoring_tests.cpp',
'sensors_tests.cpp',
'system_tests.cpp',
+ 'test_utils.cpp',
'write_verification_error_tests.cpp',
'actions/action_environment_tests.cpp',
'actions/action_error_tests.cpp',
diff --git a/phosphor-regulators/test/test_utils.cpp b/phosphor-regulators/test/test_utils.cpp
new file mode 100644
index 0000000..0cbe262
--- /dev/null
+++ b/phosphor-regulators/test/test_utils.cpp
@@ -0,0 +1,8 @@
+// This .cpp file was added as a workaround for clang-tidy limitations.
+// Meson runs clang-tidy directly on headers (.hpp), but the tool relies on
+// compile_commands.json, which only defines context for .cpp files.
+// This results in invalid diagnostics when headers are processed alone.
+// The workaround ensures headers like test_utils.hpp are properly analyzed
+// via corresponding .cpp compilation units using HeaderFilterRegex settings.
+
+#include "test_utils.hpp"
diff --git a/phosphor-regulators/test/test_utils.hpp b/phosphor-regulators/test/test_utils.hpp
index b3df87a..24084f8 100644
--- a/phosphor-regulators/test/test_utils.hpp
+++ b/phosphor-regulators/test/test_utils.hpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "action.hpp"
#include "chassis.hpp"
#include "configuration.hpp"