From 4e1d48fa13a537aa303d5a99bc639a314c614d71 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 20 Nov 2022 00:34:47 +0200 Subject: [PATCH] build fix for the case when QT_NO_TEMPORARYFILE is defined Signed-off-by: Ivailo Monev --- src/core/global/qconfig.h.cmake | 2 +- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 11 +++++++++++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 8 ++++++++ tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 9 ++++++++- tests/benchmarks/core/io/qfile/main.cpp | 12 ++++++++++-- tests/benchmarks/core/io/qtemporaryfile/main.cpp | 8 ++++++++ 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index 360f490e0..f4465944f 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -139,7 +139,6 @@ // #cmakedefine QT_NO_TABWIDGET // #cmakedefine QT_NO_TABLEVIEW // #cmakedefine QT_NO_TABLEWIDGET -// #cmakedefine QT_NO_TEMPORARYFILE // #cmakedefine QT_NO_TEXTCONTROL // #cmakedefine QT_NO_TEXTEDIT // #cmakedefine QT_NO_TEXTHTMLPARSER @@ -205,6 +204,7 @@ #cmakedefine QT_NO_STYLE_WINDOWS #cmakedefine QT_NO_SYNTAXHIGHLIGHTER #cmakedefine QT_NO_SYSTEMTRAYICON +#cmakedefine QT_NO_TEMPORARYFILE #cmakedefine QT_NO_TEXTBROWSER #cmakedefine QT_NO_UDPSOCKET #cmakedefine QT_NO_UNDOGROUP diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index f7033bdeb..3566028fc 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -97,7 +97,11 @@ private: int fileDescriptorForTest(); QProcess proc; +#ifndef QT_NO_TEMPORARYFILE QTemporaryFile tempFile; +#else + QFile file; +#endif bool fileDescriptorPassing; }; @@ -150,11 +154,18 @@ void tst_QDBusMarshall::cleanupTestCase() int tst_QDBusMarshall::fileDescriptorForTest() { +#ifndef QT_NO_TEMPORARYFILE if (!tempFile.isOpen()) { tempFile.setFileTemplate(QDir::tempPath() + "/qdbusmarshalltestXXXXXX.tmp"); tempFile.open(); } return tempFile.handle(); +#else + if (!file.isOpen()) { + file.open(STDERR_FILENO, QFile::ReadOnly); + } + return file.handle(); +#endif } void addBasicTypesColumns() diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index a7258227e..45314e8a8 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -177,6 +177,7 @@ static QFileInfoPrivate* getPrivate(QFileInfo &info) void tst_QFileInfo::copy() { +#ifndef QT_NO_TEMPORARYFILE QTemporaryFile t; t.open(); QFileInfo info(t.fileName()); @@ -206,6 +207,9 @@ void tst_QFileInfo::copy() QVERIFY(privateInfo != privateInfo3); QVERIFY(privateInfo2 != privateInfo3); QCOMPARE(privateInfo, privateInfo2); +#else // QT_NO_TEMPORARYFILE + QSKIP("Katie compiled without temporary file support (QT_NO_TEMPORARYFILE)", SkipAll); +#endif // QT_NO_TEMPORARYFILE } void tst_QFileInfo::isFile_data() @@ -368,11 +372,15 @@ void tst_QFileInfo::absFilePath() void tst_QFileInfo::canonicalPath() { +#ifndef QT_NO_TEMPORARYFILE QTemporaryFile tempFile; tempFile.setAutoRemove(true); tempFile.open(); QFileInfo fi(tempFile.fileName()); QCOMPARE(fi.canonicalPath(), QFileInfo(QDir::tempPath()).canonicalFilePath()); +#else // QT_NO_TEMPORARYFILE + QSKIP("Katie compiled without temporary file support (QT_NO_TEMPORARYFILE)", SkipAll); +#endif // QT_NO_TEMPORARYFILE } void tst_QFileInfo::canonicalFilePath() diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index cfcb3260d..fdd92f089 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -19,7 +19,6 @@ ** ****************************************************************************/ - #include #include #include @@ -38,6 +37,8 @@ //TESTED_CLASS= //TESTED_FILES= +#ifndef QT_NO_TEMPORARYFILE + class tst_QTemporaryFile : public QObject { Q_OBJECT @@ -587,3 +588,9 @@ void tst_QTemporaryFile::fileTemplate() QTEST_MAIN(tst_QTemporaryFile) #include "moc_tst_qtemporaryfile.cpp" + +#else // QT_NO_TEMPORARYFILE + +QTEST_NOOP_MAIN + +#endif // QT_NO_TEMPORARYFILE diff --git a/tests/benchmarks/core/io/qfile/main.cpp b/tests/benchmarks/core/io/qfile/main.cpp index 1607bd74d..b5c00dcd3 100644 --- a/tests/benchmarks/core/io/qfile/main.cpp +++ b/tests/benchmarks/core/io/qfile/main.cpp @@ -32,6 +32,8 @@ QT_USE_NAMESPACE #define QFILE_BENCH_FACTOR 1024*512 #define QFILE_BENCH_TF_SIZE QFILE_BENCH_FACTOR*81 +#ifndef QT_NO_TEMPORARYFILE + // 10 predefined (but random() seek positions // hardcoded to be comparable over several runs const int seekpos[] = {int(QFILE_BENCH_TF_SIZE*0.52), @@ -49,8 +51,8 @@ const int sp_size = sizeof(seekpos)/sizeof(int); class tst_qfile: public QObject { -Q_ENUMS(BenchmarkType) -Q_OBJECT + Q_ENUMS(BenchmarkType) + Q_OBJECT public: enum BenchmarkType { QFileBenchmark = 1, @@ -539,3 +541,9 @@ void tst_qfile::writeFileSequentialWithSeeks() QTEST_MAIN(tst_qfile) #include "moc_main.cpp" + +#else // QT_NO_TEMPORARYFILE + +QTEST_NOOP_MAIN + +#endif // QT_NO_TEMPORARYFILE diff --git a/tests/benchmarks/core/io/qtemporaryfile/main.cpp b/tests/benchmarks/core/io/qtemporaryfile/main.cpp index c986dddae..e456a5757 100644 --- a/tests/benchmarks/core/io/qtemporaryfile/main.cpp +++ b/tests/benchmarks/core/io/qtemporaryfile/main.cpp @@ -27,6 +27,8 @@ QT_USE_NAMESPACE +#ifndef QT_NO_TEMPORARYFILE + class tst_qtemporaryfile : public QObject { Q_OBJECT @@ -82,3 +84,9 @@ void tst_qtemporaryfile::readwrite() QTEST_MAIN(tst_qtemporaryfile) #include "moc_main.cpp" + +#else // QT_NO_TEMPORARYFILE + +QTEST_NOOP_MAIN + +#endif // QT_NO_TEMPORARYFILE -- 2.11.0