From 6cafc424e837aa64ecfad3828fb840d08b747452 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 9 Dec 2014 18:42:15 +0100 Subject: 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 Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cppcompletion_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plugins/cpptools/cppcompletion_test.cpp') diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index a5eef43fa5..c88a62293e 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -73,8 +73,10 @@ public: m_source[m_position] = ' '; // Write source to file - const QString fileName = QDir::tempPath() + QLatin1String("/file.h"); - QVERIFY(writeFile(fileName, m_source)); + m_temporaryDir.reset(new Tests::TemporaryDir()); + QVERIFY(m_temporaryDir->isValid()); + const QString fileName = m_temporaryDir->createFile("file.h", m_source); + QVERIFY(!fileName.isEmpty()); // Open in editor m_editor = EditorManager::openEditor(fileName); @@ -150,6 +152,7 @@ private: QByteArray m_source; int m_position; Snapshot m_snapshot; + QScopedPointer m_temporaryDir; TextEditorWidget *m_editorWidget; QTextDocument *m_textDocument; IEditor *m_editor; -- cgit v1.2.1