bin/tork in tork-18.2.4 vs bin/tork in tork-19.0.0

- old
+ new

@@ -1,9 +1,9 @@ #!/usr/bin/env ruby =begin ======================================================================= -# TORK 1 2012-10-10 18.2.4 +# TORK 1 2012-10-17 19.0.0 ## NAME tork - Continuous testing tool for Ruby @@ -11,83 +11,120 @@ `tork` [*OPTION*]... [*CONFIG*]... ## DESCRIPTION -This program is a simple command-line user interface for tork-driver(1). It -loads the given *CONFIG* files (which are either paths to actual files or -names of helper libraries in the tork/config/ namespace of Ruby's load path) -and then waits for you to supply interactive commands on its stdin. You may +This program is a simple command-line user interface for tork-driver(1). + +First, it applies the given *CONFIG* values, which are either (1) paths to +directories that contain configuration files or (2) names of configuration +helpers listed in the description of the `TORK_CONFIGS` environment variable. + +Next, it waits for you to supply interactive commands either (1) directly on +its stdin or (2) remotely through tork-remote(1). From then onward, you may press the ENTER key (supplying no command) to see a menu of accepted commands. +Some interactive commands accept additional arguments, described as follows. + +`t` *test_file* [*line_number*]... + Runs the given *test_file* while only running those tests that are defined + on the given list of *line_number*s. If no *line_number*s are given, then + only those tests that have changed since the last run of the *test_file* + will now be run. + +`s` [*signal*] + Stops test files that are currently running by sending the given *signal* + (optional; defaults to `SIGTERM`) to their respective worker processes. + +This program can be controlled remotely by multiple tork-remote(1) instances. + ## OPTIONS `-h`, `--help` Show this help manual. -## SEE ALSO +## FILES -tork(1), tork-driver(1), tork-master(1), tork-herald(1) +*.tork/config.rb* + Optional Ruby script that is loaded inside the driver process on startup. + It can read and change the `ENV['TORK_CONFIGS']` environment variable. -=end ========================================================================= +## ENVIRONMENT -$0 = File.basename(__FILE__) # for easier identification in ps(1) output +`TORK_CONFIGS` + Colon-separated (:) list of either paths to directories that contain + configuration files or names of the following configuration helpers. + If this variable is not set, then its value is assumed to be "default". -require 'binman' -BinMan.help + > `default` + > Loads the following configuration helpers (as appropriate) if your + > current working directory appears to utilize what they configure. + > See below for complete descriptions of these configuration helpers. + > + > * rails + > * test + > * spec + > * cucumber + > * factory_girl + > + > `dotlog` + > Hides log files by prefixing their names with a period (dot). + > + > `logdir` + > Keeps log files away from your tests, in the `log/` directory. + > + > `coverage` + > Measures C0 code coverage under Ruby 1.9 and dumps a hash in YAML + > format at the end of your log file containing every Ruby script that + > was loaded from the current working directory or any of its descendant + > directories (the key) mapped to the following information (the value): + > + > > `:grade` + > > Percentage of source lines that were C0 covered. + > > + > > `:nsloc` + > > Total number of source lines of code in the file. + > > + > > `:holes` + > > Line numbers of source lines that were not covered. + > + > `test` + > Supports the Test::Unit standard library. + > + > `spec` + > Supports the [RSpec] testing framework. + > + > `cucumber` + > Supports the [Cucumber] testing framework. + > + > `rails` + > Supports the [Ruby on Rails] web framework. + > + > `factory_girl` + > Supports the [factory_girl] testing library. + > + > `parallel_tests` + > Supports the [parallel_tests] testing library. -require 'json' -ENV['TORK_CONFIGS'] = JSON.dump(ARGV) +## SEE ALSO -#----------------------------------------------------------------------------- -# backend -#----------------------------------------------------------------------------- +tork(1), tork-driver(1), tork-master(1) -require 'tork/client' +[factory_girl]: https://github.com/thoughtbot/factory_girl +[memory_test_fix]: https://github.com/stepahn/memory_test_fix +[parallel_tests]: https://github.com/grosser/parallel_tests +[Ruby on Rails]: http://rubyonrails.org +[Cucumber]: https://cukes.info +[RSpec]: http://rspec.info -warn "#{$0}: Absorbing test execution overhead..." -@driver = Tork::Client::Transceiver.new('tork-driver') do |event, *details| - case event_sym = event.to_sym - when :load then warn "#{$0}: Overhead absorbed. Ready for testing!" - when :over then warn "#{$0}: Reabsorbing changed overhead files..." - else - test_file, line_numbers, log_file, worker_number, exit_status = details - message = [event.upcase, [test_file, *line_numbers].join(':'), - exit_status].compact.join(' ') +=end ========================================================================= - color = case event_sym - when :pass then "\e[34m%s\e[0m" # blue - when :fail then "\e[31m%s\e[0m" # red - end - message = color % message if color and STDOUT.tty? - message = [message, File.read(log_file), message] if event_sym == :fail +$0 = File.basename(__FILE__) # for easier identification in ps(1) output - puts message - end -end +require 'binman' +BinMan.help -#----------------------------------------------------------------------------- -# frontend -#----------------------------------------------------------------------------- +ENV['TORK_CONFIGS'] = [ENV['TORK_CONFIGS'], *ARGV].join(':') if ARGV.any? +require 'tork/config' -COMMANDS = { - 't' => :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, -} - -while key = STDIN.gets - if command = COMMANDS[key.strip] - warn "#{$0}: Sending #{command.to_s.inspect} command..." - @driver.send [command] - break if command == :quit - else # invalid command - COMMANDS.each do |key, cmd| - warn "#{$0}: Type #{key} then ENTER to #{cmd.to_s.tr('_', ' ')}." - end - end -end - -Process.waitall +require 'tork/cliapp' +Tork::CLIApp.new.loop