|
|
|
@ -10,17 +10,15 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <AzCore/IO/Path/Path.h>
|
|
|
|
|
|
|
|
#include <AzCore/JSON/document.h>
|
|
|
|
#include <AzCore/Module/ModuleManagerBus.h>
|
|
|
|
#include <AzCore/Module/ModuleManagerBus.h>
|
|
|
|
#include <AzCore/Module/Module.h>
|
|
|
|
#include <AzCore/Module/Module.h>
|
|
|
|
#include <AzCore/Module/DynamicModuleHandle.h>
|
|
|
|
#include <AzCore/Module/DynamicModuleHandle.h>
|
|
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
|
|
#include <AzCore/IO/Path/Path.h>
|
|
|
|
|
|
|
|
#include <AzCore/JSON/document.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <PythonCoverageEditorSystemComponent.h>
|
|
|
|
#include <PythonCoverageEditorSystemComponent.h>
|
|
|
|
|
|
|
|
|
|
|
|
#pragma optimize("", off)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace PythonCoverage
|
|
|
|
namespace PythonCoverage
|
|
|
|
{
|
|
|
|
{
|
|
|
|
constexpr char* const Caller = "PythonCoverageEditorSystemComponent";
|
|
|
|
constexpr char* const Caller = "PythonCoverageEditorSystemComponent";
|
|
|
|
@ -41,6 +39,7 @@ namespace PythonCoverage
|
|
|
|
// Attempt to discover the output directory for the test coverage files
|
|
|
|
// Attempt to discover the output directory for the test coverage files
|
|
|
|
ParseCoverageOutputDirectory();
|
|
|
|
ParseCoverageOutputDirectory();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If no output directory discovered, coverage gathering will be disabled
|
|
|
|
if (m_coverageState == CoverageState::Disabled)
|
|
|
|
if (m_coverageState == CoverageState::Disabled)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
@ -77,11 +76,12 @@ namespace PythonCoverage
|
|
|
|
void PythonCoverageEditorSystemComponent::ParseCoverageOutputDirectory()
|
|
|
|
void PythonCoverageEditorSystemComponent::ParseCoverageOutputDirectory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_coverageState = CoverageState::Disabled;
|
|
|
|
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;
|
|
|
|
const AZStd::string configFilePath = LY_TEST_IMPACT_DEFAULT_CONFIG_FILE;
|
|
|
|
|
|
|
|
|
|
|
|
if (configFilePath.empty())
|
|
|
|
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.");
|
|
|
|
AZ_Warning(Caller, false, "No test impact analysis framework config found.");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -89,7 +89,7 @@ namespace PythonCoverage
|
|
|
|
const auto fileSize = AZ::IO::SystemFile::Length(configFilePath.c_str());
|
|
|
|
const auto fileSize = AZ::IO::SystemFile::Length(configFilePath.c_str());
|
|
|
|
if(!fileSize)
|
|
|
|
if(!fileSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AZ_Error(Caller, false, "File %s does not exist", configFilePath.c_str());
|
|
|
|
AZ_Error(Caller, false, "File '%s' does not exist", configFilePath.c_str());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -97,7 +97,7 @@ namespace PythonCoverage
|
|
|
|
buffer[fileSize] = '\0';
|
|
|
|
buffer[fileSize] = '\0';
|
|
|
|
if (!AZ::IO::SystemFile::Read(configFilePath.c_str(), buffer.data()))
|
|
|
|
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 file '%s'", configFilePath.c_str());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,15 +110,23 @@ namespace PythonCoverage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto& tempConfig = configurationFile["workspace"]["temp"];
|
|
|
|
const auto& tempConfig = configurationFile["workspace"]["temp"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Temo directory root path is absolute
|
|
|
|
const AZ::IO::Path tempWorkspaceRootDir = tempConfig["root"].GetString();
|
|
|
|
const AZ::IO::Path tempWorkspaceRootDir = tempConfig["root"].GetString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Artifact directory is relative to temp directory root
|
|
|
|
const AZ::IO::Path artifactRelativeDir = tempConfig["relative_paths"]["artifact_dir"].GetString();
|
|
|
|
const AZ::IO::Path artifactRelativeDir = tempConfig["relative_paths"]["artifact_dir"].GetString();
|
|
|
|
m_coverageDir = tempWorkspaceRootDir / artifactRelativeDir;
|
|
|
|
m_coverageDir = tempWorkspaceRootDir / artifactRelativeDir;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Everything is good to go, await the first python test case
|
|
|
|
m_coverageState = CoverageState::Idle;
|
|
|
|
m_coverageState = CoverageState::Idle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PythonCoverageEditorSystemComponent::WriteCoverageFile()
|
|
|
|
void PythonCoverageEditorSystemComponent::WriteCoverageFile()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AZStd::string contents;
|
|
|
|
AZStd::string contents;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Compile the coverage for all test cases in this script
|
|
|
|
for (const auto& [testCase, entityComponents] : m_entityComponentMap)
|
|
|
|
for (const auto& [testCase, entityComponents] : m_entityComponentMap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const auto coveringModules = GetParentComponentModulesForAllActivatedEntities(entityComponents);
|
|
|
|
const auto coveringModules = GetParentComponentModulesForAllActivatedEntities(entityComponents);
|
|
|
|
@ -140,17 +148,13 @@ namespace PythonCoverage
|
|
|
|
m_coverageFile.c_str(),
|
|
|
|
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::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AZ_Error(
|
|
|
|
AZ_Error(Caller, false, "Couldn't open file '%s' for writing", m_coverageFile.c_str());
|
|
|
|
Caller, false,
|
|
|
|
|
|
|
|
"Couldn't open file %s for writing", m_coverageFile.c_str());
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!file.Write(bytes.data(), bytes.size()))
|
|
|
|
if (!file.Write(bytes.data(), bytes.size()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AZ_Error(
|
|
|
|
AZ_Error(Caller, false, "Couldn't write contents for file '%s'", m_coverageFile.c_str());
|
|
|
|
Caller, false,
|
|
|
|
|
|
|
|
"Couldn't write contents for file %s", m_coverageFile.c_str());
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|