Commit 518cdc62 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

TestQMakeProject: use QTemporaryDir instead of /tmp

test_qmakeproject creates /tmp/some/path. After the test exits, this
directory still exists, contains an empty directory "build" and two
non-empty files (.qmake.stash and Makefile).

This change brings two improvements:
* the temporary directory path is no longer hardcoded;
* the temporary files and directories are removed at test exit.
parent 49c41c2b
......@@ -43,6 +43,9 @@ void TestQMakeProject::initTestCase()
AutoTestShell::init({ "KDevQMakeManager", "KDevQMakeBuilder", "KDevMakeBuilder", "KDevStandardOutputView" });
// Verify m_buildDir after initialization. Otherwise cleanupTestCase() crashes if the check fails.
QVERIFY2(m_buildDir.isValid(), qPrintable("couldn't create temporary directory: " + m_buildDir.errorString()));
void TestQMakeProject::cleanupTestCase()
......@@ -73,8 +76,6 @@ void TestQMakeProject::testBuildDirectory()
QFETCH(QString, target);
QFETCH(QString, expected);
const QString buildDir = QDir::rootPath() + QStringLiteral("tmp/some/path"); // some dummy directory to build (nothing will be built anyway)
foreach (IProject* p, ICore::self()->projectController()->projects()) {
......@@ -88,12 +89,12 @@ void TestQMakeProject::testBuildDirectory()
KConfig cfg(fileName);
KConfigGroup group(&cfg, QMakeConfig::CONFIG_GROUP);
group.writeEntry(QMakeConfig::BUILD_FOLDER, buildDir);
group.writeEntry(QMakeConfig::BUILD_FOLDER, m_buildDir.path());
/// create subgroup for one build dir
KConfigGroup buildDirGroup = KConfigGroup(&cfg, QMakeConfig::CONFIG_GROUP).group(buildDir);
KConfigGroup buildDirGroup = KConfigGroup(&cfg, QMakeConfig::CONFIG_GROUP).group(m_buildDir.path());
......@@ -113,7 +114,7 @@ void TestQMakeProject::testBuildDirectory()
IProject* project = ICore::self()->projectController()->findProjectByName(projectName);
// adds expected directory to our base path
Path expectedPath(Path(buildDir), expected);
const Path expectedPath(Path{m_buildDir.path()}, expected);
// path for files to build
Path buildUrl(QStringLiteral("%1/%2/%3").arg(QMAKE_TESTS_PROJECTS_DIR, projectName, target));
......@@ -8,6 +8,7 @@
#include <QObject>
#include <QTemporaryDir>
* Test project handling related features. Very basic at moment, should be completed.
......@@ -27,6 +28,9 @@ private Q_SLOTS:
void testBuildDirectory_data();
void testBuildDirectory();
const QTemporaryDir m_buildDir;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment