Plugin tests: Specify test functions in same parameter as plugin name

Some tests will explicitly depend on the project/session provided on the
command line.

Change-Id: I6ee9388caf54683a3e055378eda990c8f9bbcdcf
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-03-20 16:31:14 +01:00
parent 4ba79a5516
commit 646527b65a
2 changed files with 14 additions and 18 deletions

View File

@@ -114,26 +114,22 @@ bool OptionsParser::checkForTestOption()
m_pmPrivate->testSpecs.append(PluginManagerPrivate::TestSpec(spec)); m_pmPrivate->testSpecs.append(PluginManagerPrivate::TestSpec(spec));
} }
} else { } else {
PluginSpec *spec = m_pmPrivate->pluginByName(m_currentArg); QStringList args = m_currentArg.split(QLatin1Char(','));
if (!spec) { const QString pluginName = args.takeFirst();
if (PluginSpec *spec = m_pmPrivate->pluginByName(pluginName)) {
if (m_pmPrivate->containsTestSpec(spec)) {
if (m_errorString)
*m_errorString = QCoreApplication::translate("PluginManager",
"The plugin '%1' is specified twice for testing.").arg(pluginName);
m_hasError = true;
} else {
m_pmPrivate->testSpecs.append(PluginManagerPrivate::TestSpec(spec, args));
}
} else {
if (m_errorString) if (m_errorString)
*m_errorString = QCoreApplication::translate("PluginManager", *m_errorString = QCoreApplication::translate("PluginManager",
"The plugin '%1' does not exist.").arg(m_currentArg); "The plugin '%1' does not exist.").arg(pluginName);
m_hasError = true; m_hasError = true;
} 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));
} }
} }
} }

View File

@@ -629,7 +629,7 @@ void PluginManager::formatOptions(QTextStream &str, int optionIndentation, int d
optionIndentation, descriptionIndentation); optionIndentation, descriptionIndentation);
#ifdef WITH_TESTS #ifdef WITH_TESTS
formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION)
+ QLatin1String(" <plugin> [testfunction[:testdata]]..."), QString(), + QLatin1String(" <plugin>[,testfunction[:testdata]]..."), QString(),
QLatin1String("Run plugin's tests"), optionIndentation, descriptionIndentation); QLatin1String("Run plugin's tests"), optionIndentation, descriptionIndentation);
formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) + QLatin1String(" all"), formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) + QLatin1String(" all"),
QString(), QLatin1String("Run tests from all plugins"), QString(), QLatin1String("Run tests from all plugins"),