Class: TF
- Inherits:
-
Object
- Object
- TF
- Defined in:
- lib/tf.rb,
lib/tf.rb
Defined Under Namespace
Classes: CommentTestInput, EnvArrTest, EnvMatchTest, EnvTypeTest, Environment, ErrorSummaryOutput, OutputMatchTest, Plugins, StatsOutput, StatusTest, TextOutput
Instance Method Summary collapse
- #env(shell) ⇒ Object
-
#initialize ⇒ TF
constructor
A new instance of TF.
- #process(input_files) ⇒ Object
- #process_command_tests(_stdout, _stderr, _stdboth, _status, env, tests) ⇒ Object
- #process_test(test) ⇒ Object
- #run_tests(args) ⇒ Object
Constructor Details
Instance Method Details
#env(shell) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/tf.rb', line 42 def env shell TF::Environment.parse_env( shell.execute( TF::Environment.show_env_command )[0].split(/\n/) ) end |
#process(input_files) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/tf.rb', line 34 def process input_files @plugins.output_plugins(:start_processing) input_files.each do |plugin,file| process_test( plugin.load(file) ) end @plugins.output_plugins(:end_processing) end |
#process_command_tests(_stdout, _stderr, _stdboth, _status, env, tests) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/tf.rb', line 81 def process_command_tests _stdout, _stderr, _stdboth, _status, env, tests tests.each do |test| plugin = @plugins.test_plugins.find{|_plugin| _plugin.matches? test } if plugin.nil? status, msg = false, "Could not find plugin for test '#{test}'." else status, msg = plugin.execute(test, _stdout, _stderr, _stdboth, _status, env) end @failures+=1 unless status @plugins.output_plugins(:test_processed, test, status, msg) end end |
#process_test(test) ⇒ Object
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 76 77 78 79 |
# File 'lib/tf.rb', line 50 def process_test test name, commands, execution_shell = test[:name], test[:commands], test[:shell] shell = Session::Sh.new(:prog => execution_shell) _env = env(shell) @plugins.output_plugins(:start_test, test, _env) commands.each do |line| command, tests = line[:cmd], line[:tests] @plugins.output_plugins(:start_command, line) _stdout = StringIO.new _stderr = StringIO.new _stdboth = StringIO.new shell.execute "#{command}" do |out, err| if out @plugins.output_plugins(:command_out, out) _stdout << out _stdboth << out end if err @plugins.output_plugins(:command_err, err) _stderr << err _stdboth << err end end _status = shell.status _env = env(shell) @plugins.output_plugins(:end_command, line, _status, _env) process_command_tests _stdout.string, _stderr.string, _stdboth.string, _status, _env, tests end @plugins.output_plugins(:end_test, test) end |
#run_tests(args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tf.rb', line 22 def run_tests args @plugins.load(%w( all_test )) input_files, not_processed = @plugins.parse_args(args) if not_processed.size > 0 $stderr.puts "No plugin recognized this option '#{not_processed*" "}'." exit 1 end @plugins.load(%w( ErrorSummaryOutput )) if @plugins.output_plugins.empty? process(input_files) @failures == 0 end |