diff options
Diffstat (limited to 'tests/auto/shared.h')
-rw-r--r-- | tests/auto/shared.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/shared.h b/tests/auto/shared.h index 2b9974110..e0920363f 100644 --- a/tests/auto/shared.h +++ b/tests/auto/shared.h @@ -31,6 +31,7 @@ #include <tools/hostosinfo.h> +#include <QFile> #include <QtTest> #if QT_VERSION >= 0x050000 @@ -48,4 +49,22 @@ inline void waitForNewTimestamp() QTest::qWait(1000); } +inline void touch(const QString &fn) +{ + QFile f(fn); + int s = f.size(); + if (!f.open(QFile::ReadWrite)) + qFatal("cannot open file %s", qPrintable(fn)); + f.resize(s+1); + f.resize(s); +} + +inline void copyFileAndUpdateTimestamp(const QString &source, const QString &target) +{ + QFile::remove(target); + if (!QFile::copy(source, target)) + qFatal("Failed to copy '%s' to '%s'", qPrintable(source), qPrintable(target)); + touch(target); +} + #endif // Include guard. |