mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 02:45:37 -04:00
[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
2 changed files with 44 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue