diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/CMakeLists.txt b/AutomatedTesting/Gem/PythonCoverage/Code/CMakeLists.txt index 65b6d7509f..6d0242d02e 100644 --- a/AutomatedTesting/Gem/PythonCoverage/Code/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonCoverage/Code/CMakeLists.txt @@ -28,14 +28,16 @@ if(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED) PUBLIC PYTHON_COVERAGE_EDITOR PRIVATE - LY_TEST_IMPACT_DEFAULT_CONFIG_FILE=\"\" + ${LY_TEST_IMPACT_CONFIG_FILE_PATH_DEFINITION} BUILD_DEPENDENCIES PUBLIC AZ::AzToolsFramework + RUNTIME_DEPENDENCIES + Gem::EditorPythonBindings.Editor ) ly_add_target( - NAME PythonCoverage.Editor MODULE + NAME PythonCoverage.Editor GEM_MODULE NAMESPACE Gem AUTOMOC OUTPUT_NAME Gem.PythonCoverage.Editor @@ -58,26 +60,3 @@ if(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED) ly_create_alias(NAME PythonCoverage.Builders NAMESPACE Gem TARGETS Gem::PythonCoverage.Editor) endif() endif() - -if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) - if(PAL_TRAIT_BUILD_HOST_TOOLS) - ly_add_target( - NAME PythonCoverage.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE Gem - FILES_CMAKE - pythoncoverage_editor_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Tests - Source - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - Gem::PythonCoverage.Editor - ) - - ly_add_googletest( - NAME Gem::PythonCoverage.Editor.Tests - ) - endif() -endif() \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp index 95a084570c..c33986192a 100644 --- a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp +++ b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.cpp @@ -76,20 +76,18 @@ namespace PythonCoverage void PythonCoverageEditorSystemComponent::ParseCoverageOutputDirectory() { m_coverageState = CoverageState::Disabled; - - // Config file path will be empty if test impact analysis framework is disabled at the build config level const AZStd::string configFilePath = LY_TEST_IMPACT_DEFAULT_CONFIG_FILE; if (configFilePath.empty()) { - AZ_Warning(Caller, false, "No test impact analysis framework config found."); + AZ_Warning(Caller, false, "No test impact analysis framework config file specified."); return; } const auto fileSize = AZ::IO::SystemFile::Length(configFilePath.c_str()); if(!fileSize) { - AZ_Error(Caller, false, "File '%s' does not exist", configFilePath.c_str()); + AZ_Error(Caller, false, "Test impact analysis framework config file '%s' does not exist", configFilePath.c_str()); return; } @@ -97,7 +95,7 @@ namespace PythonCoverage buffer[fileSize] = '\0'; if (!AZ::IO::SystemFile::Read(configFilePath.c_str(), buffer.data())) { - AZ_Error(Caller, false, "Could not read contents of file '%s'", configFilePath.c_str()); + AZ_Error(Caller, false, "Could not read contents of test impact analysis framework config file '%s'", configFilePath.c_str()); return; } @@ -105,13 +103,13 @@ namespace PythonCoverage rapidjson::Document configurationFile; if (configurationFile.Parse(configurationData.c_str()).HasParseError()) { - AZ_Error(Caller, false, "Could not parse runtimeConfig data, JSON has errors"); + AZ_Error(Caller, false, "Could not parse test impact analysis framework config file data, JSON has errors"); return; } const auto& tempConfig = configurationFile["workspace"]["temp"]; - // Temo directory root path is absolute + // Temp directory root path is absolute const AZ::IO::Path tempWorkspaceRootDir = tempConfig["root"].GetString(); // Artifact directory is relative to temp directory root @@ -212,7 +210,7 @@ namespace PythonCoverage return coveringModuleOutputNames; } - void PythonCoverageEditorSystemComponent::OnExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, [[maybe_unused]] const AZStd::vector& args) + void PythonCoverageEditorSystemComponent::OnStartExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, [[maybe_unused]] const AZStd::vector& args) { if (m_coverageState == CoverageState::Disabled) { diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.h b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.h index 13101ff19c..68f9299bcc 100644 --- a/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.h +++ b/AutomatedTesting/Gem/PythonCoverage/Code/Source/PythonCoverageEditorSystemComponent.h @@ -47,7 +47,7 @@ namespace PythonCoverage void OnEntityActivated(const AZ::EntityId& entityId) override; // AZ::EditorPythonScriptNotificationsBus ... - void OnExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, const AZStd::vector& args) override; + void OnStartExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, const AZStd::vector& args) override; //! Attempts to parse the test impact analysis framework configuration file. //! If either the test impact analysis framework is disabled or the configuration file cannot be parsed, python coverage diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/Tests/PythonCoverageEditorTest.cpp b/AutomatedTesting/Gem/PythonCoverage/Code/Tests/PythonCoverageEditorTest.cpp deleted file mode 100644 index 2c97ecaf73..0000000000 --- a/AutomatedTesting/Gem/PythonCoverage/Code/Tests/PythonCoverageEditorTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include - -class PythonCoverageEditorTest - : public ::testing::Test -{ -protected: - void SetUp() override - { - - } - - void TearDown() override - { - - } -}; - -TEST_F(PythonCoverageEditorTest, SanityTest) -{ - ASSERT_TRUE(true); -} - -AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); diff --git a/AutomatedTesting/Gem/PythonCoverage/Code/pythoncoverage_editor_tests_files.cmake b/AutomatedTesting/Gem/PythonCoverage/Code/pythoncoverage_editor_tests_files.cmake deleted file mode 100644 index f1912e743a..0000000000 --- a/AutomatedTesting/Gem/PythonCoverage/Code/pythoncoverage_editor_tests_files.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - Tests/PythonCoverageEditorTest.cpp -) diff --git a/AutomatedTesting/Gem/PythonCoverage/gem.json b/AutomatedTesting/Gem/PythonCoverage/gem.json index 3ec79ac633..a31ee8adcb 100644 --- a/AutomatedTesting/Gem/PythonCoverage/gem.json +++ b/AutomatedTesting/Gem/PythonCoverage/gem.json @@ -1,9 +1,7 @@ { "gem_name": "PythonCoverage", - "origin": "The primary repo for PythonCoverage goes here: i.e. http://www.mydomain.com", - "license": "What license PythonCoverage uses goes here: i.e. https://opensource.org/licenses/MIT", "display_name": "PythonCoverage", - "summary": "A short description of PythonCoverage.", + "summary": "A tool for generating gem coverage for Python tests.", "canonical_tags": [ "Gem" ], diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonRunnerNotificationBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonRunnerNotificationBus.h deleted file mode 100644 index ffd161d295..0000000000 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonRunnerNotificationBus.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. - * - * For complete copyright and license terms please see the LICENSE at the root of this - * distribution (the "License"). All use of this software is governed by the License, - * or, if provided, by the license below or the license accompanying this file. Do not - * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - */ -#pragma once - -#include - -namespace AzToolsFramework -{ - //! Provides a bus to notify when Python scripts are about to run. - class EditorPythonRunnerNotification - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - ////////////////////////////////////////////////////////////////////////// - - //! Notifies the execution of a Python script using a string. - virtual void ExecuteByString([[maybe_unused]] AZStd::string_view script) {} - - //! Notifies the execution of a Python script using a filename. - virtual void ExecuteByFilename([[maybe_unused]] AZStd::string_view filename) {} - - //! Notifies the execution of a Python script using a filename and args. - virtual void ExecuteByFilenameWithArgs( - [[maybe_unused]] AZStd::string_view filename, [[maybe_unused]] const AZStd::vector& args) {} - - //! Notifies the execution of a Python script as a test. - virtual void ExecuteByFilenameAsTest( - [[maybe_unused]] AZStd::string_view filename, [[maybe_unused]] const AZStd::vector& args) {} - }; - using EditorPythonRunnerNotificationBus = AZ::EBus; - -} // namespace AzToolsFramework - diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonScriptNotificationsBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonScriptNotificationsBus.h index 586a348e76..7586293a38 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonScriptNotificationsBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorPythonScriptNotificationsBus.h @@ -27,18 +27,18 @@ namespace AzToolsFramework static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; ////////////////////////////////////////////////////////////////////////// - //! Notifies the execution of a Python script using a string. - virtual void OnExecuteByString([[maybe_unused]] AZStd::string_view script) {} + //! Notifies the start of execution of a Python script using a string. + virtual void OnStartExecuteByString([[maybe_unused]] AZStd::string_view script) {} - //! Notifies the execution of a Python script using a filename. - virtual void OnExecuteByFilename([[maybe_unused]] AZStd::string_view filename) {} + //! Notifies the start of execution of a Python script using a filename. + virtual void OnStartExecuteByFilename([[maybe_unused]] AZStd::string_view filename) {} - //! Notifies the execution of a Python script using a filename and args. - virtual void OnExecuteByFilenameWithArgs( + //! Notifies the start of execution of a Python script using a filename and args. + virtual void OnStartExecuteByFilenameWithArgs( [[maybe_unused]] AZStd::string_view filename, [[maybe_unused]] const AZStd::vector& args) {} - //! Notifies the execution of a Python script as a test. - virtual void OnExecuteByFilenameAsTest( + //! Notifies the start of execution of a Python script as a test. + virtual void OnStartExecuteByFilenameAsTest( [[maybe_unused]] AZStd::string_view filename, [[maybe_unused]] AZStd::string_view testCase, [[maybe_unused]] const AZStd::vector& args) {} }; using EditorPythonScriptNotificationsBus = AZ::EBus; diff --git a/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp b/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp index e9e75b966f..e390578818 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp @@ -581,7 +581,7 @@ namespace EditorPythonBindings if (!script.empty()) { AzToolsFramework::EditorPythonScriptNotificationsBus::Broadcast( - &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnExecuteByString, script); + &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnStartExecuteByString, script); // Acquire GIL before calling Python code AZStd::lock_guard lock(m_lock); @@ -644,14 +644,14 @@ namespace EditorPythonBindings { AZStd::vector args; AzToolsFramework::EditorPythonScriptNotificationsBus::Broadcast( - &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnExecuteByFilename, filename); + &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnStartExecuteByFilename, filename); ExecuteByFilenameWithArgs(filename, args); } void PythonSystemComponent::ExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, const AZStd::vector& args) { AzToolsFramework::EditorPythonScriptNotificationsBus::Broadcast( - &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnExecuteByFilenameAsTest, filename, testCase, args); + &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnStartExecuteByFilenameAsTest, filename, testCase, args); const Result evalResult = EvaluateFile(filename, args); if (evalResult == Result::Okay) { @@ -668,7 +668,7 @@ namespace EditorPythonBindings void PythonSystemComponent::ExecuteByFilenameWithArgs(AZStd::string_view filename, const AZStd::vector& args) { AzToolsFramework::EditorPythonScriptNotificationsBus::Broadcast( - &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnExecuteByFilenameWithArgs, filename, args); + &AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnStartExecuteByFilenameWithArgs, filename, args); EvaluateFile(filename, args); }