| 26 | } |
| 27 | |
| 28 | void runnable::run() { |
| 29 | current_runnable = this; |
| 30 | auto guard |
| 31 | = detail::scope_guard{[]() noexcept { current_runnable = nullptr; }}; |
| 32 | switch (root_type_) { |
| 33 | case block_type::outline: |
| 34 | if (auto guard = ctx_->get<outline>(0, description_, loc_)->commit()) { |
| 35 | do_run(); |
| 36 | return; |
| 37 | } |
| 38 | CAF_RAISE_ERROR(std::logic_error, |
| 39 | "failed to select the root block for the outline"); |
| 40 | break; |
| 41 | case block_type::scenario: |
| 42 | if (auto guard = ctx_->get<scenario>(0, description_, loc_)->commit()) { |
| 43 | do_run(); |
| 44 | return; |
| 45 | } |
| 46 | CAF_RAISE_ERROR(std::logic_error, |
| 47 | "failed to select the root block for the scenario"); |
| 48 | break; |
| 49 | case block_type::test: |
| 50 | if (auto guard = ctx_->get<test>(0, description_, loc_)->commit()) { |
| 51 | do_run(); |
| 52 | return; |
| 53 | } |
| 54 | CAF_RAISE_ERROR(std::logic_error, |
| 55 | "failed to select the root block for the test"); |
| 56 | break; |
| 57 | default: |
| 58 | CAF_RAISE_ERROR(std::logic_error, "invalid root type"); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void runnable::call_do_run() { |
| 63 | current_runnable = this; |