From da21ebcd291dbf18284402447f18649021763d0f Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 4 Dec 2023 20:07:23 -0800 Subject: [PATCH] [Impeller] Remove duplicate entity test suite instantiations. (flutter/engine#48654) And make it illegal to do so in the future. Now, making such a mistake will lead to a linker error complaining about duplicate definitions of `kYouInstantiatedEntityTestMultipleTimes`. Fixes https://github.com/flutter/flutter/issues/139090 --- .../checkerboard_contents_unittests.cc | 1 - .../tiled_texture_contents_unittests.cc | 1 - .../contents/vertices_contents_unittests.cc | 1 - .../impeller/playground/playground_test.h | 18 ++++++++++-------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/checkerboard_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/checkerboard_contents_unittests.cc index b69ab65992..4632862002 100644 --- a/engine/src/flutter/impeller/entity/contents/checkerboard_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/checkerboard_contents_unittests.cc @@ -17,7 +17,6 @@ namespace impeller { namespace testing { using EntityTest = EntityPlayground; -INSTANTIATE_PLAYGROUND_SUITE(EntityTest); #ifdef IMPELLER_DEBUG TEST(EntityTest, HasNulloptCoverage) { diff --git a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc index 9d12c22287..2ec54a8567 100644 --- a/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/tiled_texture_contents_unittests.cc @@ -15,7 +15,6 @@ namespace impeller { namespace testing { using EntityTest = EntityPlayground; -INSTANTIATE_PLAYGROUND_SUITE(EntityTest); TEST_P(EntityTest, TiledTextureContentsRendersWithCorrectPipeline) { TextureDescriptor texture_desc; diff --git a/engine/src/flutter/impeller/entity/contents/vertices_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/vertices_contents_unittests.cc index 9ad4368f04..5d928e12f5 100644 --- a/engine/src/flutter/impeller/entity/contents/vertices_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/vertices_contents_unittests.cc @@ -21,7 +21,6 @@ namespace impeller { namespace testing { using EntityTest = EntityPlayground; -INSTANTIATE_PLAYGROUND_SUITE(EntityTest); std::shared_ptr CreateColorVertices( const std::vector& vertices, diff --git a/engine/src/flutter/impeller/playground/playground_test.h b/engine/src/flutter/impeller/playground/playground_test.h index df62dee2fc..7aba4ee891 100644 --- a/engine/src/flutter/impeller/playground/playground_test.h +++ b/engine/src/flutter/impeller/playground/playground_test.h @@ -55,14 +55,16 @@ class PlaygroundTest : public Playground, PlaygroundTest& operator=(const PlaygroundTest&) = delete; }; -#define INSTANTIATE_PLAYGROUND_SUITE(playground) \ - INSTANTIATE_TEST_SUITE_P( \ - Play, playground, \ - ::testing::Values(PlaygroundBackend::kMetal, \ - PlaygroundBackend::kOpenGLES, \ - PlaygroundBackend::kVulkan), \ - [](const ::testing::TestParamInfo& info) { \ - return PlaygroundBackendToString(info.param); \ +#define INSTANTIATE_PLAYGROUND_SUITE(playground) \ + [[maybe_unused]] const char* kYouInstantiated##playground##MultipleTimes = \ + ""; \ + INSTANTIATE_TEST_SUITE_P( \ + Play, playground, \ + ::testing::Values(PlaygroundBackend::kMetal, \ + PlaygroundBackend::kOpenGLES, \ + PlaygroundBackend::kVulkan), \ + [](const ::testing::TestParamInfo& info) { \ + return PlaygroundBackendToString(info.param); \ }); } // namespace impeller