Ejemplo n.º 1
0
def setup_function(_):
    # set the test_libraries path temporarily to the correct value
    global_config.set_config_value("LIBRARY_RECOVERY_MODE", True)
    testing_utils.rewind_and_set_libraries({
        "unit_test_state_machines":
        join(testing_utils.TEST_ASSETS_PATH, "unit_test_state_machines")
    })
Ejemplo n.º 2
0
def setup_module(module=None):
    # set the test_libraries path temporarily to the correct value
    testing_utils.test_multithreading_lock.acquire()
    testing_utils.rewind_and_set_libraries({
        "unit_test_state_machines":
        testing_utils.get_test_sm_path("unit_test_state_machines")
    })
    logger.debug(
        rafcon.core.config.global_config.get_config_value("LIBRARY_PATHS")
        ["unit_test_state_machines"])
Ejemplo n.º 3
0
def setup_module(module=None):
    # set the test_libraries path temporarily to the correct value
    testing_utils.rewind_and_set_libraries(
        {"temporary_libraries": TEST_LIBRARY_PATH})
Ejemplo n.º 4
0
def test_step_through_library(caplog):

    testing_utils.initialize_environment_core()

    testing_utils.rewind_and_set_libraries({
        "unit_test_state_machines":
        os.path.join(testing_utils.TEST_ASSETS_PATH,
                     "unit_test_state_machines")
    })

    state_machine = storage.load_state_machine_from_path(
        testing_utils.get_test_sm_path(
            os.path.join("unit_test_state_machines",
                         "stepping_test_with_library")))

    rafcon.core.singleton.state_machine_manager.add_state_machine(
        state_machine)
    rafcon.core.singleton.state_machine_manager.active_state_machine_id = state_machine.state_machine_id

    state_machine_execution_engine.synchronization_lock.acquire()
    state_machine_execution_engine.synchronization_counter = 0
    state_machine_execution_engine.synchronization_lock.release()

    rafcon.core.singleton.state_machine_execution_engine.step_mode()
    wait_for_execution_engine_sync_counter(1, logger)

    # step till library
    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    # step into library and step out
    rafcon.core.singleton.state_machine_execution_engine.step_into()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_out()
    wait_for_execution_engine_sync_counter(2, logger)

    # step till library
    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    # step into library and step over library children
    rafcon.core.singleton.state_machine_execution_engine.step_into()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    # step over last library item
    rafcon.core.singleton.state_machine_execution_engine.step_over()
    wait_for_execution_engine_sync_counter(1, logger)

    rafcon.core.singleton.state_machine_execution_engine.stop()
    rafcon.core.singleton.state_machine_execution_engine.join()

    try:
        from rafcon.core.state_elements.scope import ScopedVariable
        for s in state_machine.root_state.scoped_data.itervalues():
            if s.name == 'bottles' and s.data_port_type == ScopedVariable:
                assert s.value == 4
    finally:
        testing_utils.shutdown_environment_only_core(caplog=caplog)