[libcalamares] Extend tests to all example config files
- Do a `find ../src/ -name *.conf` to get files to load - Load and save all of them to check for correctness
This commit is contained in:
parent
e25deffa74
commit
3d6dd1202a
@ -66,4 +66,46 @@ LibCalamaresTests::testLoadSaveYaml()
|
|||||||
|
|
||||||
auto map = CalamaresUtils::loadYaml( "settings.conf" );
|
auto map = CalamaresUtils::loadYaml( "settings.conf" );
|
||||||
CalamaresUtils::saveYaml( "out.yaml", map );
|
CalamaresUtils::saveYaml( "out.yaml", map );
|
||||||
|
|
||||||
|
auto other_map = CalamaresUtils::loadYaml( "out.yaml" );
|
||||||
|
CalamaresUtils::saveYaml(" out2.yaml", other_map );
|
||||||
|
QCOMPARE( map, other_map );
|
||||||
|
|
||||||
|
QFile::remove( "out.yaml" );
|
||||||
|
QFile::remove( "out2.yaml" );
|
||||||
|
}
|
||||||
|
|
||||||
|
static QStringList
|
||||||
|
findConf( const QDir& d )
|
||||||
|
{
|
||||||
|
QStringList mine;
|
||||||
|
if ( d.exists() )
|
||||||
|
{
|
||||||
|
QString path = d.absolutePath();
|
||||||
|
path.append( d.separator() );
|
||||||
|
for ( const auto& confname : d.entryList( { "*.conf" } ) )
|
||||||
|
mine.append( path + confname );
|
||||||
|
for ( const auto& subdirname : d.entryList( QDir::AllDirs | QDir::NoDotAndDotDot ) )
|
||||||
|
{
|
||||||
|
QDir subdir( d );
|
||||||
|
subdir.cd( subdirname );
|
||||||
|
mine.append( findConf( subdir ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mine;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LibCalamaresTests::testLoadSaveYamlExtended()
|
||||||
|
{
|
||||||
|
for ( const auto& confname : findConf( QDir( "../src" ) ) )
|
||||||
|
{
|
||||||
|
cDebug() << "Testing" << confname;
|
||||||
|
auto map = CalamaresUtils::loadYaml( confname );
|
||||||
|
QVERIFY( CalamaresUtils::saveYaml( "out.yaml", map ) );
|
||||||
|
auto othermap = CalamaresUtils::loadYaml( "out.yaml" );
|
||||||
|
QCOMPARE( map, othermap );
|
||||||
|
}
|
||||||
|
QFile::remove( "out.yaml" );
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ private Q_SLOTS:
|
|||||||
void initTestCase();
|
void initTestCase();
|
||||||
void testDebugLevels();
|
void testDebugLevels();
|
||||||
|
|
||||||
void testLoadSaveYaml();
|
void testLoadSaveYaml(); // Just settings.conf
|
||||||
|
void testLoadSaveYamlExtended(); // Do a find() in the src dir
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user