27 auto &target = t.
data();
28 MIL <<
"Parsing setup node " << std::endl;
29 for ( YAML::const_iterator it = setup.begin(); it != setup.end(); it++ ) {
31 const std::string &key = it->first.as<std::string>();
32 const auto &data = (*it).second;
34 MIL <<
"Found key " << key << std::endl;
37 auto readListInlineOrFromFile = [&](
const auto &cb , std::string *err ) ->
bool {
38 if ( data.Type() == YAML::NodeType::Sequence ) {
40 for (
const auto &node: data ) {
41 if ( !cb( node, err ) )
return false;
44 MIL <<
"Loaded " << cnt <<
" Elements inline" << std::endl;
46 const std::string &fName = data.as<std::string>();
47 MIL <<
"Trying to load list from file " << fName << std::endl;
49 auto doc = YAML::LoadFile( (target.globalPath / fName).asString() );
50 if ( doc.Type() != YAML::NodeType::Sequence ) {
51 if ( err ) *err =
"Expected the top node to be a sequence in external file for key: ";
56 for (
const auto &node : doc ) {
57 if ( !cb( node, err ) )
return false;
60 MIL <<
"Loaded " << cnt <<
" Elements from file" << std::endl;
61 }
catch ( YAML::Exception &e ) {
65 if ( !e.mark.is_null() ) {
66 errStr <<
" Line: " << e.mark.line <<
" Col: " << e.mark.column <<
" pos: " << e.mark.pos;
72 if ( err ) *err =
zypp::str::Str() <<
"Unknown error when parsing the file for " << key;
79 if ( key ==
"resolverFlags" ) {
80#define if_SolverFlag( N ) if ( data[#N] ) { target.N = data[#N].as<bool>(); }
81 if_SolverFlag( ignorealreadyrecommended )
if ( data[
"ignorealready"] ) { target.ignorealreadyrecommended = data[
"ignorealready"].as<
bool>(); }
82 if_SolverFlag( onlyRequires )
if ( data[
"ignorerecommended"] ) { target.onlyRequires = data[
"ignorerecommended"].as<
bool>(); }
98 if ( data[
"focus"] ) {
101 }
else if ( key == (
"system") ) {
106 data[
"file"].as<std::string>()
109 else if ( key == (
"hardwareInfo") ) {
110 target.hardwareInfoFile = data.as<std::string>();
112 else if ( key == (
"modalias") ) {
113 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode,
auto ){
114 target.modaliasList.push_back( dataNode.as<std::string>() );
117 if ( !success )
return false;
119 else if ( key == (
"multiversion") ) {
120 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode,
auto ){
121 target.multiversionSpec.insert( dataNode.as<std::string>() );
124 if ( !success )
return false;
126 else if (key == (
"channels")) {
127 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode,
auto ){
128 std::string name = dataNode[
"alias"].as<std::string>();
129 std::string file = dataNode[
"file"].as<std::string>();
132 if ( dataNode[
"priority"] )
133 prio = dataNode[
"priority"].as<
unsigned>();
143 if ( !success )
return false;
145 else if ( key == (
"sources") )
147 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode,
auto ){
148 std::string url = dataNode[
"url"].as<std::string>();
149 std::string alias = dataNode[
"name"].as<std::string>();
158 if ( !success )
return false;
160 else if ( key == (
"force-install") )
162 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode,
auto ){
164 dataNode[
"channel"].as<std::string>(),
165 dataNode[
"package"].as<std::string>(),
166 dataNode[
"kind"].as<std::string>()
170 if ( !success )
return false;
172 else if ( key == (
"mediaid") )
174 target.show_mediaid = data.as<
bool>();
176 else if ( key == (
"arch") ) {
177 std::string architecture = data.as<std::string>();
178 if ( architecture.empty() ) {
179 if (err) *err =
zypp::str::Str() <<
"Property 'arch' in setup can not be empty." << std::endl;
183 MIL <<
"Setting architecture to '" << architecture <<
"'" << std::endl;
184 target.architecture =
zypp::Arch( architecture );
187 else if ( key == (
"locales") )
189 bool success = readListInlineOrFromFile( [&target](
const YAML::Node &dataNode, std::string *err ){
191 std::string fate = dataNode[
"fate"].as<std::string>();
193 if (err) *err =
zypp::str::Str() <<
"Bad or missing name in locale..." << std::endl;
196 else if ( fate ==
"added" ) {
197 target.localesTracker.added().insert( loc );
199 else if ( fate ==
"removed" ) {
200 target.localesTracker.removed().insert( loc );
203 target.localesTracker.current().insert( loc );
207 if ( !success )
return false;
209 else if ( key == (
"vendors") )
211 bool success = readListInlineOrFromFile( [&target](
const YAML::Node & dataNode, std::string * err ) {
212 std::vector<std::string> vlist;
213 for (
const auto & node : dataNode )
214 vlist.push_back( node.as<std::string>() );
215 if ( ! vlist.empty() )
216 target.vendorLists.push_back( std::move(vlist) );
219 if ( !success )
return false;
221 else if ( key == (
"autoinst") ) {
222 bool success = readListInlineOrFromFile( [&](
const YAML::Node &dataNode, std::string * err ){
223 target.autoinstalled.push(
zypp::IdString( dataNode.as<std::string>() ).
id() );
226 if ( !success )
return false;
228 else if ( key == (
"systemCheck") ) {
229 target.systemCheck = data.as<std::string>();
231 else if ( key == (
"setlicencebit") ) {
232 target.set_licence = data.as<
bool>();
235 ERR <<
"Ignoring unrecognized tag '" << key <<
"' in setup" << std::endl;
247 constexpr bool isSubNode = std::is_same_v<T, std::shared_ptr<zypp::misc::testcase::TestcaseTrial::Node>>;
248 if ( jobNode[
"include"] ) {
250 const auto &fName = jobNode[
"include"].as<std::string>();
251 MIL <<
"Including file " << fName << std::endl;
253 auto doc = YAML::LoadFile( (testcaseDir / fName).asString() );
254 if ( !
parseJobs( doc, target, testcaseDir, err ) )
256 MIL <<
"Including file " << fName <<
"was successful" << std::endl;
257 }
catch ( YAML::Exception &e ) {
258 if ( err ) *err = e.what();
261 if ( err ) *err =
zypp::str::Str() <<
"Unknown error when parsing the file: " << fName;
268 if ( !jobNode[
"job"] ) {
271 const auto &mark = jobNode.Mark();
272 errStr <<
"'job' key missing from trial node.";
273 if ( !mark.is_null() ) {
274 errStr <<
" Line: " << mark.line <<
" Col: " << mark.column <<
" pos: " << mark.pos;
281 for (
const auto &elem : jobNode ) {
282 const std::string &key = elem.first.as<std::string>();
283 const auto &data = elem.second;
284 if ( key ==
"job" ) {
285 n.
name() = data.as<std::string>();
286 }
else if ( key ==
"__content") {
287 n.
value() = data.as<std::string>();
289 if( data.IsScalar() ) {
290 n.
properties().insert( { key, data.as<std::string>() } );
291 }
else if ( data.IsSequence() ) {
297 }
else if ( data.IsMap() ) {
304 ERR <<
"Ignoring field " << key <<
" with unsupported type:" << data.Type() << std::endl;
308 if constexpr ( isSubNode ) {
309 target.push_back( std::make_shared<zypp::misc::testcase::TestcaseTrial::Node>( std::move(n) ) );
311 target.push_back( std::move(n) );