TestImpactInstrumentedTestRunner.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #pragma once
  8. #include <TestEngine/JobRunner/TestImpactTestJobRunner.h>
  9. #include <TestEngine/Run/TestImpactTestCoverage.h>
  10. #include <TestEngine/Run/TestImpactTestRun.h>
  11. #include <TestEngine/Run/TestImpactTestRunJobData.h>
  12. namespace TestImpact
  13. {
  14. //! Per-job data for instrumented test runs.
  15. class InstrumentedTestRunJobData
  16. : public TestRunJobData
  17. {
  18. public:
  19. InstrumentedTestRunJobData(const RepoPath& resultsArtifact, const RepoPath& coverageArtifact);
  20. //! Returns the path to the coverage artifact produced by the test target.
  21. const RepoPath& GetCoverageArtifactPath() const;
  22. private:
  23. RepoPath m_coverageArtifact; //!< Path to coverage data.
  24. };
  25. //! Runs a batch of test targets to determine the test coverage and passes/failures.
  26. class InstrumentedTestRunner
  27. : public TestJobRunner<InstrumentedTestRunJobData, AZStd::pair<AZStd::optional<TestRun>, TestCoverage>>
  28. {
  29. using JobRunner = TestJobRunner<InstrumentedTestRunJobData, AZStd::pair<AZStd::optional<TestRun>, TestCoverage>>;
  30. public:
  31. //! Constructs an instrumented test runner with the specified parameters common to all job runs of this runner.
  32. //! @param maxConcurrentRuns The maximum number of runs to be in flight at any given time.
  33. explicit InstrumentedTestRunner(size_t maxConcurrentRuns);
  34. //! Executes the specified instrumented test run jobs according to the specified job exception policies.
  35. //! @param jobInfos The test run jobs to execute.
  36. //! @param jobExceptionPolicy The test run job exception policy to be used for this run (use
  37. //! TestJobExceptionPolicy::OnFailedToExecute to throw on test failures).
  38. //! @param runTimeout The maximum duration a run may be in-flight for before being forcefully terminated.
  39. //! @param runnerTimeout The maximum duration the runner may run before forcefully terminating all in-flight runs.
  40. //! @param clientCallback The optional client callback to be called whenever a run job changes state.
  41. //! @return The result of the run sequence and the instrumented run jobs with their associated test run and coverage payloads.
  42. AZStd::pair<ProcessSchedulerResult, AZStd::vector<Job>> RunInstrumentedTests(
  43. const AZStd::vector<JobInfo>& jobInfos,
  44. AZStd::optional<AZStd::chrono::milliseconds> runTimeout,
  45. AZStd::optional<AZStd::chrono::milliseconds> runnerTimeout,
  46. AZStd::optional<ClientJobCallback> clientCallback);
  47. };
  48. } // namespace TestImpact