Activity-Lang: setup a mocked JobFunctor for diagnostics
...now step by step building up the scaffolding to build and verify Activity terms...
This commit is contained in:
parent
ab7f506f4b
commit
161f604cbd
4 changed files with 139 additions and 13 deletions
|
|
@ -67,7 +67,8 @@
|
|||
** combined with changed search direction, might lead to backtracking, which
|
||||
** happens silently within the search engine, without printing any further
|
||||
** diagnostics. This means: the sequence of matches you see in this diagnostic
|
||||
** output is not necessarily the last match patch, which lead to the final failure
|
||||
** output is not necessarily the last match path, which leads to final failure
|
||||
** @warning as such EventLog is deliberately _not threadsafe_
|
||||
**
|
||||
** @see EventLog_test
|
||||
** @see [usage example](\ref AbstractTangible_test)
|
||||
|
|
@ -268,6 +269,7 @@ namespace test{
|
|||
* [information records](\ref lib::Record) into a possibly shared (vector)
|
||||
* buffer in heap storage. An extended query DSL allows to write
|
||||
* assertions to cover the occurrence of events in unit tests.
|
||||
* @warning not threadsafe
|
||||
* @see EventLog_test
|
||||
*/
|
||||
class EventLog
|
||||
|
|
|
|||
|
|
@ -143,13 +143,24 @@ namespace test {
|
|||
|
||||
|
||||
/** @test TODO diagnostic setup to detect a JobFunctor activation
|
||||
* @todo WIP 7/23 🔁 define ⟶ implement
|
||||
* @todo WIP 7/23 🔁 define 🔁 implement
|
||||
*/
|
||||
void
|
||||
verifyMockJobFunctor()
|
||||
{
|
||||
ActivityDetector detector;
|
||||
JobFunctor& mockFunctor = detector.buildMockJobFunctor ("mockJob");
|
||||
InvocationInstanceID invoKey;
|
||||
TimeVar nominal{FSecs{5,2}};
|
||||
invoKey.part.a = 55;
|
||||
|
||||
Job dummyJob{detector.buildMockJobFunctor ("mockJob")
|
||||
,invoKey
|
||||
,nominal};
|
||||
|
||||
CHECK (detector.ensureNoInvocation ("mockJob"));
|
||||
dummyJob.triggerJob();
|
||||
CHECK (detector.verifyInvocation ("mockJob"));
|
||||
CHECK (detector.verifyInvocation ("mockJob").arg(nominal, invoKey.part.a));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,12 +73,14 @@
|
|||
//#include "steam/engine/job-ticket.hpp"
|
||||
#include "vault/gear/job.h"
|
||||
#include "vault/gear/activity.hpp"
|
||||
#include "vault/gear/nop-job-functor.hpp"
|
||||
//#include "vault/real-clock.hpp"
|
||||
//#include "lib/allocator-handle.hpp"
|
||||
//#include "lib/time/timevalue.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
//#include "lib/diff/gen-node.hpp"
|
||||
//#include "lib/linked-elements.hpp"
|
||||
#include "lib/meta/variadic-helper.hpp"
|
||||
#include "lib/meta/function.hpp"
|
||||
#include "lib/wrapper.hpp"
|
||||
#include "lib/format-cout.hpp"
|
||||
#include "lib/format-util.hpp"
|
||||
|
|
@ -89,6 +91,7 @@
|
|||
#include <functional>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
//#include <tuple>
|
||||
//#include <map>
|
||||
|
||||
|
|
@ -101,7 +104,7 @@ namespace test {
|
|||
// using std::make_tuple;
|
||||
// using lib::diff::GenNode;
|
||||
// using lib::diff::MakeRec;
|
||||
// using lib::time::TimeValue;
|
||||
using lib::time::TimeValue;
|
||||
// using lib::time::Time;
|
||||
// using lib::HashVal;
|
||||
using lib::meta::RebindVariadic;
|
||||
|
|
@ -271,6 +274,53 @@ namespace test {
|
|||
}
|
||||
};
|
||||
|
||||
/** @internal type rebinding helper */
|
||||
template<typename SIG>
|
||||
struct _DiagnosticFun
|
||||
{
|
||||
using Ret = typename lib::meta::_Fun<SIG>::Ret;
|
||||
using Args = typename lib::meta::_Fun<SIG>::Args;
|
||||
using ArgsX = typename lib::meta::StripNullType<Args>::Seq; ////////////////////////////////////TICKET #987 : make lib::meta::Types<TYPES...> variadic
|
||||
using SigTypes = typename lib::meta::Prepend<Ret, ArgsX>::Seq;
|
||||
|
||||
using Type = typename RebindVariadic<DiagnosticFun, SigTypes>::Type;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A Mocked job operation to detect any actual invocation
|
||||
*/
|
||||
class MockJobFunctor
|
||||
: public NopJobFunctor
|
||||
{
|
||||
public:
|
||||
using SIG_Diagnostic = void(TimeValue, int32_t);
|
||||
|
||||
private:
|
||||
using MockOp = typename _DiagnosticFun<SIG_Diagnostic>::Type;
|
||||
|
||||
MockOp mockOperation_;
|
||||
|
||||
/** rigged diagnostic implementation of job invocation
|
||||
* @note only data relevant for diagnostics is explicitly unpacked
|
||||
*/
|
||||
void
|
||||
invokeJobOperation (JobParameter param) override
|
||||
{
|
||||
mockOperation_(TimeValue{param.nominalTime}, param.invoKey.part.a);
|
||||
}
|
||||
|
||||
public:
|
||||
MockJobFunctor (MockOp mockedJobOperation)
|
||||
: mockOperation_{move (mockedJobOperation)}
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
/* ===== Maintain throw-away mock instances ===== */
|
||||
|
||||
std::deque<MockJobFunctor> mockOps_{};
|
||||
|
||||
|
||||
public:
|
||||
ActivityDetector(string id ="")
|
||||
|
|
@ -327,19 +377,15 @@ namespace test {
|
|||
auto
|
||||
buildDiagnosticFun (string id)
|
||||
{
|
||||
using Ret = typename lib::meta::_Fun<SIG>::Ret;
|
||||
using Args = typename lib::meta::_Fun<SIG>::Args;
|
||||
using ArgsX = typename lib::meta::StripNullType<Args>::Seq; ////////////////////////////////////TICKET #987 : make lib::meta::Types<TYPES...> variadic
|
||||
using SigTypes = typename lib::meta::Prepend<Ret, ArgsX>::Seq;
|
||||
using Functor = typename RebindVariadic<DiagnosticFun, SigTypes>::Type;
|
||||
|
||||
using Functor = typename _DiagnosticFun<SIG>::Type;
|
||||
return Functor{id, eventLog_, invocationSeq_};
|
||||
}
|
||||
|
||||
JobFunctor& ///////////////////////////////////////////////////////////////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
|
||||
JobClosure& ///////////////////////////////////////////////////////////////////TICKET #1287 : fix actual interface down to JobFunctor (after removing C structs)
|
||||
buildMockJobFunctor (string id)
|
||||
{
|
||||
UNIMPLEMENTED ("build a rigged JobFunctor");
|
||||
return mockOps_.emplace_back (
|
||||
buildDiagnosticFun<MockJobFunctor::SIG_Diagnostic> (id));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81676,6 +81676,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1692112779077" ID="ID_1951273297" MODIFIED="1692112792063" TEXT="Problem: Concurrency">
|
||||
<icon BUILTIN="clanbomber"/>
|
||||
<node CREATED="1692113039211" ID="ID_391962293" MODIFIED="1692113055969" TEXT="EventLog selber ist nicht thread-safe">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1692113057144" ID="ID_1824651097" MODIFIED="1692113101542" TEXT="wird der ActivityDetector jemals (wirklich) concurrent eingesetzt?">
|
||||
<icon BUILTIN="help"/>
|
||||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1690832398754" ID="ID_864386000" MODIFIED="1690832423318" TEXT="logging mock-λ">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
|
|
@ -82026,6 +82036,63 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205105640" ID="ID_1975472338" MODIFIED="1689205112281" TEXT="Dummy-Funktor">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#435e98" CREATED="1692114609799" ID="ID_742671204" MODIFIED="1692114749800" TEXT="was wird erzeugt?">
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1692114616486" ID="ID_1022358077" MODIFIED="1692114650342" TEXT="eine (opaque) JobFunctor-Subklasse"/>
|
||||
<node CREATED="1692114630221" ID="ID_827680196" MODIFIED="1692114643823" TEXT="wird vom ActivitiyDetector selber gemanaged"/>
|
||||
<node CREATED="1692114652402" ID="ID_1621166525" MODIFIED="1692114714280" TEXT="überschreiben: invokeJobOperation (JobParameter)"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692114723724" ID="ID_944641822" MODIFIED="1692114743688" TEXT="Zusatz-Verifikationen ermöglichen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1692114853703" ID="ID_1214470182" MODIFIED="1692114856906" TEXT="Parameter">
|
||||
<node CREATED="1692114757875" ID="ID_912452095" MODIFIED="1692114765987" TEXT="nominalTime"/>
|
||||
<node CREATED="1692114766498" ID="ID_266252168" MODIFIED="1692114771333" TEXT="invocation Key"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692114860699" ID="ID_568488214" MODIFIED="1692114887859" TEXT="Problem: Daten-Transport">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1692114909759" ID="ID_162471010" MODIFIED="1692114928969" TEXT="es handelt sich um erweiterte/Binärdaten">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
<node CREATED="1692114932716" ID="ID_309749065" MODIFIED="1692114949959" TEXT="das EventLog speichert nur strukturierte String-Daten">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
<node CREATED="1692115003218" ID="ID_92426865" MODIFIED="1692115008839" TEXT="Zielkonflikt">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1692115010609" ID="ID_414253" MODIFIED="1692115037594" TEXT="einerseits möchte man vielleicht Details der Invocation verifizieren"/>
|
||||
<node CREATED="1692115038374" ID="ID_1340918241" MODIFIED="1692115057190" TEXT="andererseits sollte das Log deterministisch (und lesbar) bleiben"/>
|
||||
</node>
|
||||
<node CREATED="1692115565175" ID="ID_463899224" MODIFIED="1692115568162" TEXT="Diskussion">
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1692115571524" ID="ID_1480451155" MODIFIED="1692115601676" TEXT="erst mal: nicht übertreiben!">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
es ist noch gar nicht klar, was für Verifikationen wirklich benötigt werden
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
<node CREATED="1692115619927" ID="ID_762317180" MODIFIED="1692115660252">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
<p>
|
||||
möglicherweise geht es hier vornehmlich um die <i>Aktiviertung</i>  (den Fakt des Aufrufs)
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1692115687686" ID="ID_1583315521" MODIFIED="1692115699528" TEXT="die durchgereichten Details gehören eigentlich in einen anderen Kontext"/>
|
||||
<node CREATED="1692115721920" ID="ID_708587276" MODIFIED="1692115735755" TEXT="das Call-Logging macht automatisch ein "stringify""/>
|
||||
<node CREATED="1692115836588" ID="ID_187385293" MODIFIED="1692115866482" TEXT="⟹ erst mal nur interessante Daten „auspacken“">
|
||||
<node CREATED="1692117979649" ID="ID_682909910" MODIFIED="1692117982662" TEXT="nominal time"/>
|
||||
<node CREATED="1692117983371" ID="ID_183365467" MODIFIED="1692117995525" TEXT="»part.a« vom Invocation Key"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205129709" ID="ID_355308944" MODIFIED="1689205163520" TEXT="Invocation-Activity">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue