Remove PythonCoverage runtime component

Signed-off-by: John <jonawals@amazon.com>
monroegm-disable-blank-issue-2
John 5 years ago
parent 0e0f266fdd
commit 478ffeeac6

@ -1,21 +1,12 @@
set(o3de_gem_path ${CMAKE_CURRENT_LIST_DIR})
set(o3de_gem_json ${o3de_gem_path}/gem.json)
o3de_read_json_key(o3de_gem_name ${o3de_gem_json} "gem_name")
o3de_restricted_path(${o3de_gem_json} o3de_gem_restricted_path)
# Currently we are in the DefaultProjectSource folder: ${CMAKE_CURRENT_LIST_DIR}
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
# Note: ly_get_list_relative_pal_filename will take care of the details for us, as this may be a restricted platform
# in which case it will see if that platform is present here or in the restricted folder.
# i.e. It could here: DefaultProjectSource/Platform/<platorm_name> or
# <restricted_folder>/<platform_name>/DefaultProjectSource
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} ${o3de_gem_restricted_path} ${o3de_gem_path} ${o3de_gem_name})
# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
# project cmake for this platform.
include(${pal_dir}/${PAL_PLATFORM_NAME_LOWERCASE}_gem.cmake)
ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty)
#
# 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.
#
add_subdirectory(Code)

@ -1,127 +1,74 @@
#
# 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.
#
# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
# Note: ly_get_list_relative_pal_filename will take care of the details for us, as this may be a restricted platform
# in which case it will see if that platform is present here or in the restricted folder.
# i.e. It could here in our gem : Gems/PythonCoverage/Code/Platform/<platorm_name> or
# <restricted_folder>/<platform_name>/Gems/PythonCoverage/Code
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} ${o3de_gem_restricted_path} ${o3de_gem_path} ${o3de_gem_name})
# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
# is supported by this platform.
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
# Add the PythonCoverage.Static target
# Note: We include the common files and the platform specific files which are set in pythoncoverage_common_files.cmake
# and in ${pal_dir}/pythoncoverage_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
ly_add_target(
NAME PythonCoverage.Static STATIC
NAMESPACE Gem
FILES_CMAKE
pythoncoverage_files.cmake
${pal_dir}/pythoncoverage_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
AZ::AzFramework
)
# Here add PythonCoverage target, it depends on the PythonCoverage.Static
ly_add_target(
NAME PythonCoverage ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
pythoncoverage_shared_files.cmake
${pal_dir}/pythoncoverage_shared_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PRIVATE
Gem::PythonCoverage.Static
)
# By default, we will specify that the above target PythonCoverage would be used by
# Client and Server type targets when this gem is enabled. If you don't want it
# active in Clients or Servers by default, delete one of both of the following lines:
ly_create_alias(NAME PythonCoverage.Clients NAMESPACE Gem TARGETS Gem::PythonCoverage)
ly_create_alias(NAME PythonCoverage.Servers NAMESPACE Gem TARGETS Gem::PythonCoverage)
# If we are on a host platform, we want to add the host tools targets like the PythonCoverage.Editor target which
# will also depend on PythonCoverage.Static
if(PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_target(
NAME PythonCoverage.Editor.Static STATIC
NAMESPACE Gem
FILES_CMAKE
pythoncoverage_editor_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
COMPILE_DEFINITIONS
PUBLIC
PYTHON_COVERAGE_EDITOR
PRIVATE
LY_TEST_IMPACT_DEFAULT_CONFIG_FILE=\"\"
BUILD_DEPENDENCIES
PUBLIC
AZ::AzToolsFramework
Gem::PythonCoverage.Static
)
ly_add_target(
NAME PythonCoverage.Editor MODULE
NAMESPACE Gem
AUTOMOC
OUTPUT_NAME Gem.PythonCoverage.Editor
FILES_CMAKE
pythoncoverage_editor_shared_files.cmake
COMPILE_DEFINITIONS
PRIVATE
PYTHON_COVERAGE_EDITOR
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
Gem::PythonCoverage.Editor.Static
)
# By default, we will specify that the above target PythonCoverage would be used by
# Tool and Builder type targets when this gem is enabled. If you don't want it
# active in Tools or Builders by default, delete one of both of the following lines:
ly_create_alias(NAME PythonCoverage.Tools NAMESPACE Gem TARGETS Gem::PythonCoverage.Editor)
ly_create_alias(NAME PythonCoverage.Builders NAMESPACE Gem TARGETS Gem::PythonCoverage.Editor)
if(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED)
if(PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_target(
NAME PythonCoverage.Editor.Static STATIC
NAMESPACE Gem
FILES_CMAKE
pythoncoverage_editor_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
COMPILE_DEFINITIONS
PUBLIC
PYTHON_COVERAGE_EDITOR
PRIVATE
LY_TEST_IMPACT_DEFAULT_CONFIG_FILE=\"\"
BUILD_DEPENDENCIES
PUBLIC
AZ::AzToolsFramework
)
ly_add_target(
NAME PythonCoverage.Editor MODULE
NAMESPACE Gem
AUTOMOC
OUTPUT_NAME Gem.PythonCoverage.Editor
FILES_CMAKE
pythoncoverage_editor_shared_files.cmake
COMPILE_DEFINITIONS
PRIVATE
PYTHON_COVERAGE_EDITOR
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
Gem::PythonCoverage.Editor.Static
)
# By default, we will specify that the above target PythonCoverage would be used by
# Tool and Builder type targets when this gem is enabled. If you don't want it
# active in Tools or Builders by default, delete one of both of the following lines:
ly_create_alias(NAME PythonCoverage.Tools NAMESPACE Gem TARGETS Gem::PythonCoverage.Editor)
ly_create_alias(NAME PythonCoverage.Builders NAMESPACE Gem TARGETS Gem::PythonCoverage.Editor)
endif()
endif()
################################################################################
# Tests
################################################################################
# See if globally, tests are supported
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
# We globally support tests, see if we support tests on this platform for PythonCoverage.Static
if(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED)
# We support PythonCoverage.Tests on this platform, add PythonCoverage.Tests target which depends on PythonCoverage.Static
if(PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_target(
NAME PythonCoverage.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAME PythonCoverage.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
pythoncoverage_files.cmake
pythoncoverage_tests_files.cmake
pythoncoverage_editor_tests_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Tests
@ -129,40 +76,11 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
AZ::AzFramework
Gem::PythonCoverage.Static
Gem::PythonCoverage.Editor
)
# Add PythonCoverage.Tests to googletest
ly_add_googletest(
NAME Gem::PythonCoverage.Tests
NAME Gem::PythonCoverage.Editor.Tests
)
endif()
# If we are a host platform we want to add tools test like editor tests here
if(PAL_TRAIT_BUILD_HOST_TOOLS)
# We are a host platform, see if Editor tests are supported on this platform
if(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED)
# We support PythonCoverage.Editor.Tests on this platform, add PythonCoverage.Editor.Tests target which depends on PythonCoverage.Editor
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
)
# Add PythonCoverage.Editor.Tests to googletest
ly_add_googletest(
NAME Gem::PythonCoverage.Editor.Tests
)
endif()
endif()
endif()
endif()

@ -1,4 +1,12 @@
#
# 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(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED FALSE)

@ -1,8 +0,0 @@
# Platform specific files for Android
# i.e. ../Source/Android/PythonCoverageAndroid.cpp
# ../Source/Android/PythonCoverageAndroid.h
# ../Include/Android/PythonCoverageAndroid.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Android
# i.e. ../Source/Android/PythonCoverageAndroid.cpp
# ../Source/Android/PythonCoverageAndroid.h
# ../Include/Android/PythonCoverageAndroid.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Android
# i.e. ../Source/Android/PythonCoverageAndroid.cpp
# ../Source/Android/PythonCoverageAndroid.h
# ../Include/Android/PythonCoverageAndroid.h
set(FILES
)

@ -1,4 +1,12 @@
#
# 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(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED FALSE)

@ -1,8 +0,0 @@
# Platform specific files for Linux
# i.e. ../Source/Linux/PythonCoverageLinux.cpp
# ../Source/Linux/PythonCoverageLinux.h
# ../Include/Linux/PythonCoverageLinux.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Linux
# i.e. ../Source/Linux/PythonCoverageLinux.cpp
# ../Source/Linux/PythonCoverageLinux.h
# ../Include/Linux/PythonCoverageLinux.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Linux
# i.e. ../Source/Linux/PythonCoverageLinux.cpp
# ../Source/Linux/PythonCoverageLinux.h
# ../Include/Linux/PythonCoverageLinux.h
set(FILES
)

@ -1,4 +1,12 @@
#
# 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(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED FALSE)

@ -1,8 +0,0 @@
# Platform specific files for Mac
# i.e. ../Source/Mac/PythonCoverageMac.cpp
# ../Source/Mac/PythonCoverageMac.h
# ../Include/Mac/PythonCoverageMac.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Mac
# i.e. ../Source/Mac/PythonCoverageMac.cpp
# ../Source/Mac/PythonCoverageMac.h
# ../Include/Mac/PythonCoverageMac.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Mac
# i.e. ../Source/Mac/PythonCoverageMac.cpp
# ../Source/Mac/PythonCoverageMac.h
# ../Include/Mac/PythonCoverageMac.h
set(FILES
)

@ -1,4 +1,12 @@
#
# 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(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED TRUE)

@ -1,8 +0,0 @@
# Platform specific files for Windows
# i.e. ../Source/Windows/PythonCoverageWindows.cpp
# ../Source/Windows/PythonCoverageWindows.h
# ../Include/Windows/PythonCoverageWindows.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Windows
# i.e. ../Source/Windows/PythonCoverageWindows.cpp
# ../Source/Windows/PythonCoverageWindows.h
# ../Include/Windows/PythonCoverageWindows.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for Windows
# i.e. ../Source/Windows/PythonCoverageWindows.cpp
# ../Source/Windows/PythonCoverageWindows.h
# ../Include/Windows/PythonCoverageWindows.h
set(FILES
)

@ -1,4 +1,12 @@
#
# 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(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_EDITOR_TEST_SUPPORTED TRUE)
set(PAL_TRAIT_PYTHONCOVERAGE_SUPPORTED FALSE)

@ -1,8 +0,0 @@
# Platform specific files for iOS
# i.e. ../Source/iOS/PythonCoverageiOS.cpp
# ../Source/iOS/PythonCoverageiOS.h
# ../Include/iOS/PythonCoverageiOS.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for iOS
# i.e. ../Source/iOS/PythonCoverageiOS.cpp
# ../Source/iOS/PythonCoverageiOS.h
# ../Include/iOS/PythonCoverageiOS.h
set(FILES
)

@ -1,8 +0,0 @@
# Platform specific files for iOS
# i.e. ../Source/iOS/PythonCoverageiOS.cpp
# ../Source/iOS/PythonCoverageiOS.h
# ../Include/iOS/PythonCoverageiOS.h
set(FILES
)

@ -18,9 +18,7 @@ namespace PythonCoverage
AZ_CLASS_ALLOCATOR_IMPL(PythonCoverageEditorModule, AZ::SystemAllocator, 0)
PythonCoverageEditorModule::PythonCoverageEditorModule()
: PythonCoverageModule()
{
// push results of [MyComponent]::CreateDescriptor() into m_descriptors here
m_descriptors.insert(
m_descriptors.end(),
{

@ -12,15 +12,17 @@
#pragma once
#include "PythonCoverageModule.h"
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
namespace PythonCoverage
{
class PythonCoverageEditorModule : public PythonCoverageModule
class PythonCoverageEditorModule
: public AZ::Module
{
public:
AZ_CLASS_ALLOCATOR_DECL
AZ_RTTI(PythonCoverageEditorModule, "{32C0FFEA-09A7-460F-9257-5BDEF74FCD5B}", PythonCoverageModule);
AZ_RTTI(PythonCoverageEditorModule, "{32C0FFEA-09A7-460F-9257-5BDEF74FCD5B}");
PythonCoverageEditorModule();
~PythonCoverageEditorModule();

@ -37,7 +37,15 @@ namespace PythonCoverage
{
AzToolsFramework::EditorPythonScriptNotificationsBus::Handler::BusConnect();
AZ::EntitySystemBus::Handler::BusConnect();
// Attempt to discover the output directory for the test coverage files
ParseCoverageOutputDirectory();
if (m_coverageState == CoverageState::Disabled)
{
return;
}
EnumerateAllModuleComponents();
}
@ -49,16 +57,31 @@ namespace PythonCoverage
void PythonCoverageEditorSystemComponent::OnEntityActivated(const AZ::EntityId& entityId)
{
if (m_coverageState == CoverageState::Disabled)
{
return;
}
EnumerateComponentsForEntity(entityId);
WriteCoverageFile();
// There is currently no way to receive a graceful exit signal in order to properly handle the coverage end of life so
// instead we have to serialize the data on-the-fly with blocking disk writes on the main thread... if this adversely
// affects performance in a measurable way then this could potentially be put on a worker thread, although it remains to
// be seen whether the asynchronous nature of such a thread results in queued up coverage being lost due to the hard exit
if (m_coverageState == CoverageState::Gathering)
{
WriteCoverageFile();
}
}
void PythonCoverageEditorSystemComponent::ParseCoverageOutputDirectory()
{
m_coverageState = CoverageState::Disabled;
const AZStd::string configFilePath = LY_TEST_IMPACT_DEFAULT_CONFIG_FILE;
if (configFilePath.empty())
{
// Config file path will be empty if test impact analysis framework is disabled
AZ_Warning(Caller, false, "No test impact analysis framework config found.");
return;
}
@ -86,54 +109,50 @@ namespace PythonCoverage
return;
}
const AZ::IO::Path tempWorkspaceRootDir = configurationFile["workspace"]["temp"]["root"].GetString();
const AZ::IO::Path artifactRelativeDir = configurationFile["workspace"]["temp"]["relative_paths"]["artifact_dir"].GetString();
const auto& tempConfig = configurationFile["workspace"]["temp"];
const AZ::IO::Path tempWorkspaceRootDir = tempConfig["root"].GetString();
const AZ::IO::Path artifactRelativeDir = tempConfig["relative_paths"]["artifact_dir"].GetString();
m_coverageDir = tempWorkspaceRootDir / artifactRelativeDir;
m_coverageState = CoverageState::Idle;
}
void PythonCoverageEditorSystemComponent::WriteCoverageFile()
{
// Yes, we're doing blocking file operations on the main thread... If this becomes an issue this can be offloaded
// to a worker thread
if (m_coverageState == CoverageState::Gathering)
AZStd::string contents;
for (const auto& [testCase, entityComponents] : m_entityComponentMap)
{
AZStd::string contents;
for (const auto& [testCase, entityComponents] : m_entityComponentMap)
const auto coveringModules = GetParentComponentModulesForAllActivatedEntities(entityComponents);
if (coveringModules.empty())
{
const auto coveringModules = GetParentComponentModulesForAllActivatedEntities(entityComponents);
if (coveringModules.empty())
{
return;
}
contents = testCase + "\n";
for (const auto& coveringModule : coveringModules)
{
contents += AZStd::string::format(" %s\n", coveringModule.c_str());
}
}
AZ::IO::SystemFile file;
const AZStd::vector<char> bytes(contents.begin(), contents.end());
if (!file.Open(
m_coverageFile.c_str(),
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
{
AZ_Error(
Caller, false,
"Couldn't open file %s for writing", m_coverageFile.c_str());
return;
}
if (!file.Write(bytes.data(), bytes.size()))
contents = testCase + "\n";
for (const auto& coveringModule : coveringModules)
{
AZ_Error(
Caller, false,
"Couldn't write contents for file %s", m_coverageFile.c_str());
return;
contents += AZStd::string::format(" %s\n", coveringModule.c_str());
}
}
AZ::IO::SystemFile file;
const AZStd::vector<char> bytes(contents.begin(), contents.end());
if (!file.Open(
m_coverageFile.c_str(),
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
{
AZ_Error(
Caller, false,
"Couldn't open file %s for writing", m_coverageFile.c_str());
return;
}
if (!file.Write(bytes.data(), bytes.size()))
{
AZ_Error(
Caller, false,
"Couldn't write contents for file %s", m_coverageFile.c_str());
return;
}
}
void PythonCoverageEditorSystemComponent::EnumerateAllModuleComponents()
@ -142,10 +161,9 @@ namespace PythonCoverage
&AZ::ModuleManagerRequestBus::Events::EnumerateModules,
[this](const AZ::ModuleData& moduleData)
{
const AZStd::string moduleName = moduleData.GetDebugName();
// We can only enumerate shared libs, static libs are invisible to us
if (moduleData.GetDynamicModuleHandle())
{
const auto fileName = moduleData.GetDynamicModuleHandle()->GetFilename();
for (const auto* moduleComponentDescriptor : moduleData.GetModule()->GetComponentDescriptors())
{
m_moduleComponents[moduleComponentDescriptor->GetUuid()] = moduleData.GetDebugName();

@ -1,26 +0,0 @@
#include <PythonCoverageModule.h>
#pragma optimize("", off)
namespace PythonCoverage
{
PythonCoverageModule::PythonCoverageModule()
: AZ::Module()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(
m_descriptors.end(),
{ PythonCoverageSystemComponent::CreateDescriptor() });
}
AZ::ComponentTypeList PythonCoverageModule::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList{
azrtti_typeid<PythonCoverageSystemComponent>(),
};
}
}// namespace PythonCoverage
#if !defined(PYTHON_COVERAGE_EDITOR)
AZ_DECLARE_MODULE_CLASS(Gem_PythonCoverage, PythonCoverage::PythonCoverageModule)
#endif // !defined(PYTHON_COVERAGE_EDITOR)

@ -1,26 +0,0 @@
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
#include <PythonCoverageSystemComponent.h>
#pragma once
#pragma optimize("", off)
namespace PythonCoverage
{
class PythonCoverageModule : public AZ::Module
{
public:
AZ_RTTI(PythonCoverageModule, "{dc706de0-22c4-4b05-9b99-438692afc082}", AZ::Module);
AZ_CLASS_ALLOCATOR(PythonCoverageModule, AZ::SystemAllocator, 0);
PythonCoverageModule();
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
};
} // namespace PythonCoverage

@ -1,70 +0,0 @@
#include <PythonCoverageSystemComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>
namespace PythonCoverage
{
void PythonCoverageSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<PythonCoverageSystemComponent, AZ::Component>()
->Version(0)
;
if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<PythonCoverageSystemComponent>("PythonCoverage", "[Description of functionality provided by this System Component]")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void PythonCoverageSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("PythonCoverageService"));
}
void PythonCoverageSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("PythonCoverageService"));
}
void PythonCoverageSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
AZ_UNUSED(required);
}
void PythonCoverageSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
void PythonCoverageSystemComponent::Init()
{
}
void PythonCoverageSystemComponent::Activate()
{
PythonCoverageRequestBus::Handler::BusConnect();
AZ::TickBus::Handler::BusConnect();
}
void PythonCoverageSystemComponent::Deactivate()
{
AZ::TickBus::Handler::BusDisconnect();
PythonCoverageRequestBus::Handler::BusDisconnect();
}
void PythonCoverageSystemComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
{
}
} // namespace PythonCoverage

@ -1,44 +0,0 @@
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <PythonCoverage/PythonCoverageBus.h>
namespace PythonCoverage
{
class PythonCoverageSystemComponent
: public AZ::Component
, protected PythonCoverageRequestBus::Handler
, public AZ::TickBus::Handler
{
public:
AZ_COMPONENT(PythonCoverageSystemComponent, "{b2f692ae-1047-4a6d-a4ed-27b1aac40ba5}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
protected:
////////////////////////////////////////////////////////////////////////
// PythonCoverageRequestBus interface implementation
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZTickBus interface implementation
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
////////////////////////////////////////////////////////////////////////
};
} // namespace PythonCoverage

@ -1,24 +0,0 @@
#include <AzTest/AzTest.h>
class PythonCoverageTest
: public ::testing::Test
{
protected:
void SetUp() override
{
}
void TearDown() override
{
}
};
TEST_F(PythonCoverageTest, SanityTest)
{
ASSERT_TRUE(true);
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);

@ -1,3 +1,13 @@
#
# 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
Source/PythonCoverageEditorSystemComponent.cpp

@ -1,7 +1,15 @@
#
# 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
Source/PythonCoverageModule.cpp
Source/PythonCoverageModule.h
Source/PythonCoverageEditorModule.cpp
Source/PythonCoverageEditorModule.h
Source/PythonCoverageEditorModule.cpp
Source/PythonCoverageEditorModule.h
)

@ -1,3 +1,13 @@
#
# 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

@ -1,5 +0,0 @@
set(FILES
Source/PythonCoverageSystemComponent.cpp
Source/PythonCoverageSystemComponent.h
)

@ -1,5 +0,0 @@
set(FILES
Source/PythonCoverageModule.cpp
Source/PythonCoverageModule.h
)

@ -0,0 +1,46 @@
/*
* 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 <AzCore/EBus/EBus.h>
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<AZStd::string_view>& 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<AZStd::string_view>& args) {}
};
using EditorPythonRunnerNotificationBus = AZ::EBus<EditorPythonRunnerNotification>;
} // namespace AzToolsFramework

@ -18,6 +18,9 @@ option(LY_TEST_IMPACT_INSTRUMENTATION_BIN "Path to test impact framework instrum
# Name of test impact framework console static library target
set(LY_TEST_IMPACT_CONSOLE_STATIC_TARGET "TestImpact.Frontend.Console.Static")
# Name of test impact framework python coverage gem target
set(LY_TEST_IMPACT_PYTHON_COVERAGE_STATIC_TARGET "PythonCoverage.Editor.Static")
# Name of test impact framework console target
set(LY_TEST_IMPACT_CONSOLE_TARGET "TestImpact.Frontend.Console")
@ -395,6 +398,7 @@ function(ly_test_impact_write_config_file CONFIG_TEMPLATE_FILE PERSISTENT_DATA_D
# Set the above config file as the default config file to use for the test impact framework console target
target_compile_definitions(${LY_TEST_IMPACT_CONSOLE_STATIC_TARGET} PUBLIC "LY_TEST_IMPACT_DEFAULT_CONFIG_FILE=\"${PERSISTENT_DATA_DIR}/$<TARGET_FILE_BASE_NAME:${LY_TEST_IMPACT_CONSOLE_TARGET}>.$<CONFIG>.json\"")
target_compile_definitions(${LY_TEST_IMPACT_PYTHON_COVERAGE_STATIC_TARGET} PRIVATE "LY_TEST_IMPACT_DEFAULT_CONFIG_FILE=\"${PERSISTENT_DATA_DIR}/$<TARGET_FILE_BASE_NAME:${LY_TEST_IMPACT_CONSOLE_TARGET}>.$<CONFIG>.json\"")
message(DEBUG "Test impact framework post steps complete")
endfunction()

Loading…
Cancel
Save