From 3b0c0435bc8f2075e4b0e61ce968de23f76e3f99 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 20 Mar 2020 21:55:03 +0100 Subject: [PATCH] [libcalamaresui] Chase API change in Yaml - We can drop a bunch of calls to toMap() now. --- src/libcalamaresui/Branding.cpp | 2 +- src/libcalamaresui/modulesystem/Module.cpp | 2 +- src/modules/contextualprocess/Tests.cpp | 6 +++--- src/modules/shellprocess/Tests.cpp | 18 ++++++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 34ba23436..5c41f5ea2 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -123,7 +123,7 @@ loadStrings( QMap< QString, QString >& map, throw YAML::Exception( YAML::Mark(), std::string( "Branding configuration is not a map: " ) + key ); } - const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ).toMap(); + const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ); map.clear(); for ( auto it = config.constBegin(); it != config.constEnd(); ++it ) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 8fe3f2ac6..35b1508f1 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -237,7 +237,7 @@ void Module::loadConfigurationFile( const QString& configFileName ) //throws YA } cDebug() << "Loaded module configuration" << path; - m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap(); + m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ); m_emergency = m_maybe_emergency && m_configurationMap.contains( EMERGENCY ) && m_configurationMap[ EMERGENCY ].toBool(); return; diff --git a/src/modules/contextualprocess/Tests.cpp b/src/modules/contextualprocess/Tests.cpp index a0071328a..50ce9f400 100644 --- a/src/modules/contextualprocess/Tests.cpp +++ b/src/modules/contextualprocess/Tests.cpp @@ -79,14 +79,15 @@ ContextualProcessTests::testProcessListSampleConfig() } ContextualProcessJob job; - job.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc ).toMap() ); + job.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc ) ); QCOMPARE( job.count(), 2 ); // Only "firmwareType" and "branding.shortVersion" QCOMPARE( job.count( "firmwareType" ), 4 ); QCOMPARE( job.count( "branding.shortVersion" ), 2 ); // in the example config } -void ContextualProcessTests::testFetch() +void +ContextualProcessTests::testFetch() { Logger::setupLogLevel( Logger::LOGVERBOSE ); @@ -187,5 +188,4 @@ void ContextualProcessTests::testFetch() QCOMPARE( s, QString() ); QVERIFY( s.isEmpty() ); } - } diff --git a/src/modules/shellprocess/Tests.cpp b/src/modules/shellprocess/Tests.cpp index e991973db..caf9800c9 100644 --- a/src/modules/shellprocess/Tests.cpp +++ b/src/modules/shellprocess/Tests.cpp @@ -62,7 +62,7 @@ ShellProcessTests::testProcessListSampleConfig() } } - CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl.isEmpty() ); QCOMPARE( cl.count(), 3 ); @@ -79,7 +79,7 @@ script: - "ls /nonexistent" - "/bin/false" )" ); - CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl.isEmpty() ); QCOMPARE( cl.count(), 3 ); @@ -90,7 +90,7 @@ script: - false - "ls /nonexistent" )" ); - CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl1.isEmpty() ); QCOMPARE( cl1.count(), 2 ); // One element ignored } @@ -101,7 +101,7 @@ ShellProcessTests::testProcessListFromString() YAML::Node doc = YAML::Load( R"(--- script: "ls /tmp" )" ); - CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl.isEmpty() ); QCOMPARE( cl.count(), 1 ); @@ -112,7 +112,7 @@ script: "ls /tmp" doc = YAML::Load( R"(--- script: false )" ); - CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( cl1.isEmpty() ); QCOMPARE( cl1.count(), 0 ); } @@ -125,7 +125,7 @@ script: command: "ls /tmp" timeout: 20 )" ); - CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl.isEmpty() ); QCOMPARE( cl.count(), 1 ); @@ -142,7 +142,7 @@ script: timeout: 12 - "-/bin/false" )" ); - CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) ); + CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) ); QVERIFY( !cl.isEmpty() ); QCOMPARE( cl.count(), 2 ); QCOMPARE( cl.at( 0 ).timeout(), 12s ); @@ -157,12 +157,11 @@ ShellProcessTests::testRootSubstitution() script: - "ls /tmp" )" ); - QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ); + QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).value( "script" ); QVariant rootScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(--- script: - "ls @@ROOT@@" )" ) ) - .toMap() .value( "script" ); QVariant userScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(--- script: @@ -170,7 +169,6 @@ script: - "chown @@USER@@ @@ROOT@@/calatest*" - rm -rf @@ROOT@@/calatest* )" ) ) - .toMap() .value( "script" ); if ( !Calamares::JobQueue::instance() )