class TF::OutputMatchTest

Constants

MATCHER

Public Instance Methods

execute(test, _stdout, _stderr, _stdboth, _status, env) click to toggle source
# File lib/plugins/tf/output_match_test.rb, line 8
def execute test, _stdout, _stderr, _stdboth, _status, env
  test =~ TF::OutputMatchTest::MATCHER
  _, type, sign, value = $1, $2, $3, $4
  test_val, match_type =
    case type
    when "stdout" then [ _stdout, "[#{type}]" ]
    when "stderr" then [ _stderr, "[#{type}]" ]
    when nil      then [ _stdboth, "" ]
    else return [ false, "failed: match[#{type}] #{sign} /#{value}/ # unknown output type" ]
    end
  if ( sign == "=" ) ^ ( Regexp.new(value) =~ "#{test_val}" )
    [ false, "failed: match#{match_type} #{sign} /#{value}/" ]
  else
    [ true, "passed: match#{match_type} #{sign} /#{value}/" ]
  end
end
matches?(test) click to toggle source
# File lib/plugins/tf/output_match_test.rb, line 4
def matches? test
  test =~ TF::OutputMatchTest::MATCHER
end