|
@@ -6,14 +6,17 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
+#include <PythonCoverageEditorSystemComponent.h>
|
|
|
+
|
|
|
#include <AzCore/IO/Path/Path.h>
|
|
|
#include <AzCore/JSON/document.h>
|
|
|
#include <AzCore/Module/ModuleManagerBus.h>
|
|
|
#include <AzCore/Module/Module.h>
|
|
|
#include <AzCore/Module/DynamicModuleHandle.h>
|
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
|
+#include <AzCore/std/string/regex.h>
|
|
|
|
|
|
-#include <PythonCoverageEditorSystemComponent.h>
|
|
|
+#pragma optimize("", off)
|
|
|
|
|
|
namespace PythonCoverage
|
|
|
{
|
|
@@ -109,11 +112,6 @@ namespace PythonCoverage
|
|
|
const AZ::IO::Path artifactRelativeDir = tempConfig["relative_paths"]["artifact_dir"].GetString();
|
|
|
m_coverageDir = tempWorkspaceRootDir / artifactRelativeDir;
|
|
|
|
|
|
- // Placeholder name to use for when the test case isn't specified
|
|
|
- const auto& pythonArtifactCoverageConfig = configurationFile["python"]["artifact"]["coverage"];
|
|
|
- m_placeholderTestCase = AZStd::string(pythonArtifactCoverageConfig["fixture_placeholder"].GetString()) + "." +
|
|
|
- AZStd::string(pythonArtifactCoverageConfig["test_case_placeholder"].GetString());
|
|
|
-
|
|
|
// Everything is good to go, await the first python test case
|
|
|
m_coverageState = CoverageState::Idle;
|
|
|
return m_coverageState;
|
|
@@ -130,7 +128,9 @@ namespace PythonCoverage
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- contents = testCase + "\n";
|
|
|
+ contents = m_parentScriptPath + "\n";
|
|
|
+ contents += m_testFixture + "\n";
|
|
|
+ contents = m_testCase + "\n";
|
|
|
contents += m_scriptPath + "\n";
|
|
|
for (const auto& coveringModule : coveringModules)
|
|
|
{
|
|
@@ -219,19 +219,38 @@ namespace PythonCoverage
|
|
|
WriteCoverageFile();
|
|
|
m_coverageState = CoverageState::Idle;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (testCase.empty())
|
|
|
{
|
|
|
// We need to be able to pinpoint the coverage data to the specific test case names otherwise we will not be able
|
|
|
// to specify which specific tests should be run in the future (filename does not necessarily equate to test case name)
|
|
|
- AZ_Warning(LogCallSite, false, "No test case specified, placeholder test case name will be used for this test");
|
|
|
- m_testCase = m_placeholderTestCase;
|
|
|
+ AZ_Error(LogCallSite, false, "No test case specified, coverage data gathering will be disabled for this test");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const auto matcherPattern = AZStd::regex("(.*)::(.*)::(.*)");
|
|
|
+ const auto strTestCase = AZStd::string(testCase);
|
|
|
+ AZStd::smatch testCaseMatches;
|
|
|
+ if (!AZStd::regex_search(strTestCase, testCaseMatches, matcherPattern))
|
|
|
+ {
|
|
|
+ AZ_Error(
|
|
|
+ LogCallSite,
|
|
|
+ false,
|
|
|
+ "The test case name '%s' did not comply to the format expected by the coverage gem "
|
|
|
+ "'parent_script_path::fixture_name::test_case_name', coverage data gathering will be disabled for this test",
|
|
|
+ strTestCase.c_str());
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ m_parentScriptPath = testCaseMatches[1];
|
|
|
+ m_testFixture = testCaseMatches[2];
|
|
|
+ m_testCase = testCaseMatches[3];
|
|
|
m_entityComponents.clear();
|
|
|
m_scriptPath = filename;
|
|
|
- const auto coverageFile = m_coverageDir / AZStd::string::format("%.*s.pycoverage", AZ_STRING_ARG(testCase));
|
|
|
+ const auto coverageFile = m_coverageDir / AZStd::string::format("%.*s.pycoverage", m_testCase);
|
|
|
m_coverageFile = coverageFile;
|
|
|
m_coverageState = CoverageState::Gathering;
|
|
|
}
|
|
|
} // namespace PythonCoverage
|
|
|
+
|
|
|
+#pragma optimize("", on)
|