OSDN Git Service

build fix for the case when QT_NO_TEMPORARYFILE is defined
authorIvailo Monev <xakepa10@gmail.com>
Sat, 19 Nov 2022 22:34:47 +0000 (00:34 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 19 Nov 2022 22:34:47 +0000 (00:34 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/global/qconfig.h.cmake
tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
tests/auto/qfileinfo/tst_qfileinfo.cpp
tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
tests/benchmarks/core/io/qfile/main.cpp
tests/benchmarks/core/io/qtemporaryfile/main.cpp

index 360f490..f446594 100644 (file)
 // #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
 #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
index f7033bd..3566028 100644 (file)
@@ -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()
index a725822..45314e8 100644 (file)
@@ -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()
index cfcb326..fdd92f0 100644 (file)
@@ -19,7 +19,6 @@
 **
 ****************************************************************************/
 
-
 #include <QtTest/QtTest>
 #include <qcoreapplication.h>
 #include <qstring.h>
@@ -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
index 1607bd7..b5c00dc 100644 (file)
@@ -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
index c986ddd..e456a57 100644 (file)
@@ -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