add qmake evaluator test
Change-Id: I31b95daede5edef245dd1ba447f2937a0db34232 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
ef50e244cd
commit
5ddc16b5df
@ -135,6 +135,7 @@ public:
|
||||
bool initProperties();
|
||||
# else
|
||||
void setProperties(const QHash<QString, QString> &props);
|
||||
void setProperties(const QHash<ProKey, ProString> &props) { properties = props; }
|
||||
# endif
|
||||
ProString propertyValue(const ProKey &name) const { return properties.value(name); }
|
||||
#endif
|
||||
|
2513
tests/auto/tools/qmakelib/evaltest.cpp
Normal file
2513
tests/auto/tools/qmakelib/evaltest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1956,7 +1956,7 @@ void tst_qmakelib::proParser()
|
||||
QFETCH(bool, ok);
|
||||
|
||||
bool verified = true;
|
||||
QMakeHandler handler;
|
||||
QMakeTestHandler handler;
|
||||
handler.setExpectedMessages(msgs.split('\n', QString::SkipEmptyParts));
|
||||
QMakeVfs vfs;
|
||||
QMakeParser parser(0, &vfs, &handler);
|
||||
|
@ -12,9 +12,13 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
tst_qmakelib.cpp \
|
||||
parsertest.cpp \
|
||||
evaltest.cpp \
|
||||
ioutils.cpp \
|
||||
proitems.cpp \
|
||||
qmakevfs.cpp \
|
||||
qmakeparser.cpp
|
||||
qmakeparser.cpp \
|
||||
qmakeglobals.cpp \
|
||||
qmakebuiltins.cpp \
|
||||
qmakeevaluator.cpp
|
||||
|
||||
DEFINES += PROPARSER_DEBUG
|
||||
DEFINES += PROPARSER_DEBUG PROEVALUATOR_FULL PROEVALUATOR_SETENV
|
||||
|
2
tests/auto/tools/qmakelib/testdata/cat/file1.txt
vendored
Normal file
2
tests/auto/tools/qmakelib/testdata/cat/file1.txt
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"Hello, world."
|
||||
foo bar baz
|
5
tests/auto/tools/qmakelib/testdata/cat/file2.txt
vendored
Normal file
5
tests/auto/tools/qmakelib/testdata/cat/file2.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
foo bar baz
|
||||
"Hello, ' world." post
|
||||
'Hello, " world.' post
|
||||
\" \' \\ \a \ nix
|
||||
" "
|
0
tests/auto/tools/qmakelib/testdata/files/dir/file1.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/dir/file1.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/dir/file2.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/dir/file2.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/file1.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/file1.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/file2.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/file2.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/other.txt
vendored
Normal file
0
tests/auto/tools/qmakelib/testdata/files/other.txt
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx
vendored
Normal file
@ -0,0 +1 @@
|
||||
error("fail!")
|
1
tests/auto/tools/qmakelib/testdata/fromfile/infile.prx
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/fromfile/infile.prx
vendored
Normal file
@ -0,0 +1 @@
|
||||
DEFINES = QT_DLL
|
8
tests/auto/tools/qmakelib/testdata/include/inc.pri
vendored
Normal file
8
tests/auto/tools/qmakelib/testdata/include/inc.pri
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
VAR = val
|
||||
.VAR = nope
|
||||
|
||||
fake-*: MATCH = 1
|
||||
|
||||
defineTest(func) {
|
||||
message("say hi!")
|
||||
}
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Nothing here
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Nothing here
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Nothing here
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Nothing here
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf
vendored
Normal file
@ -0,0 +1 @@
|
||||
# Nothing here
|
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf
vendored
Normal file
1
tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf
vendored
Normal file
@ -0,0 +1 @@
|
||||
VAR = foo bar
|
@ -37,6 +37,27 @@
|
||||
|
||||
using namespace QMakeInternal;
|
||||
|
||||
void tst_qmakelib::initTestCase()
|
||||
{
|
||||
m_indir = QFINDTESTDATA("testdata");
|
||||
m_outdir = m_indir + QLatin1String("_build");
|
||||
m_env.insert(QStringLiteral("E1"), QStringLiteral("env var"));
|
||||
#ifdef Q_OS_WIN
|
||||
m_env.insert(QStringLiteral("COMSPEC"), qgetenv("COMSPEC"));
|
||||
#endif
|
||||
m_prop.insert(ProKey("P1"), ProString("prop val"));
|
||||
m_prop.insert(ProKey("QT_HOST_DATA/get"), ProString(m_indir));
|
||||
|
||||
QVERIFY(!m_indir.isEmpty());
|
||||
QVERIFY(QDir(m_outdir).removeRecursively());
|
||||
QVERIFY(QDir().mkpath(m_outdir));
|
||||
}
|
||||
|
||||
void tst_qmakelib::cleanupTestCase()
|
||||
{
|
||||
QVERIFY(QDir(m_outdir).removeRecursively());
|
||||
}
|
||||
|
||||
void tst_qmakelib::proString()
|
||||
{
|
||||
QString qs1(QStringLiteral("this is a string"));
|
||||
@ -225,21 +246,24 @@ void tst_qmakelib::pathUtils()
|
||||
QCOMPARE(IoUtils::resolvePath(fnbase, fn1), QStringLiteral("/a/unix/file/path"));
|
||||
}
|
||||
|
||||
void QMakeHandler::print(const QString &fileName, int lineNo, int type, const QString &msg)
|
||||
void QMakeTestHandler::print(const QString &fileName, int lineNo, int type, const QString &msg)
|
||||
{
|
||||
QString pfx = ((type & QMakeParserHandler::CategoryMask) == QMakeParserHandler::WarningMessage)
|
||||
? QString::fromLatin1("WARNING: ") : QString();
|
||||
QString out;
|
||||
if (lineNo)
|
||||
out = QStringLiteral("%1%2:%3: %4").arg(pfx, fileName, QString::number(lineNo), msg);
|
||||
doPrint(QStringLiteral("%1%2:%3: %4").arg(pfx, fileName, QString::number(lineNo), msg));
|
||||
else
|
||||
out = QStringLiteral("%1%2").arg(pfx, msg);
|
||||
if (!expected.isEmpty() && expected.first() == out) {
|
||||
doPrint(QStringLiteral("%1%2").arg(pfx, msg));
|
||||
}
|
||||
|
||||
void QMakeTestHandler::doPrint(const QString &msg)
|
||||
{
|
||||
if (!expected.isEmpty() && expected.first() == msg) {
|
||||
expected.removeAt(0);
|
||||
return;
|
||||
} else {
|
||||
qWarning("%s", qPrintable(msg));
|
||||
printed = true;
|
||||
}
|
||||
qWarning("%s", qPrintable(out));
|
||||
printed = true;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qmakelib)
|
||||
|
@ -31,9 +31,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmakeparser.h>
|
||||
#include <qmakeevaluator.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class tst_qmakelib : public QObject
|
||||
@ -45,6 +46,9 @@ public:
|
||||
virtual ~tst_qmakelib() {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void quoteArgUnix_data();
|
||||
void quoteArgUnix();
|
||||
void quoteArgWin_data();
|
||||
@ -57,6 +61,9 @@ private slots:
|
||||
void proParser_data();
|
||||
void proParser();
|
||||
|
||||
void proEval_data();
|
||||
void proEval();
|
||||
|
||||
private:
|
||||
void addParseOperators();
|
||||
void addParseValues();
|
||||
@ -65,14 +72,30 @@ private:
|
||||
void addParseBraces();
|
||||
void addParseCustomFunctions();
|
||||
void addParseAbuse();
|
||||
|
||||
void addAssignments();
|
||||
void addExpansions();
|
||||
void addControlStructs();
|
||||
void addReplaceFunctions(const QString &qindir);
|
||||
void addTestFunctions(const QString &qindir);
|
||||
|
||||
QProcessEnvironment m_env;
|
||||
QHash<ProKey, ProString> m_prop;
|
||||
QString m_indir, m_outdir;
|
||||
};
|
||||
|
||||
class QMakeHandler : public QMakeParserHandler {
|
||||
class QMakeTestHandler : public QMakeHandler {
|
||||
public:
|
||||
QMakeHandler() : QMakeParserHandler(), printed(false) {}
|
||||
QMakeTestHandler() : QMakeHandler(), printed(false) {}
|
||||
virtual void message(int type, const QString &msg, const QString &fileName, int lineNo)
|
||||
{ print(fileName, lineNo, type, msg); }
|
||||
|
||||
virtual void fileMessage(const QString &msg)
|
||||
{ doPrint(msg); }
|
||||
|
||||
virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
|
||||
virtual void doneWithEval(ProFile *) {}
|
||||
|
||||
void setExpectedMessages(const QStringList &msgs) { expected = msgs; }
|
||||
QStringList expectedMessages() const { return expected; }
|
||||
|
||||
@ -80,7 +103,9 @@ public:
|
||||
|
||||
private:
|
||||
void print(const QString &fileName, int lineNo, int type, const QString &msg);
|
||||
void doPrint(const QString &msg);
|
||||
|
||||
QStringList expected;
|
||||
bool printed;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user