@@ -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()
|
||||
+6
-8
@@ -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<AZStd::string_view>& args)
|
||||
void PythonCoverageEditorSystemComponent::OnStartExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, [[maybe_unused]] const AZStd::vector<AZStd::string_view>& args)
|
||||
{
|
||||
if (m_coverageState == CoverageState::Disabled)
|
||||
{
|
||||
|
||||
+1
-1
@@ -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<AZStd::string_view>& args) override;
|
||||
void OnStartExecuteByFilenameAsTest(AZStd::string_view filename, AZStd::string_view testCase, const AZStd::vector<AZStd::string_view>& 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
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
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);
|
||||
@@ -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
|
||||
)
|
||||
@@ -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"
|
||||
],
|
||||
|
||||
-46
@@ -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 <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
|
||||
|
||||
+8
-8
@@ -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<AZStd::string_view>& 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<AZStd::string_view>& args) {}
|
||||
};
|
||||
using EditorPythonScriptNotificationsBus = AZ::EBus<EditorPythonScriptNotifications>;
|
||||
|
||||
@@ -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<decltype(m_lock)> lock(m_lock);
|
||||
@@ -644,14 +644,14 @@ namespace EditorPythonBindings
|
||||
{
|
||||
AZStd::vector<AZStd::string_view> 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<AZStd::string_view>& 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<AZStd::string_view>& args)
|
||||
{
|
||||
AzToolsFramework::EditorPythonScriptNotificationsBus::Broadcast(
|
||||
&AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnExecuteByFilenameWithArgs, filename, args);
|
||||
&AzToolsFramework::EditorPythonScriptNotificationsBus::Events::OnStartExecuteByFilenameWithArgs, filename, args);
|
||||
EvaluateFile(filename, args);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user