Plugin tests: Allow to specify which test functions to run

This simplifies debugging single test functions.

Test data can be specified the same way as for QTest executables.

New syntax for the -test option:
    -test <plugin> [testfunction[:testdata]]...

Examples:
    ./qtcreator -test Git testDiffFileResolving
    ./qtcreator -test Git testDiffFileResolving testStatusParsing:"DU"

Change-Id: Ifea6b114bfc0fabe3e9ddffcc2fd90af157052ec
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-01-22 12:54:22 +01:00
parent 120f03061d
commit 8a1aa5dcf2
3 changed files with 84 additions and 14 deletions

View File

@@ -107,8 +107,8 @@ bool OptionsParser::checkForTestOption()
if (nextToken(RequiredToken)) {
if (m_currentArg == QLatin1String("all")) {
foreach (PluginSpec *spec, m_pmPrivate->pluginSpecs) {
if (spec && !m_pmPrivate->testSpecs.contains(spec))
m_pmPrivate->testSpecs.append(spec);
if (spec && !m_pmPrivate->containsTestSpec(spec))
m_pmPrivate->testSpecs.append(PluginManagerPrivate::TestSpec(spec));
}
} else {
PluginSpec *spec = m_pmPrivate->pluginByName(m_currentArg);
@@ -117,8 +117,20 @@ bool OptionsParser::checkForTestOption()
*m_errorString = QCoreApplication::translate("PluginManager",
"The plugin '%1' does not exist.").arg(m_currentArg);
m_hasError = true;
} else if (!m_pmPrivate->testSpecs.contains(spec)) {
m_pmPrivate->testSpecs.append(spec);
} else if (!m_pmPrivate->containsTestSpec(spec)) {
// Collect optional test functions. Everything following the plugin
// name until the next option is interpreted as a test function. E.g.
// in './qtcreator -test Git myFile' the argument 'myFile' will be
// be interpreted as an function name and not a file to open.
const QStringList::const_iterator current(m_it);
QStringList testFunctions;
while (nextToken() && !m_currentArg.startsWith(QLatin1Char('-')))
testFunctions.append(m_currentArg);
// Make sure a following nextToken() call will get the current/next option.
if (current != m_it && m_it != m_end)
--m_it;
m_pmPrivate->testSpecs.append(
PluginManagerPrivate::TestSpec(spec, testFunctions));
}
}
}