[libcalamares] Rename moduleInstances() and fix tests
- "custom" is a misnomer, so drop that from the name - tests adjusted: all instances are returned, not just the "custom" ones.
This commit is contained in:
parent
6f7234e4ac
commit
1f57a99ff2
@ -277,8 +277,8 @@ Settings::validateSequence()
|
||||
{
|
||||
targetKey = k;
|
||||
const auto it = std::find_if(
|
||||
m_customModuleInstances.constBegin(), m_customModuleInstances.constEnd(), moduleFinder );
|
||||
if ( it == m_customModuleInstances.constEnd() )
|
||||
m_moduleInstances.constBegin(), m_moduleInstances.constEnd(), moduleFinder );
|
||||
if ( it == m_moduleInstances.constEnd() )
|
||||
{
|
||||
cWarning() << "Custom instance key" << instance << "is not listed in the *instances*";
|
||||
// don't add it, let this fail later.
|
||||
@ -288,11 +288,11 @@ Settings::validateSequence()
|
||||
{
|
||||
targetKey = k;
|
||||
const auto it = std::find_if(
|
||||
m_customModuleInstances.constBegin(), m_customModuleInstances.constEnd(), moduleFinder );
|
||||
if ( it == m_customModuleInstances.constEnd() )
|
||||
m_moduleInstances.constBegin(), m_moduleInstances.constEnd(), moduleFinder );
|
||||
if ( it == m_moduleInstances.constEnd() )
|
||||
{
|
||||
// Non-custom instance, just mentioned in *sequence*
|
||||
m_customModuleInstances.append( InstanceDescription( k ) );
|
||||
m_moduleInstances.append( InstanceDescription( k ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ Settings::setConfiguration( const QByteArray& ba, const QString& explainName )
|
||||
|
||||
interpretModulesSearch(
|
||||
debugMode(), CalamaresUtils::yamlToStringList( config[ "modules-search" ] ), m_modulesSearchPaths );
|
||||
interpretInstances( config[ "instances" ], m_customModuleInstances );
|
||||
interpretInstances( config[ "instances" ], m_moduleInstances );
|
||||
interpretSequence( config[ "sequence" ], m_modulesSequence );
|
||||
|
||||
m_brandingComponentName = requireString( config, "branding" );
|
||||
@ -336,9 +336,9 @@ Settings::modulesSearchPaths() const
|
||||
|
||||
|
||||
Settings::InstanceDescriptionList
|
||||
Settings::customModuleInstances() const
|
||||
Settings::moduleInstances() const
|
||||
{
|
||||
return m_customModuleInstances;
|
||||
return m_moduleInstances;
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
QStringList modulesSearchPaths() const;
|
||||
|
||||
using InstanceDescriptionList = QList< InstanceDescription >;
|
||||
InstanceDescriptionList customModuleInstances() const;
|
||||
InstanceDescriptionList moduleInstances() const;
|
||||
|
||||
using ModuleSequence = QList< QPair< ModuleSystem::Action, QStringList > >;
|
||||
ModuleSequence modulesSequence() const;
|
||||
@ -158,7 +158,7 @@ private:
|
||||
|
||||
QStringList m_modulesSearchPaths;
|
||||
|
||||
InstanceDescriptionList m_customModuleInstances;
|
||||
InstanceDescriptionList m_moduleInstances;
|
||||
ModuleSequence m_modulesSequence;
|
||||
|
||||
QString m_brandingComponentName;
|
||||
|
@ -386,7 +386,7 @@ TestLibCalamares::testSettings()
|
||||
{
|
||||
Calamares::Settings s( true );
|
||||
QVERIFY( s.debugMode() );
|
||||
QVERIFY( s.customModuleInstances().isEmpty() );
|
||||
QVERIFY( s.moduleInstances().isEmpty() );
|
||||
QVERIFY( s.modulesSequence().isEmpty() );
|
||||
QVERIFY( s.brandingComponentName().isEmpty() );
|
||||
|
||||
@ -410,7 +410,7 @@ sequence:
|
||||
QStringLiteral( "<testdata>" ) );
|
||||
|
||||
QVERIFY( s.debugMode() );
|
||||
QCOMPARE( s.customModuleInstances().count(), 2 );
|
||||
QCOMPARE( s.moduleInstances().count(), 4 ); // there are 4 module instances mentioned
|
||||
QCOMPARE( s.modulesSequence().count(), 2 ); // 2 steps (show, exec)
|
||||
QVERIFY( s.brandingComponentName().isEmpty() );
|
||||
|
||||
@ -422,17 +422,17 @@ sequence:
|
||||
};
|
||||
|
||||
const auto it0 = std::find_if(
|
||||
s.customModuleInstances().constBegin(), s.customModuleInstances().constEnd(), moduleFinder );
|
||||
QVERIFY( it0 != s.customModuleInstances().constEnd() );
|
||||
s.moduleInstances().constBegin(), s.moduleInstances().constEnd(), moduleFinder );
|
||||
QVERIFY( it0 != s.moduleInstances().constEnd() );
|
||||
|
||||
moduleKey = QString( "derp" );
|
||||
const auto it1 = std::find_if(
|
||||
s.customModuleInstances().constBegin(), s.customModuleInstances().constEnd(), moduleFinder );
|
||||
QVERIFY( it1 == s.customModuleInstances().constEnd() );
|
||||
s.moduleInstances().constBegin(), s.moduleInstances().constEnd(), moduleFinder );
|
||||
QVERIFY( it1 == s.moduleInstances().constEnd() );
|
||||
|
||||
int validCount = 0;
|
||||
int customCount = 0;
|
||||
for ( const auto& d : s.customModuleInstances() )
|
||||
for ( const auto& d : s.moduleInstances() )
|
||||
{
|
||||
if ( d.isValid() )
|
||||
validCount++;
|
||||
@ -441,7 +441,7 @@ sequence:
|
||||
QVERIFY( d.isCustom() ? d.isValid() : true ); // All custom entries are valid
|
||||
}
|
||||
QCOMPARE( customCount, 2 );
|
||||
QCOMPARE( validCount, 2 );
|
||||
QCOMPARE( validCount, 4 ); // welcome@hi is listed twice, in *show* and *exec*
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user