Module: Roby::Test::Self
- Includes:
- Roby::Test, Assertions, RunPlanners
- Included in:
- Minitest::Test
- Defined in:
- lib/roby/test/self.rb
Overview
This module is extending Test to be able to run tests using the normal testrb command. It is meant to be used to test libraries (e.g. Roby itself) as, in complex Roby applications, the setup and teardown steps would be very expensive.
Constant Summary
Constants included from Roby::Test
BASE_PORT, DISCOVERY_SERVER, LOCAL_PORT, LOCAL_SERVER, REMOTE_PORT, REMOTE_SERVER
Constants included from ExpectExecution
ExpectExecution::SETUP_METHODS
Constants included from Roby
BIN_DIR, Conf, FORMAT_EXCEPTION_RECURSION_GUARD_KEY, LOG_SYMBOLIC_TO_NUMERIC, NullTask, ROBY_LIB_DIR, ROBY_ROOT_DIR, RX_IN_FRAMEWORK, RX_IN_METARUBY, RX_IN_UTILRB, RX_REQUIRE, SelfTest, State, Roby::TaskService, VERSION, VirtualTask, Void, VoidClass
Instance Attribute Summary
Attributes included from Roby::Test
#app, #control, #original_collections, #plan, #remote_processes
Attributes included from TeardownPlans
#registered_plans, #teardown_fail, #teardown_force, #teardown_poll, #teardown_warn
Attributes included from ExpectExecution
#expect_execution_default_timeout
Instance Method Summary collapse
- #enable_event_reporting(*filters) ⇒ Object
-
#make_tmpdir ⇒ String
Create a temporary directory.
-
#make_tmppath ⇒ Pathname
Create a temporary directory.
- #setup ⇒ Object
- #teardown ⇒ Object
Methods included from RunPlanners
deregister_planning_handler, planner_handler_for, roby_plan_with, #run_planners, setup_planning_handlers
Methods included from Assertions
#__capture_log, #assert_adds_error, #assert_adds_framework_error, #assert_child_of, #assert_droby_compatible, #assert_event_becomes_unreachable, #assert_event_command_failed, #assert_event_emission, #assert_event_emission_failed, #assert_event_exception, #assert_event_is_unreachable, #assert_exception_can_be_pretty_printed, #assert_fatal_exception, #assert_free_event_command_failed, #assert_free_event_emission_failed, #assert_free_event_exception, #assert_free_event_exception_warning, #assert_handled_exception, #assert_logs_event, #assert_logs_exception_with_backtrace, #assert_nonfatal_exception, #assert_notifies_free_event_exception, #assert_pp, #assert_relative_error, #assert_same_position, #assert_sets_equal, #assert_state_machine_transition, #assert_task_fails_to_start, #assert_task_quarantined, #capture_log, #create_exception_matcher, #droby_local_marshaller, #droby_remote_marshaller, #droby_to_remote, #droby_transfer, #find_state_machine_capture, #refute_child_of, #roby_make_flexmock_exception_matcher, #roby_normalize_exception_message, #run_state_machine_capture, #validate_state_machine
Methods included from Roby::Test
#create_transaction, #deprecated_feature, #execution_engine, #flexmock_call_original, #flexmock_invoke_original, #inhibit_fatal_messages, #make_random_plan, #new_plan, #prepare_plan, #process_events, #process_events_until, register_spec_type, #remote_process, #reset_log_levels, #restore_collections, sampling, #save_collection, self_test=, self_test?, #set_log_level, stats, #stop_remote_processes, #with_log_level
Methods included from TeardownPlans
#clear_registered_plans, #initialize, #register_plan, #teardown_clear, #teardown_forced_killall, #teardown_killall, #teardown_registered_plans, #teardown_show_plan_state_if_changed
Methods included from ExpectExecution
#add_expectations, #execute, #execute_one_cycle, #expect_execution, #reset_current_expect_execution, #setup_current_expect_execution
Methods included from Roby
RelationSpace, app, color, control, control=, disable_colors, display_exception, disposable, do_display_exception, do_display_exception_formatted, do_display_exception_raw, each_cycle, enable_colors, enable_colors_if_available, engine, error_deprecated, every, execute, execution_engine, filter_backtrace, find_in_path, flatten_exception, format, format_backtrace, format_exception, format_exception_recursion_guard, format_one_exception, format_time, from, from_conf, from_state, inside_control?, log_all_threads_backtraces, log_backtrace, log_callers, log_error, log_exception, log_exception_with_backtrace, log_level_enabled?, log_pp, make_backtrace_relative_to_app_dir, monotonic_time, null_disposable, on_exception, once, outside_control?, plan, poll_state_events, pretty_print_backtrace, sanitize_keywords, sanitize_keywords_to_array, sanitize_keywords_to_hash, scheduler, scheduler=, wait_one_cycle, wait_until, warn_deprecated, which
Instance Method Details
#enable_event_reporting(*filters) ⇒ Object
77 78 79 80 |
# File 'lib/roby/test/self.rb', line 77 def enable_event_reporting(*filters) @event_reporter.enabled = true filters.each { |f| @event_reporter.filter(f) } end |
#make_tmpdir ⇒ String
Create a temporary directory
The directory is removed on test teardown. Unlike #make_tmppath, this returns a string. Prefer #make_tmppath
121 122 123 124 |
# File 'lib/roby/test/self.rb', line 121 def make_tmpdir @temp_dirs << (dir = Dir.mktmpdir) dir end |
#make_tmppath ⇒ Pathname
Create a temporary directory
The directory is removed on test teardown. Unlike #make_tmpdir, this returns a Pathname. Prefer this method over #make_tmpdir
110 111 112 113 |
# File 'lib/roby/test/self.rb', line 110 def make_tmppath @temp_dirs << (dir = Dir.mktmpdir) Pathname.new(dir) end |
#setup ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/roby/test/self.rb', line 47 def setup @temp_dirs = [] Roby.app.log["server"] = false Roby.app.auto_load_models = false Roby.app.plugins_enabled = false Roby.app.testing = true Roby.app.public_logs = false Roby.app.log_base_dir = make_tmpdir Roby.app.reset_log_dir Roby.app.setup Roby.app.prepare @plan = ExecutablePlan.new @event_reporter = EventReporter.new(STDOUT) @plan.event_logger.add(@event_reporter) @plan.execution_engine.event_logger.add(@event_reporter) @control = DecisionControl.new Roby.app.reset_plan(@plan) super # Save and restore some arrays save_collection Roby::ExecutionEngine.propagation_handlers save_collection Roby::ExecutionEngine.external_events_handlers save_collection Roby::Plan.structure_checks Roby.app.abort_on_exception = false Roby.app.abort_on_application_exception = true end |
#teardown ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/roby/test/self.rb', line 82 def teardown begin super rescue Exception => e teardown_failure = e end execution_engine&.shutdown Roby.app.shutdown Roby.app.cleanup Roby.app.argv_set.clear State.clear State.clear_model Conf.clear Conf.clear_model @temp_dirs.each { |p| FileUtils.rm_rf(p) } ensure if teardown_failure raise teardown_failure end end |