Fix `getRunMode` and `whenEmulated`
Clarification and motivation
!920 (merged) added getRunMode
and whenEmulated
to cleveland. Unfortunately, their behaviour is counter-intuitive, and haddock comments are fairly misleading:
Check at runtime whether are we executed against network or in emulation.
"Runtime" here implies that getRunMode
is decided dynamically, i.e. if the scenario is run with clevelandScenarioCaps
for instance, in one test getRunMode
would return NetworkMode
, in another, EmulationMode
.
However, in practice, the result depends solely on the type of the scenario: if it's ClevelandT
, getRunMode
returns NetworkMode
, and for EmulatedT
, respectively EmulationMode
.
In code/cleveland/test/TestSuite/Cleveland/Level.hs
, for instance, getRunMode
always returns NetworkMode
, due to it being executed inside ClevelandT
, which lacks EmulatorImpl
capability.
One way to fix this is to add a new capability, say, RunModeCap
wrapping RunMode
, and pass it explicitly to scenarios from IsTest
instances. Then it will actually work at runtime.
Another, perhaps more straightforward option, is to pass Maybe EmulationImpl
to ClevelandScenario
.
Note: it's better to start on this issue after !993 (merged) is merged.
Acceptance criteria
- The result of
getRunMode
actually depends on where the scenario is being run, and not on its type.