Commit d97110a1 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

VCS tests: global QString constants => data members

Initialize m_plugin with nullptr.

Simplify the expression assigned to perforceTestBaseDir.

The temporary directories are created before and removed after each test
function. This makes switching to QTemporaryDir more difficult and less
useful => retain QDir::tempPath() for the time being.
parent 9b819006
Pipeline #97338 passed with stage
in 35 minutes and 28 seconds
......@@ -31,16 +31,19 @@
#define VERIFYJOB(j) \
do { QVERIFY(j); QVERIFY(j->exec()); QVERIFY((j)->status() == KDevelop::VcsJob::JobSucceeded); } while(0)
const QString tempDir = QDir::tempPath();
const QString bazaarTest_BaseDir(tempDir + "/kdevBazaar_testdir/");
const QString bazaarRepo(bazaarTest_BaseDir + ".bzr");
const QString bazaarSrcDir(bazaarTest_BaseDir + "src/");
const QString bazaarTest_FileName(QStringLiteral("testfile"));
const QString bazaarTest_FileName2(QStringLiteral("foo"));
const QString bazaarTest_FileName3(QStringLiteral("bar"));
using namespace KDevelop;
TestBazaar::TestBazaar()
: tempDir{QDir::tempPath()}
, bazaarTest_BaseDir{tempDir + QLatin1String("/kdevBazaar_testdir/")}
, bazaarRepo{bazaarTest_BaseDir + QLatin1String(".bzr")}
, bazaarSrcDir{bazaarTest_BaseDir + QLatin1String("src/")}
, bazaarTest_FileName{QStringLiteral("testfile")}
, bazaarTest_FileName2{QStringLiteral("foo")}
, bazaarTest_FileName3{QStringLiteral("bar")}
{
}
void TestBazaar::initTestCase()
{
AutoTestShell::init({QStringLiteral("kdevbazaar")});
......
......@@ -15,6 +15,7 @@
#define KDEVPLATFORM_PLUGIN_TEST_BAZAAR_H
#include <QObject>
#include <QString>
class BazaarPlugin;
......@@ -26,6 +27,8 @@ namespace KDevelop
class TestBazaar: public QObject
{
Q_OBJECT
public:
TestBazaar();
private:
void repoInit();
......@@ -49,8 +52,17 @@ private Q_SLOTS:
void testRemoveFolderContainingUnversionedFiles();
private:
BazaarPlugin* m_plugin;
void removeTempDirs();
BazaarPlugin* m_plugin = nullptr;
const QString tempDir;
const QString bazaarTest_BaseDir;
const QString bazaarRepo;
const QString bazaarSrcDir;
const QString bazaarTest_FileName;
const QString bazaarTest_FileName2;
const QString bazaarTest_FileName3;
};
#endif // KDEVPLATFORM_PLUGIN_TEST_BAZAAR_H
......@@ -11,6 +11,7 @@
#include "test_perforce.h"
#include <QTest>
#include <QDir>
#include <QDirIterator>
#include <QStandardPaths>
......@@ -25,18 +26,20 @@
#define VERIFYJOB(j) \
QVERIFY(j); QVERIFY(j->exec()); QVERIFY((j)->status() == VcsJob::JobSucceeded)
const QString tempDir = QDir::tempPath();
const QString perforceTestBaseDirNoSlash(tempDir + "/kdevPerforce_testdir");
const QString perforceTestBaseDir(tempDir + "/kdevPerforce_testdir/");
const QString perforceConfigFileName(QStringLiteral("p4config.txt"));
const QString perforceSrcDir(perforceTestBaseDir + "src/");
const QString perforceTest_FileName(QStringLiteral("testfile"));
const QString perforceTest_FileName2(QStringLiteral("foo"));
const QString perforceTest_FileName3(QStringLiteral("bar"));
using namespace KDevelop;
PerforcePluginTest::PerforcePluginTest()
: tempDir{QDir::tempPath()}
, perforceTestBaseDirNoSlash{tempDir + QLatin1String("/kdevPerforce_testdir")}
, perforceTestBaseDir{perforceTestBaseDirNoSlash + QLatin1Char('/')}
, perforceConfigFileName{QStringLiteral("p4config.txt")}
, perforceSrcDir{perforceTestBaseDir + QLatin1String("src/")}
, perforceTest_FileName{QStringLiteral("testfile")}
, perforceTest_FileName2{QStringLiteral("foo")}
, perforceTest_FileName3{QStringLiteral("bar")}
{
}
void PerforcePluginTest::initTestCase()
{
AutoTestShell::init({QStringLiteral("kdevperforce")});
......
......@@ -12,12 +12,16 @@
#define PERFORCEPLUGIN_TEST_H
#include <QObject>
#include <QString>
class PerforcePlugin;
class PerforcePluginTest : public QObject
{
Q_OBJECT
public:
PerforcePluginTest();
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
......@@ -36,9 +40,20 @@ private Q_SLOTS:
void testCommit();
void testDiff();
private:
PerforcePlugin* m_plugin;
void removeTempDirsIfAny();
void createNewTempDirs();
PerforcePlugin* m_plugin = nullptr;
const QString tempDir;
const QString perforceTestBaseDirNoSlash;
const QString perforceTestBaseDir;
const QString perforceConfigFileName;
const QString perforceSrcDir;
const QString perforceTest_FileName;
const QString perforceTest_FileName2;
const QString perforceTest_FileName3;
};
#endif
Markdown is supported
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