Module: Tryouts::ClassMethods
- Included in:
- Tryouts
- Defined in:
- lib/tryouts.rb
Instance Attribute Summary collapse
-
#cases ⇒ Object
readonly
Returns the value of attribute cases.
-
#container ⇒ Object
Returns the value of attribute container.
- #debug(msg, indent: 0) ⇒ Object
-
#fails ⇒ Object
Returns the value of attribute fails.
-
#noisy ⇒ Object
Returns the value of attribute noisy.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#stack_traces ⇒ Object
writeonly
Sets the attribute stack_traces.
-
#testcase_io ⇒ Object
readonly
Returns the value of attribute testcase_io.
Instance Method Summary collapse
-
#batch_stopping_error?(exception) ⇒ Boolean
Determine if an error should stop batch execution.
-
#classify_error(exception) ⇒ Object
Error classification for resilient error handling.
- #debug? ⇒ Boolean
- #stack_traces? ⇒ Boolean
-
#test_stopping_error?(exception) ⇒ Boolean
Determine if an error should stop individual test execution.
- #trace(msg, indent: 0) ⇒ Object
- #update_load_path(lib_glob) ⇒ Object
Instance Attribute Details
#cases ⇒ Object (readonly)
Returns the value of attribute cases.
27 28 29 |
# File 'lib/tryouts.rb', line 27 def cases @cases end |
#container ⇒ Object
Returns the value of attribute container.
25 26 27 |
# File 'lib/tryouts.rb', line 25 def container @container end |
#debug(msg, indent: 0) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/tryouts.rb', line 48 def debug(msg, indent: 0) return unless debug? prefix = (' ' * indent) + Console.color(:cyan, 'DEBUG') warn "#{prefix} #{msg}" end |
#fails ⇒ Object
Returns the value of attribute fails.
25 26 27 |
# File 'lib/tryouts.rb', line 25 def fails @fails end |
#noisy ⇒ Object
Returns the value of attribute noisy.
25 26 27 |
# File 'lib/tryouts.rb', line 25 def noisy @noisy end |
#quiet ⇒ Object
Returns the value of attribute quiet.
25 26 27 |
# File 'lib/tryouts.rb', line 25 def quiet @quiet end |
#stack_traces=(value) ⇒ Object (writeonly)
Sets the attribute stack_traces
26 27 28 |
# File 'lib/tryouts.rb', line 26 def stack_traces=(value) @stack_traces = value end |
#testcase_io ⇒ Object (readonly)
Returns the value of attribute testcase_io.
27 28 29 |
# File 'lib/tryouts.rb', line 27 def testcase_io @testcase_io end |
Instance Method Details
#batch_stopping_error?(exception) ⇒ Boolean
Determine if an error should stop batch execution
78 79 80 81 |
# File 'lib/tryouts.rb', line 78 def batch_stopping_error?(exception) classification = classify_error(exception) [:non_recoverable_exit, :system_resource, :syntax].include?(classification) end |
#classify_error(exception) ⇒ Object
Error classification for resilient error handling
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tryouts.rb', line 56 def classify_error(exception) case exception when SystemExit, SignalException :non_recoverable_exit when Timeout::Error :transient when Errno::ENOENT, Errno::EACCES, Errno::EPERM :file_system when LoadError, NameError, NoMethodError :code_structure when SecurityError, NoMemoryError, SystemStackError :system_resource when SyntaxError, TryoutSyntaxError :syntax when StandardError :recoverable else :unknown end end |
#debug? ⇒ Boolean
29 30 31 |
# File 'lib/tryouts.rb', line 29 def debug? @debug == true end |
#stack_traces? ⇒ Boolean
33 34 35 |
# File 'lib/tryouts.rb', line 33 def stack_traces? @stack_traces == true || debug? # Debug mode auto-enables stack traces end |
#test_stopping_error?(exception) ⇒ Boolean
Determine if an error should stop individual test execution
84 85 86 87 |
# File 'lib/tryouts.rb', line 84 def test_stopping_error?(exception) classification = classify_error(exception) [:non_recoverable_exit, :system_resource].include?(classification) end |
#trace(msg, indent: 0) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/tryouts.rb', line 41 def trace(msg, indent: 0) return unless debug? prefix = (' ' * indent) + Console.color(:dim, 'TRACE') warn "#{prefix} #{msg}" end |
#update_load_path(lib_glob) ⇒ Object
37 38 39 |
# File 'lib/tryouts.rb', line 37 def update_load_path(lib_glob) Dir.glob(lib_glob).each { |dir| $LOAD_PATH.unshift(dir) } end |