mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Fix unit_test suite matching with full names
This commit is contained in:
committed by
Nik Bougalis
parent
756ac603db
commit
cd98d1c1f9
@@ -51,9 +51,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mode_t m_mode;
|
mode_t mode_;
|
||||||
std::string m_pat;
|
std::string pat_;
|
||||||
std::string m_library;
|
std::string library_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class = void>
|
template <class = void>
|
||||||
@@ -69,52 +69,52 @@ public:
|
|||||||
|
|
||||||
template <class>
|
template <class>
|
||||||
selector::selector (mode_t mode, std::string const& pattern)
|
selector::selector (mode_t mode, std::string const& pattern)
|
||||||
: m_mode (mode)
|
: mode_ (mode)
|
||||||
, m_pat (pattern)
|
, pat_ (pattern)
|
||||||
{
|
{
|
||||||
if (m_mode == automatch && pattern.empty())
|
if (mode_ == automatch && pattern.empty())
|
||||||
m_mode = all;
|
mode_ = all;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class>
|
template <class>
|
||||||
bool
|
bool
|
||||||
selector::operator() (suite_info const& s)
|
selector::operator() (suite_info const& s)
|
||||||
{
|
{
|
||||||
switch (m_mode)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case automatch:
|
case automatch:
|
||||||
// check suite
|
// suite or full name
|
||||||
if (m_pat == s.name())
|
if (s.name() == pat_ || s.full_name() == pat_)
|
||||||
{
|
{
|
||||||
m_mode = none;
|
mode_ = none;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check module
|
// check module
|
||||||
if (m_pat == s.module())
|
if (pat_ == s.module())
|
||||||
{
|
{
|
||||||
m_mode = module;
|
mode_ = module;
|
||||||
m_library = s.library();
|
library_ = s.library();
|
||||||
return ! s.manual();
|
return ! s.manual();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check library
|
// check library
|
||||||
if (m_pat == s.library())
|
if (pat_ == s.library())
|
||||||
{
|
{
|
||||||
m_mode = library;
|
mode_ = library;
|
||||||
return ! s.manual();
|
return ! s.manual();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case suite:
|
case suite:
|
||||||
return m_pat == s.name();
|
return pat_ == s.name();
|
||||||
|
|
||||||
case module:
|
case module:
|
||||||
return m_pat == s.module() && ! s.manual();
|
return pat_ == s.module() && ! s.manual();
|
||||||
|
|
||||||
case library:
|
case library:
|
||||||
return m_pat == s.library() && ! s.manual();
|
return pat_ == s.library() && ! s.manual();
|
||||||
|
|
||||||
case none:
|
case none:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -33,35 +33,35 @@ class runner;
|
|||||||
class suite_info
|
class suite_info
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef std::function <void (runner&)> run_type;
|
using run_type = std::function <void (runner&)>;
|
||||||
|
|
||||||
char const* m_name;
|
std::string name_;
|
||||||
char const* m_module;
|
std::string module_;
|
||||||
char const* m_library;
|
std::string library_;
|
||||||
bool m_manual;
|
bool m_manual;
|
||||||
run_type m_run;
|
run_type m_run;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <class = void>
|
template <class = void>
|
||||||
suite_info (char const* name, char const* module, char const* library,
|
suite_info (std::string const& name, std::string const& module,
|
||||||
bool manual, run_type run);
|
std::string const& library, bool manual, run_type run);
|
||||||
|
|
||||||
char const*
|
std::string const&
|
||||||
name() const
|
name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const*
|
std::string const&
|
||||||
module() const
|
module() const
|
||||||
{
|
{
|
||||||
return m_module;
|
return module_;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const*
|
std::string const&
|
||||||
library() const
|
library() const
|
||||||
{
|
{
|
||||||
return m_library;
|
return library_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns `true` if this suite only runs manually. */
|
/** Returns `true` if this suite only runs manually. */
|
||||||
@@ -87,15 +87,11 @@ public:
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template <class>
|
template <class>
|
||||||
suite_info::suite_info (
|
suite_info::suite_info (std::string const& name, std::string const& module,
|
||||||
char const* name,
|
std::string const& library, bool manual, run_type run)
|
||||||
char const* module,
|
: name_ (name)
|
||||||
char const* library,
|
, module_ (module)
|
||||||
bool manual,
|
, library_ (library)
|
||||||
run_type run)
|
|
||||||
: m_name (name)
|
|
||||||
, m_module (module)
|
|
||||||
, m_library (library)
|
|
||||||
, m_manual (manual)
|
, m_manual (manual)
|
||||||
, m_run (std::move (run))
|
, m_run (std::move (run))
|
||||||
{
|
{
|
||||||
@@ -105,10 +101,7 @@ template <class>
|
|||||||
std::string
|
std::string
|
||||||
suite_info::full_name() const
|
suite_info::full_name() const
|
||||||
{
|
{
|
||||||
return
|
return library_ + "." + module_ + "." + name_;
|
||||||
std::string (m_library) + "." +
|
|
||||||
std::string (m_module) + "." +
|
|
||||||
std::string (m_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -121,15 +114,11 @@ operator< (suite_info const& lhs, suite_info const& rhs)
|
|||||||
/** Convenience for producing suite_info for a given test type. */
|
/** Convenience for producing suite_info for a given test type. */
|
||||||
template <class Suite>
|
template <class Suite>
|
||||||
suite_info
|
suite_info
|
||||||
make_suite_info (char const* name, char const* module, char const* library,
|
make_suite_info (std::string const& name, std::string const& module,
|
||||||
bool manual)
|
std::string const& library, bool manual)
|
||||||
{
|
{
|
||||||
return suite_info (name, module, library, manual,
|
return suite_info(name, module, library, manual,
|
||||||
[](runner& r)
|
[](runner& r) { return Suite{}(r); });
|
||||||
{
|
|
||||||
Suite test;
|
|
||||||
return test (r);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
|
|||||||
Reference in New Issue
Block a user