From 0bd59178679ea1f573b484e5f2baf178352c44ef Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 30 Dec 2013 19:44:42 +0100 Subject: CppEditor/CppTools: Don't continue in test function on failure QVERIFY/QCOMPARE are meant to be called in the test function so that on failure they just can "return" and thus skip subsequent code. Since we use reusable test code in the test functions (the *TestCase classes), we need to ensure that on failure no further test code is executed. This mostly inlines the run function of the test classes into the constructor. Change-Id: I320ee032bdde0174ddfe3fdf3f9e18e19abf1d7f Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cpptoolstestcase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/plugins/cpptools/cpptoolstestcase.cpp') diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp index be9e61fb03..80de9dfc1d 100644 --- a/src/plugins/cpptools/cpptoolstestcase.cpp +++ b/src/plugins/cpptools/cpptoolstestcase.cpp @@ -70,10 +70,12 @@ bool TestDocument::writeToDisk() const TestCase::TestCase(bool runGarbageCollector) : m_modelManager(CppModelManagerInterface::instance()) + , m_succeededSoFar(false) , m_runGarbageCollector(runGarbageCollector) { if (m_runGarbageCollector) QVERIFY(garbageCollectGlobalSnapshot()); + m_succeededSoFar = true; } TestCase::~TestCase() @@ -85,6 +87,11 @@ TestCase::~TestCase() QVERIFY(garbageCollectGlobalSnapshot()); } +bool TestCase::succeededSoFar() const +{ + return m_succeededSoFar; +} + CPlusPlus::Snapshot TestCase::globalSnapshot() { return CppModelManagerInterface::instance()->snapshot(); -- cgit v1.2.1