bin/testr in testr-14.1.3 vs bin/testr in testr-14.2.0

- old
+ new

@@ -1,37 +1,30 @@ #!/usr/bin/env ruby =begin -TESTR 1 "2012-01-13" "14.1.3" +TESTR 1 "2012-01-16" "14.2.0" ============================= NAME ---- testr - Continuous testing tool for Ruby SYNOPSIS -------- -`testr` [*OPTION*]... +`testr` [*OPTION*]... [*CONFIG*]... DESCRIPTION ----------- This program is a simple command-line user interface for testr-driver(1). It -demonstrates how the components of TestR work together and also serves as an -example of how you can create your own TestR user interface. +loads the given *CONFIG* files (which are either paths to actual files or +names of helper libraries in the testr/config/ namespace of Ruby's load path) +and then waits for you to supply interactive commands on its stdin. You may +press the ENTER key (supplying no command) to see a menu of accepted commands. -When run, it presents you with a menu of single-character commands that you -can enter, loads the test execution overhead into testr-master(1), and -finally notifies you when the master is ready to run test files. - -It also launches testr-herald(1) alongside testr-master(1). When the herald -reports a modified file that belongs to the test execution overhead, this -program notifies you accordingly and then replaces the current master with a -new one that will absorb the modified test execution overhead into itself. - OPTIONS ------- `-h`, `--help` Display this help manual using man(1). @@ -47,12 +40,19 @@ require 'binman' BinMan.help require 'json' +ENV['TESTR_CONFIGS'] = JSON.dump(ARGV) + +#----------------------------------------------------------------------------- +# backend +#----------------------------------------------------------------------------- + require 'testr/client' +warn 'testr: Absorbing test execution overhead...' @driver = TestR::Client::Transceiver.new('testr-driver') do |line| evstr, *details = JSON.load(line) event = evstr.to_sym case event @@ -71,36 +71,38 @@ puts message end end +#----------------------------------------------------------------------------- +# frontend +#----------------------------------------------------------------------------- + COMMANDS = { 'r' => :run_all_test_files, 's' => :stop_running_test_files, 'p' => :rerun_passed_test_files, 'f' => :rerun_failed_test_files, 'o' => :reabsorb_overhead_files, 'q' => :quit, } -def COMMANDS.show - each do |key, cmd| - warn "testr: Type #{key} then ENTER to #{cmd.to_s.tr('_', ' ')}." - end -end - -COMMANDS.show # instruct newbies - -while key = STDIN.gets.chomp - if command = COMMANDS[key] - if command == :quit - @driver.quit - break +begin + while key = STDIN.gets.chomp + if command = COMMANDS[key] + if command == :quit + @driver.quit + break + else + @driver.send [command] + end else - @driver.send [command] + COMMANDS.each do |key, cmd| + warn "testr: Type #{key} then ENTER to #{cmd.to_s.tr('_', ' ')}." + end end - else - COMMANDS.show end +rescue Interrupt + # forced quit end Process.waitall