1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28#ifndef TESTCOMPILER_H
29#define TESTCOMPILER_H
30
31#include <QObject>
32#include <QStringList>
33
34enum BuildType { Exe, Dll, Lib, Plain };
35
36class TestCompiler : public QObject
37{
38 Q_OBJECT
39
40public:
41 TestCompiler();
42 virtual ~TestCompiler();
43
44 void setBaseCommands( QString makeCmd, QString qmakeCmd );
45
46 void resetArguments();
47 void setArguments(const QStringList &makeArgs, const QStringList &qmakeArgs);
48
49 void resetEnvironment();
50 void addToEnvironment( QString varAssignment );
51
52 static QString targetName(BuildType buildMode, const QString& target, const QString& version);
53
54 // executes a make clean in the specified workPath
55 bool makeClean( const QString &workPath );
56 // executes a make dist clean in the specified workPath
57 bool makeDistClean( const QString &workPath );
58 // executes a qmake -project on the specified workDir
59 bool qmakeProject( const QString &workDir, const QString &proName );
60 // executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null
61 bool qmake(const QString &workDir, const QString &proName, const QString &buildDir = QString(),
62 const QStringList &additionalArguments = QStringList());
63 // executes qmake in workDir with the specified arguments
64 bool qmake(const QString &workDir, const QStringList &arguments);
65 // executes a make in the specified workPath, with an optional target (eg. install)
66 bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
67 // checks if the executable exists in destDir
68 bool exists(const QString &destDir, const QString &exeName, BuildType buildType,
69 const QString &version = QString());
70 // removes the makefile
71 bool removeMakefile( const QString &workPath );
72 // removes the project file specified by 'project' on the 'workPath'
73 bool removeProject( const QString &workPath, const QString &project );
74 // removes the file specified by 'fileName' on the 'workPath'
75 bool removeFile( const QString &workPath, const QString &fileName );
76
77 // Returns each line of stdout/stderr of the last commands
78 // separated by platform-specific line endings.
79 QString commandOutput() const;
80
81 // clear the results of storage of stdout for running previous commands
82 void clearCommandOutput();
83
84 bool runCommand(const QString &cmd, const QStringList &args, bool expectFail = false);
85
86private:
87 bool errorOut();
88
89 QString makeCmd_;
90 QStringList makeArgs_;
91 QString qmakeCmd_;
92 QStringList qmakeArgs_;
93 QStringList environment_;
94
95 QStringList testOutput_;
96};
97
98#endif // TESTCOMPILER_H
99

source code of qtbase/tests/auto/tools/qmake/testcompiler.h