File indexing completed on 2024-05-05 04:38:47

0001 /*
0002     SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_PROJECTTESTJOB_H
0008 #define KDEVPLATFORM_PROJECTTESTJOB_H
0009 
0010 #include <KJob>
0011 
0012 #include "utilexport.h"
0013 
0014 namespace KDevelop {
0015 
0016 class IProject;
0017 class ProjectTestJobPrivate;
0018 
0019 /**
0020  * A combined result of a project test job
0021  *
0022  * @sa ProjectTestJob
0023  *
0024  **/
0025 struct KDEVPLATFORMUTIL_EXPORT ProjectTestResult
0026 {
0027     ProjectTestResult()
0028     {}
0029     /**
0030      * The total number of test suites launched in this job
0031      **/
0032     int total = 0;
0033     /**
0034      * The number of passed test suites in this job.
0035      **/
0036     int passed = 0;
0037     /**
0038      * The number of failed test suites in this job.
0039      **/
0040     int failed = 0;
0041     /**
0042      * The number of errors in this job.
0043      **/
0044     int error = 0;
0045 };
0046 
0047 /**
0048  * @brief A job that tests an entire project and reports the total result
0049  *
0050  * Launches all test suites in the specified project without raising the output window.
0051  * Instead of providing individual test results, it combines and simplifies them.
0052  *
0053  **/
0054 class KDEVPLATFORMUTIL_EXPORT ProjectTestJob : public KJob
0055 {
0056     Q_OBJECT
0057 
0058 public:
0059     /**
0060      * Create a project test job
0061      *
0062      * @param project The project to be tested
0063      * @param parent This job's parent object, or 0 for no parent.
0064      *
0065      **/
0066     explicit ProjectTestJob(IProject* project, QObject* parent = nullptr);
0067 
0068     /**
0069      * Destructor
0070      *
0071      **/
0072     ~ProjectTestJob() override;
0073 
0074     /**
0075      * Start this job.
0076      **/
0077     void start() override;
0078 
0079     /**
0080      * @brief The result of this job
0081      *
0082      * This function only returns a correct result after all the tests are completed.
0083      * It is therefore best to call this after the KJob::result() signal is emitted.
0084      *
0085      * @sa ProjectTestResult
0086      **/
0087     ProjectTestResult testResult();
0088 
0089 protected:
0090     bool doKill() override;
0091 
0092 private:
0093     friend class ProjectTestJobPrivate;
0094     const QScopedPointer<class ProjectTestJobPrivate> d_ptr;
0095     Q_DECLARE_PRIVATE(ProjectTestJob)
0096 };
0097 
0098 }
0099 
0100 Q_DECLARE_TYPEINFO(KDevelop::ProjectTestResult, Q_MOVABLE_TYPE);
0101 
0102 #endif // KDEVPLATFORM_PROJECTTESTJOB_H