70#ifndef LIB_TEST_EVENT_LOG_H
71#define LIB_TEST_EVENT_LOG_H
100 using Log = std::vector<Entry>;
103 buildSearchFilter(
Log const& srcSeq)
106 return iter::chainSearch (Cursor{srcSeq.begin(), srcSeq.end()});
122 using Filter =
decltype( buildSearchFilter (std::declval<Log const&>()) );
153 operator bool()
const
157 cerr <<
"__Log_condition_violated__\n"+
violation_ <<
"\n";
196 template<
typename...ARGS>
215 template<
typename...ARGS>
225 template<
typename ARG>
247 return this->
on(targetID);
282 log (std::initializer_list<string>
const& ili)
284 log_->emplace_back(ili);
287 template<
typename ATTR,
typename ARGS>
291 log_->emplace_back(typeID, std::forward<ATTR>(attribs)
292 , std::forward<ARGS>(args));
308 :
EventLog(idi::instanceTypeID (obj))
319 return log_->front().get(
"this");
358 template<
typename...ELMS>
360 event (
string classifier, ELMS
const& ...initialiser)
362 log (
"event",
ArgSeq{
"ID="+classifier}, collectStr<ArgSeq> (initialiser...));
378 template<
typename...ARGS>
380 call (
string target,
string function, ARGS
const& ...args)
382 return call (target, function, collectStr<ArgSeq>(args...));
386 template<
class X,
typename...ARGS>
388 call (
const X *
const targetObj,
string function, ARGS
const& ...args)
393 template<
typename...ARGS>
395 call (
CStr target,
string function, ARGS
const& ...args)
397 return call (
string(target), function, args...);
400 template<
typename...ELMS>
402 note (ELMS
const& ...initialiser)
404 log_->emplace_back (collectStr<ArgSeq> (initialiser...));
429 template<
typename X,
typename...ARGS>
431 addAttrib (
string const& key,
X&& initialiser, ARGS&& ...args)
433 REQUIRE (not isnil (*
log_));
434 mutateInPlace (
log_->back())
435 .attrib(key,initialiser, std::forward<ARGS>(args)...);
447 return 1 >=
log_->size();
529 return not (l1 == l2);
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
Token or Atom with distinct identity.
object-like record of data.
Helper to log and verify the occurrence of events.
EventLog & call(string target, string function, ARGS const &...args)
Log a function call with arbitrary arguments.
EventLog & warn(string text)
Log a warning entry.
EventLog & event(string classifier, ELMS const &...initialiser)
const_iterator begin() const
friend const_iterator end(EventLog const &log)
lib::diff::RecordSetup< string >::Storage ArgSeq
EventLog & addAttrib(string const &key, X &&initialiser, ARGS &&...args)
Qualify the latest entry: set further attribute(s)
EventLog & destroy(string text)
Log the destruction of an object.
EventLog & event(string text)
log some text as event
friend bool operator!=(EventLog const &l1, EventLog const &l2)
EventMatch verify(string match) const
start a query to match for some substring.
EventLog & error(string text)
Log an error note.
void log(Symbol typeID, ATTR &&attribs, ARGS &&args)
friend const_iterator begin(EventLog const &log)
EventLog & clear(const X *const obj)
EventLog & clear()
purge log contents while retaining just the original Header-ID
EventMatch verifyCall(string match) const
start a query to match especially a function call
EventMatch verifyEvent(string match) const
start a query to match for some event.
EventLog & joinInto(EventLog &otherLog)
Merge this log into another log, forming a combined log.
EventMatch verifyMatch(string regExp) const
start a query to match with a regular expression
lib::RangeIter< Log::const_iterator > Iter
EventMatch verifyEvent(string classifier, X const &something) const
std::shared_ptr< Log > log_
const_iterator end() const
EventLog & create(string text)
Log the creation of an object.
EventMatch ensureNot(string match) const
start a query to ensure the given expression does not match.
void log(std::initializer_list< string > const &ili)
friend bool operator==(EventLog const &l1, EventLog const &l2)
equality comparison is based on the actual log contents
EventLog & note(ELMS const &...initialiser)
EventLog & call(CStr target, string function, ARGS const &...args)
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
EventLog & fatal(string text)
Log a fatal failure.
EventLog & call(const X *const targetObj, string function, ARGS const &...args)
Log a function call on given object ("`this`")...
EventLog(const X *const obj)
bool foundSolution()
core of the evaluation machinery: apply a filter predicate and then pull through the log to find a ac...
EventMatch & type(string typeID)
refine filter to additionally require a matching log entry type
bool look_for_match_
support for positive and negative queries.
EventMatch & beforeMatch(string regExp)
find a match with the given regular expression
void refineSerach_matchArgument(size_t idx, string match)
std::vector< std::regex > RExSeq
EventMatch & afterCall(string match)
find a function invocation backwards, before the current point of reference
string violation_
record when the underlying query has failed
lib::diff::RecordSetup< string >::Storage ArgSeq
EventMatch & id(string classifier)
refine filter to additionally match on the ID attribute
EventMatch & locateMatch(string regExp)
basic search like locate() but with the given regular expression
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
EventMatch & argMatch(ARGS const &...regExps)
refine filter to additionally cover all arguments with a series of regular expressions.
EventMatch & on(const X *const targetObj)
EventMatch & locateEvent(string match)
basic search for a matching "event"
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
void refineSerach_matchArgsRegExp(RExSeq &®ExpSeq, string rendered_regExps)
EventMatch & locate(string match)
basic search function: continue linear lookup over the elements of the EventLog to find a match (subs...
void refineSerach_matchArguments(ArgSeq &&argSeq)
Filter solution_
match predicate evaluator
EventMatch & locateCall(string match)
basic search for some specific function invocation
EventMatch & argPos(size_t idx, ARG const &arg)
refine filter to additionally require match on a specific positional argument
EventMatch & afterEvent(string match)
EventMatch & after(string match)
find a match (substring match) of the given text in an EventLog entry before the current position,...
EventMatch & attrib(string key, string valueMatch)
refine filter to additionally match on a specific attribute
EventMatch & on(string targetID)
refine filter to additionally match the ‘'this’` attribute
EventMatch & key(string key)
refine filter to additionally require the presence an attribute
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
decltype(buildSearchFilter(std::declval< Log const & >())) Filter
EventMatch & afterMatch(string regExp)
void evaluateQuery(string matchSpec, Literal rel="after")
this is actually called after each refinement of the filter and matching conditions.
string lastMatch_
record last match for diagnostics
Lumiera error handling (C++ interface).
Generic functions to build identification schemes.
Evaluation mechanism to apply a sequence of conditions onto a linear search.
An iterator with the ability to switch direction.
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
lib::diff::Record< string > Entry
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
CON collectStr(ELMS const &...elms)
convert a sequence of elements to string
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
bool isnil(lib::time::Duration const &dur)
Special collection to represent object-like data.
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...