aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/tst_blackbox.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-08-01 09:49:30 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-08-01 10:57:39 +0200
commit702068a6ab4a8e5cbd66d6e40b742d1f11c2361c (patch)
treeff93accb9c44aed841d4338ff0b1c7d8fa2d5ab6 /tests/auto/blackbox/tst_blackbox.cpp
parentb07742b80d3d1727d60df9b68b07bb79c4caabf1 (diff)
Autotests: Make "copy and touch" operation atomic.
On Windows, QFile::copy does not update the timestamp on the target file. This fixes the "projectInvalidation" API test on that OS. Change-Id: I01c232de0f4e5e9bc5d2d28c24d5fb5516a58ca3 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/blackbox/tst_blackbox.cpp')
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 4dd049c8e..b9cc46c45 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -151,16 +151,6 @@ void TestBlackbox::rmDirR(const QString &dir)
removeDirectoryWithContents(dir, &errorMessage);
}
-void TestBlackbox::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);
-}
-
QByteArray TestBlackbox::unifiedLineEndings(const QByteArray &ba)
{
if (HostOsInfo::isWindowsHost()) {
@@ -815,9 +805,7 @@ void TestBlackbox::track_qrc()
void TestBlackbox::track_qobject_change()
{
QDir::setCurrent(testDataDir + "/trackQObjChange");
- QFile("bla.h").remove();
- QVERIFY(QFile("bla_qobject.h").copy("bla.h"));
- touch("bla.h");
+ copyFileAndUpdateTimestamp("bla_qobject.h", "bla.h");
QCOMPARE(runQbs(), 0);
const QString productFilePath = executableFilePath("i");
QVERIFY2(regularFileExists(productFilePath), qPrintable(productFilePath));
@@ -826,9 +814,7 @@ void TestBlackbox::track_qobject_change()
QVERIFY2(regularFileExists(moc_bla_objectFileName), qPrintable(moc_bla_objectFileName));
QTest::qSleep(1000);
- QFile("bla.h").remove();
- QVERIFY(QFile("bla_noqobject.h").copy("bla.h"));
- touch("bla.h");
+ copyFileAndUpdateTimestamp("bla_noqobject.h", "bla.h");
QCOMPARE(runQbs(), 0);
QVERIFY(regularFileExists(productFilePath));
QVERIFY(!QFile(moc_bla_objectFileName).exists());
@@ -1135,9 +1121,7 @@ void TestBlackbox::trackRemoveProduct()
waitForNewTimestamp();
QFile::remove("zoo.cpp");
QFile::remove("product3.qbs");
- QFile::remove("trackProducts.qbs");
- QFile::copy("../before/trackProducts.qbs", "trackProducts.qbs");
- touch("trackProducts.qbs");
+ copyFileAndUpdateTimestamp("../before/trackProducts.qbs", "trackProducts.qbs");
QCOMPARE(runQbs(params), 0);
QVERIFY(!m_qbsStdout.contains("compiling foo.cpp"));
QVERIFY(!m_qbsStdout.contains("compiling bar.cpp"));
@@ -1580,9 +1564,7 @@ void TestBlackbox::dynamicRuleOutputs()
QDateTime appFileTimeStamp1 = QFileInfo(appFile).lastModified();
waitForNewTimestamp();
- QFile::remove("numbers.l");
- QFile::copy("../after/numbers.l", "numbers.l");
- touch("numbers.l");
+ copyFileAndUpdateTimestamp("../after/numbers.l", "numbers.l");
QCOMPARE(runQbs(), 0);
// Check build #2: no file names are specified in numbers.l
@@ -1594,9 +1576,7 @@ void TestBlackbox::dynamicRuleOutputs()
QVERIFY(regularFileExists(sourceFile2));
waitForNewTimestamp();
- QFile::remove("numbers.l");
- QFile::copy("../before/numbers.l", "numbers.l");
- touch("numbers.l");
+ copyFileAndUpdateTimestamp("../before/numbers.l", "numbers.l");
QCOMPARE(runQbs(), 0);
// Check build #3: source and header file name are specified in numbers.l