forked from qt-creator/qt-creator
CppTools: Tests: Stop writing into source dir
Instead, always write into a unique temporary directory in QDir::tempPath(). Where applicable, read the test source from files instead of first writing the file. Some clean ups in test_codegen*. Change-Id: Id48dc50c6ca16252edfd9fc8a86ba0de9f9be486 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
cb3c7538be
commit
6cafc424e8
@@ -60,10 +60,13 @@ class CPPTOOLS_EXPORT TestDocument
|
||||
public:
|
||||
TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
|
||||
|
||||
void setBaseDirectory(const QString &baseDirectory) { m_baseDirectory = baseDirectory; }
|
||||
|
||||
QString filePath() const;
|
||||
bool writeToDisk() const;
|
||||
|
||||
public:
|
||||
QString m_baseDirectory;
|
||||
QString m_fileName;
|
||||
QString m_source;
|
||||
char m_cursorMarker;
|
||||
@@ -124,18 +127,31 @@ private:
|
||||
QList<ProjectExplorer::Project *> m_openProjects;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT TemporaryCopiedDir
|
||||
class TemporaryDir
|
||||
{
|
||||
Q_DISABLE_COPY(TemporaryDir)
|
||||
|
||||
public:
|
||||
TemporaryCopiedDir(const QString &sourceDirPath);
|
||||
TemporaryDir();
|
||||
|
||||
bool isValid() const { return m_isValid; }
|
||||
QString path() const { return m_temporaryDir.path(); }
|
||||
|
||||
QString createFile(const QByteArray &relativePath, const QByteArray &contents);
|
||||
|
||||
protected:
|
||||
QTemporaryDir m_temporaryDir;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT TemporaryCopiedDir : public TemporaryDir
|
||||
{
|
||||
public:
|
||||
TemporaryCopiedDir(const QString &sourceDirPath);
|
||||
QString absolutePath(const QByteArray &relativePath) const;
|
||||
|
||||
private:
|
||||
QTemporaryDir m_temporaryDir;
|
||||
bool m_isValid;
|
||||
TemporaryCopiedDir();
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT VerifyCleanCppModelManager
|
||||
|
||||
Reference in New Issue
Block a user