diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-01-20 09:20:08 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2014-01-21 11:07:49 +0100 |
commit | f506104f2915793c3e94e2b533f0acba9a34958b (patch) | |
tree | dc9675a818cfe21b0818b34a68873108edc29987 /src/plugins/cpptools/cppheadersource_test.cpp | |
parent | 0f4e3c356a9931a984242c55daf0c8d703882f42 (diff) | |
download | qt-creator-f506104f2915793c3e94e2b533f0acba9a34958b.tar.gz |
CppTools: Cleanup header/source test
Dynamically create data files in tempPath and clean them up when
finished.
Change-Id: Ie78f557b185b264acc0d0f5814646c203d8a93f4
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppheadersource_test.cpp')
-rw-r--r-- | src/plugins/cpptools/cppheadersource_test.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/plugins/cpptools/cppheadersource_test.cpp b/src/plugins/cpptools/cppheadersource_test.cpp index bbc4efa24f..c047d0fe43 100644 --- a/src/plugins/cpptools/cppheadersource_test.cpp +++ b/src/plugins/cpptools/cppheadersource_test.cpp @@ -30,13 +30,26 @@ #include "cpptoolsplugin.h" #include "cpptoolsreuse.h" -#include <coreplugin/testdatadir.h> +#include <utils/fileutils.h> #include <QDir> #include <QtTest> static inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); } +static void createTempFile(const QString &fileName) +{ + QFile file(fileName); + QDir(QFileInfo(fileName).absolutePath()).mkpath(_(".")); + file.open(QFile::WriteOnly); + file.close(); +} + +static QString baseTestDir() +{ + return QDir::tempPath() + _("/qtc_cppheadersource/"); +} + namespace CppTools { namespace Internal { @@ -46,11 +59,13 @@ void CppToolsPlugin::test_headersource() QFETCH(QString, headerFileName); bool wasHeader; - Core::Tests::TestDataDir dataDir(_(SRCDIR "/../../../tests/cppheadersource/") - + _(QTest::currentDataTag())); + const QString baseDir = baseTestDir(); + QDir path = QDir(baseDir + _(QTest::currentDataTag())); - const QString sourcePath = dataDir.file(sourceFileName); - const QString headerPath = dataDir.file(headerFileName); + const QString sourcePath = path.absoluteFilePath(sourceFileName); + const QString headerPath = path.absoluteFilePath(headerFileName); + createTempFile(sourcePath); + createTempFile(headerPath); clearHeaderSourceCache(); QCOMPARE(correspondingHeaderOrSource(sourcePath, &wasHeader), headerPath); @@ -68,5 +83,15 @@ void CppToolsPlugin::test_headersource_data() QTest::newRow("includesub") << _("foo.cpp") << _("include/foo.h"); } +void CppToolsPlugin::initTestCase() +{ + QDir(baseTestDir()).mkpath(_(".")); +} + +void CppToolsPlugin::cleanupTestCase() +{ + Utils::FileUtils::removeRecursively(Utils::FileName::fromString(baseTestDir())); +} + } // namespace Internal } // namespace CppTools |