55 using Filter =
decltype( buildSearchFilter (std::declval<Log const&>()) );
58 using RExSeq = std::vector<std::regex>;
64 return [=](Entry
const& entry)
66 return contains (
string(entry), match);
73 std::regex regExp(regExpDef);
74 return [=](Entry
const& entry)
76 return std::regex_search(
string(entry), regExp);
83 return [=](Entry
const& entry)
85 return ( entry.getType() ==
"event"
86 or entry.getType() ==
"error"
87 or entry.getType() ==
"create"
88 or entry.getType() ==
"destroy"
89 or entry.getType() ==
"logJoin"
91 and not isnil(entry.scope())
92 and contains (*entry.scope(), match);
99 return [=](Entry
const& entry)
101 return ( entry.getType() == classifier
102 or (entry.hasAttribute(
"ID") and contains (entry.get(
"ID"), classifier))
104 and not isnil(entry.scope())
105 and contains (*entry.scope(), match);
112 return [=](Entry
const& entry)
114 return entry.getType() ==
"call"
115 and contains (entry.get(
"fun"), match);
131 return [=](Entry
const& entry)
133 auto scope = entry.scope();
134 for (
auto const& match : argSeq)
135 if (isnil (scope) or not contains(*scope, match))
148 return [=](Entry
const& entry)
150 return idx < entry.childSize()
151 and contains (entry.child(idx), match);
168 return [=](Entry
const& entry)
170 auto scope = entry.scope();
171 for (
auto const& rex : regExpSeq)
173 if (isnil (scope))
return false;
174 while (scope and std::regex_search(*scope, rex))
187 return [=](Entry
const& entry)
189 return contains (entry.getType(), typeID);
198 return [=](Entry
const& entry)
200 return entry.hasAttribute(key);
209 return [=](Entry
const& entry)
211 return entry.hasAttribute(key)
212 and contains (entry.get(key), valueMatch);
224 template<
typename COND>
229 solution.search (forward<COND> (searchCond));
231 solution.addStep ([predicate{forward<COND> (searchCond)}, direction]
234 filter.reverse (
BACKWARD == direction);
235 filter.disableFilter();
237 filter.setNewFilter (predicate);
241 template<
typename COND>
245 solution.addStep ([predicate{forward<COND> (additionalCond)}]
248 filter.andFilter (predicate);
259 : solution_{buildSearchFilter (srcSeq)}
260 , lastMatch_{
"HEAD "+ solution_->get(
"this")}
261 , look_for_match_{true}
323 attachNextSerchStep (
solution_, find(match), CURRENT);
334 attachNextSerchStep (
solution_, findRegExp(regExp), CURRENT);
347 attachNextSerchStep (
solution_, findEvent(match), CURRENT);
355 attachNextSerchStep (
solution_, findEvent(classifier,match), CURRENT);
356 evaluateQuery (
"match-event(ID=\""+classifier+
"\", \""+match+
"\")");
367 attachNextSerchStep (
solution_, findCall(match), CURRENT);
386 attachNextSerchStep (
solution_, find(match), FORWARD);
397 attachNextSerchStep (
solution_, findRegExp(regExp), FORWARD);
419 attachNextSerchStep (
solution_, findEvent(match), FORWARD);
427 attachNextSerchStep (
solution_, findEvent(classifier,match), FORWARD);
428 evaluateQuery (
"match-event(ID=\""+classifier+
"\", \""+match+
"\")");
440 attachNextSerchStep (
solution_, findCall(match), FORWARD);
456 attachNextSerchStep (
solution_, find(match), BACKWARD);
464 attachNextSerchStep (
solution_, findRegExp(regExp), BACKWARD);
472 attachNextSerchStep (
solution_, findEvent(match), BACKWARD);
480 attachNextSerchStep (
solution_, findEvent(classifier,match), BACKWARD);
481 evaluateQuery (
"match-event(ID=\""+classifier+
"\", \""+match+
"\")",
"before");
491 attachNextSerchStep (
solution_, findCall(match), BACKWARD);
504 refineSerach (
solution_, matchArgument(idx, match));
515 refineSerach (
solution_, matchArguments(move(argSeq)));
529 refineSerach (
solution_, matchArgsRegExp (move (regExpSeq)));
541 refineSerach (
solution_, matchType(typeID));
563 refineSerach (
solution_, matchAttribute(
key,valueMatch));
574 refineSerach (
solution_, matchAttribute(
"ID",classifier));
585 refineSerach (
solution_, matchAttribute(
"this",targetID));
593 refineSerach (
solution_, matchAttribute(
"this",targetID));
607 log({
"type=EventLogHeader",
"this="+logID});
627 Log& target = *otherLog.
log_;
628 target.reserve (target.size() +
log_->size() + 1);
629 target.emplace_back (
log_->front());
630 auto p =
log_->begin();
631 while (++p !=
log_->end())
632 target.emplace_back (std::move(*p));
633 this->
log_->resize(1);
634 this->
log({
"type=joined", otherLog.
getID()});
635 otherLog.
log({
"type=logJoin", this->
getID()});
645 string originalLogID = this->
getID();
646 return this->
clear (originalLogID);
660 log_.reset (
new Log);
661 log({
"type=EventLogHeader",
"this="+alteredLogID});
668 return clear (
string{alteredLogID});
698 log (
"call",
ArgSeq{
"fun="+function,
"this="+target}, std::forward<ArgSeq>(args));
705 return call (
string(target),
string(function), std::forward<ArgSeq>(args));
712 log({
"type=warn", text});
719 log({
"type=error", text});
726 log({
"type=fatal", text});
735 log({
"type=create", text});
742 log({
"type=destroy", text});
Token or Atom with distinct identity.
Helper to log and verify the occurrence of events.
EventLog & warn(string text)
Log a warning entry.
lib::diff::RecordSetup< string >::Storage ArgSeq
EventLog & destroy(string text)
Log the destruction of an object.
EventLog & event(string text)
log some text as event
EventMatch verify(string match) const
start a query to match for some substring.
EventLog & error(string text)
Log an error note.
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
std::shared_ptr< Log > log_
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)
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
EventLog & fatal(string text)
Log a fatal failure.
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
EventMatch(Log const &srcSeq)
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 & 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 & 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
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).
Support for verifying the occurrence of events from unit tests.
void refineSerach(Filter &solution, COND &&additionalCond)
std::vector< std::regex > RExSeq
auto matchArguments(ArgSeq &&argSeq)
this filter functor is for refinement of an existing filter
lib::diff::RecordSetup< string >::Storage ArgSeq
auto matchArgument(size_t idx, string match)
refinement filter to match a specific positional argument
auto findRegExp(string regExpDef)
auto findCall(string match)
auto ensureAttribute(string key)
refinement filter to ensure a specific attribute is present on the log entry
auto matchType(string typeID)
refinement filter to match on the given typeID
auto matchArgsRegExp(RExSeq &®ExpSeq)
refinement filter, to cover all arguments by regular expression(s)
auto matchAttribute(string key, string valueMatch)
refinement filter to ensure a specific attribute is present on the log entry
decltype(buildSearchFilter(std::declval< Log const & >())) Filter
auto findEvent(string match)
void attachNextSerchStep(Filter &solution, COND &&searchCond, Direction direction)
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
vector< string > stringify(ELMS const &...elms)
standard setup: convert to string into a vector
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
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)