Переглянути джерело

Changed AzTest to fail when no tests were found. (#11231)

* Changed test suites to fail if 0 tests are run. Disabled test suites that would fail. Updated gem templates to start as disabled.
SSpalding 2 роки тому
батько
коміт
5769b615b7
22 змінених файлів з 81 додано та 53 видалено
  1. 15 2
      Code/Framework/AzTest/AzTest/AzTest.cpp
  2. 10 5
      Code/Framework/AzTest/AzTest/AzTest.h
  3. 6 3
      Gems/AWSCore/Code/CMakeLists.txt
  4. 4 3
      Gems/Blast/Code/CMakeLists.txt
  5. 8 6
      Gems/Compression/Code/CMakeLists.txt
  6. 4 3
      Gems/MotionMatching/Code/CMakeLists.txt
  7. 4 3
      Gems/RecastNavigation/Code/CMakeLists.txt
  8. 4 3
      Gems/SceneProcessing/Code/CMakeLists.txt
  9. 4 3
      Gems/Streamer/StreamerProfiler/Code/CMakeLists.txt
  10. 1 1
      Templates/CppToolGem/Template/Code/Platform/Android/PAL_android.cmake
  11. 2 2
      Templates/CppToolGem/Template/Code/Platform/Linux/PAL_linux.cmake
  12. 2 2
      Templates/CppToolGem/Template/Code/Platform/Mac/PAL_mac.cmake
  13. 2 2
      Templates/CppToolGem/Template/Code/Platform/Windows/PAL_windows.cmake
  14. 1 1
      Templates/CppToolGem/Template/Code/Platform/iOS/PAL_ios.cmake
  15. 1 1
      Templates/DefaultGem/Template/Code/Platform/Android/PAL_android.cmake
  16. 2 2
      Templates/DefaultGem/Template/Code/Platform/Linux/PAL_linux.cmake
  17. 2 2
      Templates/DefaultGem/Template/Code/Platform/Mac/PAL_mac.cmake
  18. 2 2
      Templates/DefaultGem/Template/Code/Platform/Windows/PAL_windows.cmake
  19. 1 1
      Templates/DefaultGem/Template/Code/Platform/iOS/PAL_ios.cmake
  20. 2 2
      Templates/PythonToolGem/Template/Code/Platform/Linux/PAL_linux.cmake
  21. 2 2
      Templates/PythonToolGem/Template/Code/Platform/Mac/PAL_mac.cmake
  22. 2 2
      Templates/PythonToolGem/Template/Code/Platform/Windows/PAL_windows.cmake

+ 15 - 2
Code/Framework/AzTest/AzTest/AzTest.cpp

@@ -125,7 +125,7 @@ namespace AZ
             {
                 // the --unittest parameter makes us run tests built inside this executable
 
-                // first, remove the unit test parameter so that it doesn't get passed into google 
+                // first, remove the unit test parameter so that it doesn't get passed into google
                 // test, which would potentially generate warnings since its a non standard param:
                 int unitTestIndex = GetParameterIndex(argc, argv, "--unittest");
                 if (unitTestIndex != -1)
@@ -161,6 +161,11 @@ namespace AZ
                 AZ::Test::printUnusedParametersWarning(argc, argv);
                 AZ::Test::addTestEnvironments(m_envs);
                 m_returnCode = RUN_ALL_TESTS();
+                if (::testing::UnitTest::GetInstance()->test_to_run_count() == 0)
+                {
+                    std::cerr << "No tests were found for last suite ran!" << std::endl;
+                    m_returnCode = 1;
+                }
                 return true;
             }
             else if (ContainsParameter(argc, argv, "--loadunittests"))
@@ -279,7 +284,15 @@ namespace AZ
 
             AZ::Test::printUnusedParametersWarning(argc, argv);
 
-            return RUN_ALL_TESTS();
+            int returnCode = RUN_ALL_TESTS()
+            if (::testing::UnitTest::GetInstance()->test_to_run_count() == 0)
+            {
+                std::cerr << "No tests were found for last suite ran!" << std::endl;
+                m_returnCode = 1;
+            }
+            return returnCode;
+
+
 #else // AZ_MONOLITHIC_BUILD
             int result = 0;
             std::shared_ptr<AZ::Test::IModuleHandle> module = platform.GetModule(lib);

+ 10 - 5
Code/Framework/AzTest/AzTest/AzTest.h

@@ -104,7 +104,7 @@ namespace AZ
 
         void addTestEnvironment(ITestEnvironment* env);
         void addTestEnvironments(std::vector<ITestEnvironment*> envs);
-        
+
         //! A hook that can be used to read any other misc parameters and remove them before google sees them.
         //! Note that this modifies argc and argv to delete the parameters it consumes.
         void ApplyGlobalParameters(int* argc, char** argv);
@@ -231,7 +231,7 @@ namespace AZ
         {
         public:
             std::list<std::string> resultList;
-            
+
             void OnTestEnd(const ::testing::TestInfo& test_info) override
             {
                 std::string result;
@@ -284,6 +284,11 @@ namespace AZ
         AZ::Test::printUnusedParametersWarning(argc, argv);                                             \
         AZ::Test::addTestEnvironments({TEST_ENV});                                                      \
         int result = RUN_ALL_TESTS();                                                                   \
+        if (::testing::UnitTest::GetInstance()->test_to_run_count() == 0)                               \
+        {                                                                                               \
+            std::cerr << "No tests were found for last suite ran!" << std::endl;                        \
+            result = 1;                                                                                 \
+        }                                                                                               \
         return result;                                                                                  \
     }
 
@@ -416,7 +421,7 @@ int main(int argc, char** argv)
             static AZ::Test::TestEnvironmentRegistry* AZ_UNIT_TEST_HOOK_REGISTRY_NAME =\
                 new( AZ_OS_MALLOC(sizeof(AZ::Test::TestEnvironmentRegistry),           \
                                   alignof(AZ::Test::TestEnvironmentRegistry)))         \
-              AZ::Test::TestEnvironmentRegistry({ TEST_ENV }, AZ_MODULE_NAME, true);         
+              AZ::Test::TestEnvironmentRegistry({ TEST_ENV }, AZ_MODULE_NAME, true);
 
 #define AZ_BENCHMARK_HOOK_ENV(TEST_ENV)
 #define AZ_BENCHMARK_HOOK()
@@ -426,7 +431,7 @@ int main(int argc, char** argv)
 
 
 // These macros are needed to implement unit test hooks necessary for running AzUnitTests or AzBenchmarks.
-// 
+//
 
 /* For unit test modules that implement AzUnitTests and AzBenchmarkTests with either a custom environment for AzUnitTests or a custom environment class for AzBenchmarks
    the follow use the overloaded 'IMPLEMENT_AZ_UNIT_TEST_HOOKS' macro
@@ -435,7 +440,7 @@ int main(int argc, char** argv)
 
    // Implement unit test hooks without a custom AzUnitTest or AzBenchmark environment,
    AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);
-   
+
    // Implement unit test hooks with a custom AzUnitTest environment
    AZ_UNIT_TEST_HOOK(new CustomEnvClass());
 

+ 6 - 3
Gems/AWSCore/Code/CMakeLists.txt

@@ -206,9 +206,12 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
                     Gem::AWSCore.Static
                     Gem::AWSCore.Editor.Static
         )
-        ly_add_googletest(
-            NAME Gem::AWSCore.Editor.Tests
-        )
+        set(SUPPORTED_PLATFORMS "Windows")
+        if ("${PAL_PLATFORM_NAME}" IN_LIST SUPPORTED_PLATFORMS)
+            ly_add_googletest(
+                NAME Gem::AWSCore.Editor.Tests
+            )
+        endif()
     endif()
 endif()
 

+ 4 - 3
Gems/Blast/Code/CMakeLists.txt

@@ -165,8 +165,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
                     AZ::AzToolsFrameworkTestCommon
                     Gem::Blast.Editor.Static
         )
-        ly_add_googletest(
-            NAME Gem::Blast.Editor.Tests
-        )
+        # Commented out as currently there are no Blast Editor tests
+        # ly_add_googletest(
+            # NAME Gem::Blast.Editor.Tests
+        # )
     endif()
 endif()

+ 8 - 6
Gems/Compression/Code/CMakeLists.txt

@@ -171,9 +171,10 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
         )
 
         # Add Compression.Tests to googletest
-        ly_add_googletest(
-            NAME Gem::Compression.Tests
-        )
+        # Commented out as currently there are no Compression tests
+        #ly_add_googletest(
+            #NAME Gem::Compression.Tests
+        #)
     endif()
 
     # If we are a host platform we want to add tools test like editor tests here
@@ -198,9 +199,10 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
             )
 
             # Add Compression.Editor.Tests to googletest
-            ly_add_googletest(
-                NAME Gem::Compression.Editor.Tests
-            )
+            # Commented out as currently there are no Compression Editor tests
+            # ly_add_googletest(
+                # NAME Gem::Compression.Editor.Tests
+            # )
         endif()
     endif()
 endif()

+ 4 - 3
Gems/MotionMatching/Code/CMakeLists.txt

@@ -140,8 +140,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
         )
 
         # Add MotionMatching.Editor.Tests to googletest
-        ly_add_googletest(
-            NAME Gem::MotionMatching.Editor.Tests
-        )
+        # Commented out as currently there are no MotionMatching Editor tests
+        # ly_add_googletest(
+            # NAME Gem::MotionMatching.Editor.Tests
+        # )
     endif()
 endif()

+ 4 - 3
Gems/RecastNavigation/Code/CMakeLists.txt

@@ -285,9 +285,10 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
             )
 
             # Add RecastNavigation.Editor.Tests to googletest
-            ly_add_googletest(
-                NAME Gem::RecastNavigation.Editor.Tests
-            )
+            # Commented out as currently there are no RecastNavigation Editor tests
+            # ly_add_googletest(
+                # NAME Gem::RecastNavigation.Editor.Tests
+            # )
         endif()
     endif()
 endif()

+ 4 - 3
Gems/SceneProcessing/Code/CMakeLists.txt

@@ -91,9 +91,10 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
         RUNTIME_DEPENDENCIES
             Gem::SceneProcessing
     )
-    ly_add_googletest(
-        NAME Gem::SceneProcessing.Tests
-    )
+    # Commented out as currently there are no SceneProcessing tests
+    # ly_add_googletest(
+        # NAME Gem::SceneProcessing.Tests
+    # )
 
     if (PAL_TRAIT_BUILD_HOST_TOOLS)
         ly_add_target(

+ 4 - 3
Gems/Streamer/StreamerProfiler/Code/CMakeLists.txt

@@ -84,8 +84,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
         )
 
         # Add StreamerProfiler.Tests to googletest
-        ly_add_googletest(
-            NAME Gem::StreamerProfiler.Tests
-        )
+        # Commented out as currently there are no StreamerProfiler tests
+        # ly_add_googletest(
+            # NAME Gem::StreamerProfiler.Tests
+        # )
     endif()
 endif()

+ 1 - 1
Templates/CppToolGem/Template/Code/Platform/Android/PAL_android.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
 set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/CppToolGem/Template/Code/Platform/Linux/PAL_linux.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/CppToolGem/Template/Code/Platform/Mac/PAL_mac.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/CppToolGem/Template/Code/Platform/Windows/PAL_windows.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 1 - 1
Templates/CppToolGem/Template/Code/Platform/iOS/PAL_ios.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
 set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 1 - 1
Templates/DefaultGem/Template/Code/Platform/Android/PAL_android.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
 set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/DefaultGem/Template/Code/Platform/Linux/PAL_linux.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/DefaultGem/Template/Code/Platform/Mac/PAL_mac.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/DefaultGem/Template/Code/Platform/Windows/PAL_windows.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 1 - 1
Templates/DefaultGem/Template/Code/Platform/iOS/PAL_ios.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
 set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/PythonToolGem/Template/Code/Platform/Linux/PAL_linux.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/PythonToolGem/Template/Code/Platform/Mac/PAL_mac.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)

+ 2 - 2
Templates/PythonToolGem/Template/Code/Platform/Windows/PAL_windows.cmake

@@ -7,5 +7,5 @@
 # {END_LICENSE}
 
 set(PAL_TRAIT_${NameUpper}_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED TRUE)
-set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED TRUE)
+set(PAL_TRAIT_${NameUpper}_TEST_SUPPORTED FALSE)
+set(PAL_TRAIT_${NameUpper}_EDITOR_TEST_SUPPORTED FALSE)