From 161f604cbd0292d68e9ef603b9afdf0508993d9a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 15 Aug 2023 18:52:51 +0200 Subject: [PATCH] Activity-Lang: setup a mocked JobFunctor for diagnostics ...now step by step building up the scaffolding to build and verify Activity terms... --- src/lib/test/event-log.hpp | 4 +- tests/vault/gear/activity-detector-test.cpp | 15 ++++- tests/vault/gear/activity-detector.hpp | 66 +++++++++++++++++--- wiki/thinkPad.ichthyo.mm | 67 +++++++++++++++++++++ 4 files changed, 139 insertions(+), 13 deletions(-) diff --git a/src/lib/test/event-log.hpp b/src/lib/test/event-log.hpp index 5644cc04a..10495b62c 100644 --- a/src/lib/test/event-log.hpp +++ b/src/lib/test/event-log.hpp @@ -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 diff --git a/tests/vault/gear/activity-detector-test.cpp b/tests/vault/gear/activity-detector-test.cpp index 6e6aed734..2bb20f648 100644 --- a/tests/vault/gear/activity-detector-test.cpp +++ b/tests/vault/gear/activity-detector-test.cpp @@ -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)); } diff --git a/tests/vault/gear/activity-detector.hpp b/tests/vault/gear/activity-detector.hpp index 84dda78de..f92a58060 100644 --- a/tests/vault/gear/activity-detector.hpp +++ b/tests/vault/gear/activity-detector.hpp @@ -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 #include #include +#include //#include //#include @@ -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 + struct _DiagnosticFun + { + using Ret = typename lib::meta::_Fun::Ret; + using Args = typename lib::meta::_Fun::Args; + using ArgsX = typename lib::meta::StripNullType::Seq; ////////////////////////////////////TICKET #987 : make lib::meta::Types variadic + using SigTypes = typename lib::meta::Prepend::Seq; + + using Type = typename RebindVariadic::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::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 mockOps_{}; + public: ActivityDetector(string id ="") @@ -327,19 +377,15 @@ namespace test { auto buildDiagnosticFun (string id) { - using Ret = typename lib::meta::_Fun::Ret; - using Args = typename lib::meta::_Fun::Args; - using ArgsX = typename lib::meta::StripNullType::Seq; ////////////////////////////////////TICKET #987 : make lib::meta::Types variadic - using SigTypes = typename lib::meta::Prepend::Seq; - using Functor = typename RebindVariadic::Type; - + using Functor = typename _DiagnosticFun::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 (id)); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index b545e0b19..fc7483c79 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -81676,6 +81676,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + @@ -82026,6 +82036,63 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ es ist noch gar nicht klar, was für Verifikationen wirklich benötigt werden +

+ +
+ +
+ + + + +

+ möglicherweise geht es hier vornehmlich um die Aktiviertung  (den Fakt des Aufrufs) +

+ +
+ +
+ + + + + + + + +