General refactor of runtime classes.
parent
226ccce52d
commit
d732b7d0ce
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 <Process/JobRunner/TestImpactProcessJobMeta.h>
|
||||
|
||||
namespace TestImpact
|
||||
{
|
||||
JobMetaContainer::JobMetaContainer(const JobMeta& jobMeta)
|
||||
: m_meta(jobMeta)
|
||||
{
|
||||
}
|
||||
|
||||
JobMetaContainer::JobMetaContainer(JobMeta&& jobMeta)
|
||||
: m_meta(AZStd::move(jobMeta))
|
||||
{
|
||||
}
|
||||
|
||||
JobResult JobMetaContainer::GetJobResult() const
|
||||
{
|
||||
return m_meta.m_result;
|
||||
}
|
||||
|
||||
AZStd::optional<ReturnCode> JobMetaContainer::GetReturnCode() const
|
||||
{
|
||||
return m_meta.m_returnCode;
|
||||
}
|
||||
|
||||
AZStd::chrono::high_resolution_clock::time_point JobMetaContainer::GetStartTime() const
|
||||
{
|
||||
return m_meta.m_startTime.value_or(AZStd::chrono::high_resolution_clock::time_point());
|
||||
}
|
||||
|
||||
AZStd::chrono::high_resolution_clock::time_point JobMetaContainer::GetEndTime() const
|
||||
{
|
||||
if (m_meta.m_startTime.has_value() && m_meta.m_duration.has_value())
|
||||
{
|
||||
return m_meta.m_startTime.value() + m_meta.m_duration.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZStd::chrono::high_resolution_clock::time_point();
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::chrono::milliseconds JobMetaContainer::GetDuration() const
|
||||
{
|
||||
return m_meta.m_duration.value_or(AZStd::chrono::milliseconds{ 0 });
|
||||
}
|
||||
|
||||
} // namespace TestImpact
|
||||
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 <Process/TestImpactProcessInfo.h>
|
||||
|
||||
#include <AzCore/std/chrono/chrono.h>
|
||||
#include <AzCore/std/optional.h>
|
||||
|
||||
namespace TestImpact
|
||||
{
|
||||
//! Result of a job that was run.
|
||||
enum class JobResult
|
||||
{
|
||||
NotExecuted, //!< The job was not executed (e.g. the job runner terminated before the job could be executed).
|
||||
FailedToExecute, //!< The job failed to execute (e.g. due to the arguments used to execute the job being invalid).
|
||||
Timeout, //!< The job was terminated by the job runner (e.g. job timeout exceeded while job was in-flight).
|
||||
Terminated, //!< The job was terminated by the job runner (e.g. global timeout exceeded while job was in-flight).
|
||||
ExecutedWithFailure, //!< The job was executed but exited in an erroneous state (the underlying process returned non-zero).
|
||||
ExecutedWithSuccess //!< The job was executed and exited in a successful state (the underlying processes returned zero).
|
||||
};
|
||||
|
||||
//! The meta-data for a given job.
|
||||
struct JobMeta
|
||||
{
|
||||
JobResult m_result = JobResult::NotExecuted;
|
||||
AZStd::optional<AZStd::chrono::high_resolution_clock::time_point>
|
||||
m_startTime; //!< The time, relative to the job runner start, that this job started.
|
||||
AZStd::optional<AZStd::chrono::milliseconds> m_duration; //!< The duration that this job took to complete.
|
||||
AZStd::optional<ReturnCode> m_returnCode; //!< The return code of the underlying processes of this job.
|
||||
};
|
||||
|
||||
class JobMetaContainer
|
||||
{
|
||||
public:
|
||||
JobMetaContainer(const JobMeta& jobMeta);
|
||||
JobMetaContainer(JobMeta&& jobMeta);
|
||||
|
||||
//! Returns the result of this job.
|
||||
JobResult GetJobResult() const;
|
||||
|
||||
//! Returns the start time, relative to the job runner start, that this job started.
|
||||
AZStd::chrono::high_resolution_clock::time_point GetStartTime() const;
|
||||
|
||||
//! Returns the end time, relative to the job runner start, that this job ended.
|
||||
AZStd::chrono::high_resolution_clock::time_point GetEndTime() const;
|
||||
|
||||
//! Returns the duration that this job took to complete.
|
||||
AZStd::chrono::milliseconds GetDuration() const;
|
||||
|
||||
//! Returns the return code of the underlying processes of this job.
|
||||
AZStd::optional<ReturnCode> GetReturnCode() const;
|
||||
|
||||
private:
|
||||
JobMeta m_meta;
|
||||
};
|
||||
} // namespace TestImpact
|
||||
|
||||
Loading…
Reference in New Issue