Module: Tryouts::ClassMethods

Included in:
Tryouts
Defined in:
lib/tryouts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#casesObject (readonly)

Returns the value of attribute cases.



28
29
30
# File 'lib/tryouts.rb', line 28

def cases
  @cases
end

#containerObject

Returns the value of attribute container.



26
27
28
# File 'lib/tryouts.rb', line 26

def container
  @container
end

#debug(msg, indent: 0) ⇒ Object



49
50
51
52
53
54
# File 'lib/tryouts.rb', line 49

def debug(msg, indent: 0)
  return unless debug?

  prefix = ('  ' * indent) + Console.color(:cyan, 'DEBUG')
  warn "#{prefix} #{msg}"
end

#failsObject

Returns the value of attribute fails.



26
27
28
# File 'lib/tryouts.rb', line 26

def fails
  @fails
end

#noisyObject

Returns the value of attribute noisy.



26
27
28
# File 'lib/tryouts.rb', line 26

def noisy
  @noisy
end

#quietObject

Returns the value of attribute quiet.



26
27
28
# File 'lib/tryouts.rb', line 26

def quiet
  @quiet
end

#stack_traces=(value) ⇒ Object (writeonly)

Sets the attribute stack_traces

Parameters:

  • value

    the value to set the attribute stack_traces to.



27
28
29
# File 'lib/tryouts.rb', line 27

def stack_traces=(value)
  @stack_traces = value
end

#testcase_ioObject (readonly)

Returns the value of attribute testcase_io.



28
29
30
# File 'lib/tryouts.rb', line 28

def testcase_io
  @testcase_io
end

Instance Method Details

#batch_stopping_error?(exception) ⇒ Boolean

Determine if an error should stop batch execution

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/tryouts.rb', line 79

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



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tryouts.rb', line 57

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/tryouts.rb', line 30

def debug?
  @debug == true
end

#stack_traces?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/tryouts.rb', line 34

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

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/tryouts.rb', line 85

def test_stopping_error?(exception)
  classification = classify_error(exception)
  [:non_recoverable_exit, :system_resource].include?(classification)
end

#trace(msg, indent: 0) ⇒ Object



42
43
44
45
46
47
# File 'lib/tryouts.rb', line 42

def trace(msg, indent: 0)
  return unless debug?

  prefix = ('  ' * indent) + Console.color(:dim, 'TRACE')
  warn "#{prefix} #{msg}"
end

#update_load_path(lib_glob) ⇒ Object



38
39
40
# File 'lib/tryouts.rb', line 38

def update_load_path(lib_glob)
  Dir.glob(lib_glob).each { |dir| $LOAD_PATH.unshift(dir) }
end