AutoTest: Fix handling of cpp files for Quick tests

Modifying C++ files of Quick tests had been ignored as they
normally have little impact.
But nevertheless this behavior is wrong and could lead to
unexpected behavior later on if no complete rescan had been
done and even with a rescan there could have been some
cached artifacts.
Fix this by tracking the paths of the C++ files that hold
the main() or the respective macro to be able to handle
changes of these files correctly as well.

Task-number: QTCREATORBUG-20746
Change-Id: Iec860aa63ffd167511efdbf63a6ffa369f094edf
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-07-10 14:47:40 +02:00
parent f18d2ded9b
commit f80aa2c6f7
4 changed files with 43 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
#include "quicktesttreeitem.h"
#include "quicktestconfiguration.h"
#include "quicktestframework.h"
#include "quicktestparser.h"
#include "../testframeworkmanager.h"
@@ -426,6 +427,23 @@ QSet<QString> QuickTestTreeItem::internalTargets() const
return result;
}
void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath)
{
static const Core::Id id = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(
QuickTest::Constants::FRAMEWORK_NAME);
TestTreeItem::markForRemovalRecursively(filePath);
auto parser = dynamic_cast<QuickTestParser *>(TestFrameworkManager::instance()
->testParserForTestFramework(id));
const QString proFile = parser->projectFileForMainCppFile(filePath);
if (!proFile.isEmpty()) {
TestTreeItem *root = TestFrameworkManager::instance()->rootNodeForTestFramework(id);
root->forAllChildren([proFile](TestTreeItem *it) {
if (it->proFile() == proFile)
it->markForRemoval(true);
});
}
}
TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const
{
if (type() != Root)