CMake Build: Use same Qt compiler defines for tests

Source code needed adjustments though.

Change-Id: I78b4610a6bb895a385c7c30a6c92c97a276b89dd
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Cristian Adam
2019-09-10 13:13:30 +02:00
parent 62d16e437a
commit 486aaabd21
15 changed files with 56 additions and 50 deletions
+13
View File
@@ -1,5 +1,18 @@
include(FeatureSummary)
#
# Default Qt compilation defines
#
list(APPEND DEFAULT_DEFINES
QT_CREATOR
QT_NO_JAVA_STYLE_ITERATORS
QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII
QT_DISABLE_DEPRECATED_BEFORE=0x050900
QT_USE_FAST_OPERATOR_PLUS
QT_USE_FAST_CONCATENATION
)
#
# Setup path handling
#
-10
View File
@@ -1,13 +1,3 @@
# Not in the main CMakeLists.txt file because some tests fail if we have the flags set as default
list(APPEND DEFAULT_DEFINES
QT_CREATOR
QT_NO_JAVA_STYLE_ITERATORS
QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII
QT_DISABLE_DEPRECATED_BEFORE=0x050900
QT_USE_FAST_OPERATOR_PLUS
QT_USE_FAST_CONCATENATION
)
add_library(app_version INTERFACE)
target_include_directories(app_version INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
install(TARGETS app_version EXPORT QtCreator)
+1 -1
View File
@@ -127,7 +127,7 @@ void tst_SimpleLexer::run(const QByteArray &source,
languageFeatures.flags |= extraLanguageFeatures.flags;
lexer.setLanguageFeatures(languageFeatures);
}
const Tokens tokens = lexer(source, preserveState ? _state : 0);
const Tokens tokens = lexer(QString::fromUtf8(source), preserveState ? _state : 0);
if (preserveState)
_state = lexer.state();
@@ -217,10 +217,8 @@ public:
dir = QFileInfo(currentFileName).dir();
const QFileInfo inc(dir, includedFileName);
if (inc.exists()) {
const QString resolved = inc.filePath();
return resolved.toUtf8().constData();
return inc.filePath();
} else {
// std::cerr<<"Cannot find " << inc.fileName().toUtf8().constData()<<std::endl;
return QString();
}
}
@@ -418,8 +416,8 @@ QByteArray tst_Preprocessor::simplified(const QByteArray &buf)
QList<QByteArray> lines = buf.split('\n');
foreach (const QByteArray &line, lines) {
if (!line.startsWith('#')) {
out.append(' ');
out.append(line);
out.append(" ");
out.append(QString::fromUtf8(line));
}
}
+18 -13
View File
@@ -281,7 +281,7 @@ static QString parentIName(const QString &iname)
struct Value
{
Value() : value(noValue) {}
Value(const char *str) : value(str) {}
Value(const char *str) : value(QString::fromUtf8(str)) {}
Value(const QString &str) : value(str) {}
bool matches(const QString &actualValue0, const Context &context) const
@@ -595,11 +595,11 @@ struct CheckType : public Check
{
CheckType(const QByteArray &iname, const Name &name,
const Type &type)
: Check(iname, name, noValue, type)
: Check(QString::fromUtf8(iname), name, noValue, type)
{}
CheckType(const QByteArray &iname, const Type &type)
: Check(iname, noValue, type)
: Check(QString::fromUtf8(iname), noValue, type)
{}
};
@@ -609,19 +609,23 @@ const QtVersion Qt5 = QtVersion(0x50000);
struct Check4 : Check
{
Check4(const QByteArray &iname, const Value &value, const Type &type)
: Check(iname, value, type) { qtVersionForCheck = Qt4; }
: Check(QString::fromUtf8(iname), value, type)
{ qtVersionForCheck = Qt4; }
Check4(const QByteArray &iname, const Name &name, const Value &value, const Type &type)
: Check(iname, name, value, type) { qtVersionForCheck = Qt4; }
: Check(QString::fromUtf8(iname), name, value, type)
{ qtVersionForCheck = Qt4; }
};
struct Check5 : Check
{
Check5(const QByteArray &iname, const Value &value, const Type &type)
: Check(iname, value, type) { qtVersionForCheck = Qt5; }
: Check(QString::fromUtf8(iname), value, type)
{ qtVersionForCheck = Qt5; }
Check5(const QByteArray &iname, const Name &name, const Value &value, const Type &type)
: Check(iname, name, value, type) { qtVersionForCheck = Qt5; }
: Check(QString::fromUtf8(iname), name, value, type)
{ qtVersionForCheck = Qt5; }
};
@@ -733,8 +737,8 @@ public:
const Data &operator+(const Profile &profile) const
{
profileExtra += profile.contents;
includes += profile.includes;
profileExtra += QString::fromUtf8(profile.contents);
includes += QString::fromUtf8(profile.includes);
return *this;
}
@@ -1613,7 +1617,7 @@ void tst_Dumpers::dumper()
contents = output.mid(posDataStart);
contents.replace("\\\"", "\"");
actual.fromStringMultiple(contents);
actual.fromStringMultiple(QString::fromLocal8Bit(contents));
context.nameSpace = actual["qtnamespace"].data();
actual = actual["data"];
//qDebug() << "FOUND NS: " << context.nameSpace;
@@ -1632,12 +1636,13 @@ void tst_Dumpers::dumper()
posNameSpaceStart += sizeof("@NS@") - 1;
int posNameSpaceEnd = output.indexOf("@", posNameSpaceStart);
QVERIFY(posNameSpaceEnd != -1);
context.nameSpace = output.mid(posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart);
context.nameSpace = QString::fromLocal8Bit(output.mid(
posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart));
//qDebug() << "FOUND NS: " << context.nameSpace;
if (context.nameSpace == "::")
context.nameSpace.clear();
contents.replace("\\\"", "\"");
actual.fromString(contents);
actual.fromString(QString::fromLocal8Bit(contents));
} else {
QByteArray localsAnswerStart("<qtcreatorcdbext>|R|42|");
QByteArray locals("|script|");
@@ -1653,7 +1658,7 @@ void tst_Dumpers::dumper()
if (localsBeginPos != -1)
localsBeginPos = output.indexOf(locals, localsBeginPos);
} while (localsBeginPos != -1);
actual.fromString(contents);
actual.fromString(QString::fromLocal8Bit(contents));
context.nameSpace = actual["result"]["qtnamespace"].data();
actual = actual["result"]["data"];
}
+2 -2
View File
@@ -1571,8 +1571,8 @@ void tst_Json::fromBinary()
void tst_Json::toAndFromBinary_data()
{
QTest::addColumn<QString>("filename");
QTest::newRow("test.json") << (testDataDir + QLatin1String("/test.json"));
QTest::newRow("test2.json") << (testDataDir + QLatin1String("/test2.json"));
QTest::newRow("test.json") << QString(testDataDir + QLatin1String("/test.json"));
QTest::newRow("test2.json") << QString(testDataDir + QLatin1String("/test2.json"));
}
void tst_Json::toAndFromBinary()
+1 -1
View File
@@ -114,7 +114,7 @@ void tst_Check::test()
Document::MutablePtr doc = Document::create(path, Dialect::Qml);
QFile file(doc->fileName());
file.open(QFile::ReadOnly | QFile::Text);
doc->setSource(file.readAll());
doc->setSource(QString::fromUtf8(file.readAll()));
file.close();
doc->parse();
snapshot.insert(doc);
@@ -74,7 +74,7 @@ struct TestData
static TestData testData(const QString &path) {
QFile file(path);
file.open(QFile::ReadOnly | QFile::Text);
const QString content = QString(file.readAll());
const QString content = QString::fromUtf8(file.readAll());
file.close();
Document::MutablePtr doc = Document::create(path, Dialect::Qml);
@@ -76,7 +76,7 @@ static TestData testData(const QString &path)
{
QFile file(path);
file.open(QFile::ReadOnly | QFile::Text);
const QString content = QString(file.readAll());
const QString content = QString::fromUtf8(file.readAll());
file.close();
Document::MutablePtr doc = Document::create(path, Dialect::Qml);
@@ -96,7 +96,7 @@ static QStringList readSkipList(const QDir &dir, const QString &filename)
return QStringList();
while (!f.atEnd()) {
const QString s = f.readLine().trimmed();
const QString s = QString::fromUtf8(f.readLine().trimmed());
if (!s.isEmpty())
result << dir.absoluteFilePath(s);
}
@@ -67,7 +67,7 @@ void tst_SimpleReader::testWellFormed()
SimpleReaderNode::WeakPtr weak02;
{
SimpleReader reader;
SimpleReaderNode::Ptr rootNode = reader.readFromSource(source);
SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source));
QVERIFY(reader.errors().isEmpty());
QVERIFY(rootNode);
QVERIFY(rootNode->isValid());
@@ -130,7 +130,7 @@ void tst_SimpleReader::testIllFormed01()
" propertyBlah: false\n"
"}\n";
SimpleReader reader;
SimpleReaderNode::Ptr rootNode = reader.readFromSource(source);
SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source));
QVERIFY(!rootNode);
QVERIFY(!reader.errors().empty());
@@ -153,7 +153,7 @@ void tst_SimpleReader::testIllFormed02()
"}\n";
SimpleReader reader;
SimpleReaderNode::Ptr rootNode = reader.readFromSource(source);
SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source));
QVERIFY(rootNode);
QVERIFY(rootNode->isValid());
@@ -188,7 +188,7 @@ void tst_SimpleReader::testArrays()
const QVariant variant = variantList;
SimpleReader reader;
SimpleReaderNode::Ptr rootNode = reader.readFromSource(source);
SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source));
QVERIFY(rootNode);
QVERIFY(rootNode->isValid());
@@ -239,7 +239,7 @@ void tst_SimpleReader::testBug01()
"}\n";
SimpleReader reader;
SimpleReaderNode::Ptr rootNode = reader.readFromSource(source);
SimpleReaderNode::Ptr rootNode = reader.readFromSource(QString::fromUtf8(source));
QVERIFY(rootNode);
QVERIFY(rootNode->isValid());
+6 -6
View File
@@ -89,10 +89,10 @@ static SshConnectionParameters getParameters()
} \
if (params.userName().isEmpty()) \
QSKIP(qPrintable(QString::fromLatin1("No user name provided. Set %1.") \
.arg(userVar()))); \
.arg(QString::fromUtf8(userVar())))); \
if (params.privateKeyFile.isEmpty()) \
QSKIP(qPrintable(QString::fromLatin1("No key file provided. Set %1.") \
.arg(keyFileVar()))); \
.arg(QString::fromUtf8(keyFileVar())))); \
} while (false)
class tst_Ssh : public QObject
@@ -234,9 +234,9 @@ void tst_Ssh::remoteProcess()
connect(&runner, &SshRemoteProcessRunner::readyReadStandardError,
[&remoteStderr, &runner] { remoteStderr += runner.readAllStandardError(); });
if (useTerminal)
runner.runInTerminal(commandLine, params);
runner.runInTerminal(QString::fromUtf8(commandLine), params);
else
runner.run(commandLine, params);
runner.run(QString::fromUtf8(commandLine), params);
QTimer timer;
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.setSingleShot(true);
@@ -254,7 +254,7 @@ void tst_Ssh::remoteProcess()
SshRemoteProcessRunner killer;
if (isBlocking)
killer.run("pkill -f -9 \"" + commandLine + '"', params);
killer.run("pkill -f -9 \"" + QString::fromUtf8(commandLine) + '"', params);
timer.start();
loop.exec();
@@ -285,7 +285,7 @@ void tst_Ssh::remoteProcessChannels()
QByteArray remoteStderr;
QByteArray remoteData;
SshRemoteProcessPtr echoProcess
= connection.createRemoteProcess("printf " + testString + " >&2");
= connection.createRemoteProcess("printf " + QString::fromUtf8(testString) + " >&2");
echoProcess->setReadChannel(QProcess::StandardError);
QEventLoop loop;
connect(echoProcess.get(), &SshRemoteProcess::done, &loop, &QEventLoop::quit);
@@ -194,7 +194,7 @@ void tst_StringUtils::testStripAccelerator()
{
QFETCH(QString, expected);
QCOMPARE(Utils::stripAccelerator(QTest::currentDataTag()), expected);
QCOMPARE(Utils::stripAccelerator(QString::fromUtf8(QTest::currentDataTag())), expected);
}
void tst_StringUtils::testStripAccelerator_data()
@@ -128,7 +128,7 @@ protected:
static std::time_t lastModified(Utils::SmallStringView filePath)
{
return QFileInfo(QString(filePath)).lastModified().toTime_t();
return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch();
}
ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const
@@ -146,7 +146,7 @@ protected:
static std::time_t lastModified(Utils::SmallStringView filePath)
{
return QFileInfo(QString(filePath)).lastModified().toTime_t();
return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch();
}
ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const
@@ -63,7 +63,7 @@ protected:
static std::time_t lastModified(Utils::SmallStringView filePath)
{
return QFileInfo(QString(filePath)).lastModified().toTime_t();
return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch();
}
ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const