diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-01-31 16:04:56 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-02-01 08:14:32 +0000 |
commit | 8b99628dc3bb125366f8b5c99ca57c78b96c1e54 (patch) | |
tree | 472378f185788ec83c2f83c2a9b2d6f874fb0d69 /tests/auto/blackbox/tst_blackboxqt.cpp | |
parent | bf18a35838e67fc790e5fd043dbd7a76518de28f (diff) |
Autotests: Add convenience function for changing file contents
We do that in a lot of test functions.
Change-Id: I8629e8bf936bc8f45d6a42b3bfc89a6a078cd023
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxqt.cpp')
-rw-r--r-- | tests/auto/blackbox/tst_blackboxqt.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index f2c263cfa..addde9a3f 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -286,24 +286,14 @@ void TestBlackboxQt::removeMocHeaderFromFileList() { QDir::setCurrent(testDataDir + "/remove-moc-header-from-file-list"); QCOMPARE(runQbs(), 0); + QString projectFile("remove-moc-header-from-file-list.qbs"); WAIT_FOR_NEW_TIMESTAMP(); - QFile projectFile("remove-moc-header-from-file-list.qbs"); - QVERIFY2(projectFile.open(QIODevice::ReadWrite), qPrintable(projectFile.errorString())); - QByteArray content = projectFile.readAll(); - content.replace("\"file.h\"", "// \"file.h\""); - projectFile.resize(0); - projectFile.write(content); - projectFile.close(); + REPLACE_IN_FILE(projectFile, "\"file.h\"", "// \"file.h\""); QbsRunParameters params; params.expectFailure = true; QVERIFY(runQbs(params) != 0); WAIT_FOR_NEW_TIMESTAMP(); - QVERIFY2(projectFile.open(QIODevice::ReadWrite), qPrintable(projectFile.errorString())); - content = projectFile.readAll(); - content.replace("// \"file.h\"", "\"file.h\""); - projectFile.resize(0); - projectFile.write(content); - projectFile.close(); + REPLACE_IN_FILE(projectFile, "// \"file.h\"", "\"file.h\""); QCOMPARE(runQbs(), 0); } |