81    return it == 
_pimpl->properties.end() ? def : it->second;
 
 
   85  { 
return _pimpl->properties; }
 
 
   88  { 
return _pimpl->properties; }
 
 
   91  { 
return _pimpl->children; }
 
 
   94  { 
return _pimpl->children; }
 
 
   98    xmlDocPtr xml_doc = xmlParseFile ( filename.
c_str() );
 
   99    if (xml_doc == NULL) {
 
  100      if ( err ) *err = (
str::Str() << 
"Can't parse test file '" << filename << 
"'");
 
  107    DBG << 
"Parsing file '" << filename << 
"'" << std::endl;
 
  109    if (!root.equals(
"test")) {
 
  110      if ( err ) *err = (
str::Str() << 
"Node not 'test' in parse_xml_test():" << root.name() << 
"'");
 
  114    bool setupDone = 
false;
 
  115    auto node = root.children();
 
  117      if (node->type() == XML_ELEMENT_NODE) {
 
  118        if (node->equals( 
"setup" )) {
 
  120            if ( err ) *err = 
"Multiple setup tags found, this is not supported";
 
  127        } 
else if (node->equals( 
"trial" )) {
 
  129            if ( err ) *err = 
"Any trials must be preceded by the setup!";
 
  137          ERR << 
"Unknown tag '" << node->name() << 
"' in test" << std::endl;
 
  140      node = ( node->next() );
 
  142    xmlFreeDoc (xml_doc);
 
 
  148    DBG << 
"Parsing file '" << path << 
"'" << std::endl;
 
  150    const auto makeError = [&]( 
const std::string_view &errStr ){
 
  151      if ( err ) *err = errStr;
 
  157      control = YAML::LoadFile( path.
asString() );
 
  159      if ( control.Type() != YAML::NodeType::Map )
 
  160        return makeError(
"Root node must be of type Map.");
 
  162      const auto &setup = control[
"setup"];
 
  164        return makeError(
"The 'setup' section is required.");
 
  169      const auto &trials = control[
"trials"];
 
  171        return makeError(
"The 'trials' section is required.");
 
  172      if ( trials.Type() != YAML::NodeType::Sequence )
 
  173        return makeError(
"The 'trials' section must be of type Sequence.");
 
  175      for ( 
const auto &trial : trials ) {
 
  177        if ( !trial[
"trial"] )
 
  178          return makeError(
"Every element in the trials sequence needs to have the 'trial' key.");
 
  184    } 
catch ( YAML::Exception &e ) {
 
  185      if ( err ) *err = e.what();
 
  188      if ( err ) *err = 
"Unknown error when parsing the control file";
 
 
  204      if ( err ) *err = 
"Unsopported or no testcase in directory";
 
  210    _pimpl->_setup.data().globalPath = path;
 
 
 
Wrapper class for stat/lstat.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
const TestcaseSetup & setupInfo() const
const TestcaseTrials & trialInfo() const
std::unique_ptr< Impl > _pimpl
static Type testcaseTypeAt(const zypp::Pathname &path)
bool loadTestcaseAt(const zypp::Pathname &path, std::string *err)
std::vector< TestcaseTrial > TestcaseTrials
bool parseTrial(const XmlNode &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *)
bool parseSetup(const XmlNode &setup, zypp::misc::testcase::TestcaseSetup &t, std::string *err)
bool parseSetup(const YAML::Node &setup, zypp::misc::testcase::TestcaseSetup &t, std::string *err)
bool parseTrial(const YAML::Node &trial, zypp::misc::testcase::TestcaseTrial &target, const zypp::Pathname &testcaseDir, std::string *err)
static const std::string yamlControlFile
static const std::string helixControlFile
bool loadHelix(const Pathname &filename, std::string *err)
bool loadYaml(const Pathname &path, std::string *err)
std::vector< Node > nodes
std::map< std::string, std::string > properties
std::vector< std::shared_ptr< Node > > children
const std::vector< std::shared_ptr< Node > > & children() const
const std::string & name() const
const std::string & getProp(const std::string &name, const std::string &def=std::string()) const
const std::map< std::string, std::string > & properties() const
RWCOW_pointer< Impl > _pimpl
const std::string & value() const
const std::vector< Node > & nodes() const
RWCOW_pointer< Impl > _pimpl
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...