Skip to content

Commit e3e9f72

Browse files
committed
Merge branch 'fix/run_this_state_unit_test' into 'develop'
fix: run this state unit test See merge request dev/sys/tci/rafcon!85
2 parents 9fee0ca + b5fbc3b commit e3e9f72

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"creation_time": "2021-11-22 14:35:11",
3-
"last_update": "2021-11-22 15:49:02",
43
"root_state_storage_id": "test_run_this_state_BTWFZQ",
54
"state_machine_version": null,
6-
"used_rafcon_version": "0.14.9"
5+
"used_rafcon_version": "1.0.0"
76
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
def execute(self, inputs, outputs, gvm):
22
self.logger.info("Hello {}".format(self.name))
33
gvm.set_variable("test_value", 2)
4+
self.logger.info(gvm.get_variable("test_value"))
45
return "success"

tests/core/test_run_selected_state.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
2-
import time
3-
2+
import threading
43
# core elements
54
from rafcon.core.states.state import StateExecutionStatus
65

76
from rafcon.core.storage import storage
87
import rafcon.core.singleton
98
from rafcon.core.singleton import state_machine_execution_engine
9+
from tests.utils import wait_for_execution_engine_sync_counter
1010
from rafcon.utils import log
1111

1212
# test environment elements
@@ -23,19 +23,12 @@ def test_run_this_state(caplog):
2323
sm = storage.load_state_machine_from_path(testing_utils.get_test_sm_path(os.path.join(
2424
"unit_test_state_machines", "test_run_this_state")))
2525
rafcon.core.singleton.state_machine_manager.add_state_machine(sm)
26-
# Set state machine as active state machine
27-
# rafcon.core.singleton.state_machine_manager.active_state_machine_id = state_machine.state_machine_id
2826
# Run selected state machine
27+
rafcon.core.singleton.global_variable_manager.set_variable("test_value", 1)
2928
state_machine_execution_engine.run_selected_state("BTWFZQ/EPQSTG", sm.state_machine_id)
30-
timeout = time.time()
31-
while not sm.get_state_by_path("BTWFZQ/EPQSTG").state_execution_status is StateExecutionStatus.WAIT_FOR_NEXT_STATE:
32-
time.sleep(.05)
33-
if time.time()-timeout > 2:
34-
raise RuntimeError("execution_state EPQSTG didn't run --> timeout")
35-
# Stop execution engine
29+
wait_for_execution_engine_sync_counter(1, logger)
3630
state_machine_execution_engine.stop()
3731
rafcon.core.singleton.state_machine_execution_engine.join()
38-
3932
# assert variable state
4033
try:
4134
assert rafcon.core.singleton.global_variable_manager.get_variable("test_value") == 2

0 commit comments

Comments
 (0)