Skip to content

Commit

Permalink
shorten all commands names down to ~4 characters
Browse files Browse the repository at this point in the history
* In tork(1):
  * the `o` input command character is now named `b`

* In tork-driver(1):
  * the `run_all_test_files` command is now named `test!`
  * the `over` message is now named `boot!`

* In tork-engine(1):
  * the `reabsorb_overhead` command is now named `boot!`
  * the `run_test_file` command is now named `test`
  * the `run_test_files` command is now named `test`
  * the `stop_running_test_files` command is now named `stop`
  * the `rerun_passed_test_files` command is now named `pass!`
  * the `rerun_failed_test_files` command is now named `fail!`
  * the `list_failed_test_files` command is now named `fail?`
  * the `over` status message is now named `boot!`
  • Loading branch information
sunaku committed Oct 26, 2014
1 parent 9efdaef commit bbef74c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 44 deletions.
4 changes: 2 additions & 2 deletions bin/tork-driver
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stdin that are single-line JSON arrays, it splits each of them into an array
of words, using the same word-splitting algorithm as sh(1), before processing
them. For example, the line `a "b c"` is split into the `["a", "b c"]` array.
`["run_all_test_files"]`
`["test!"]`
Runs all test files found within and beneath the current working directory.
*...*
Expand All @@ -36,7 +36,7 @@ them. For example, the line `a "b c"` is split into the `["a", "b c"]` array.
This program prints the following messages, which are single-line JSON arrays,
to stdout.
`["over",` *overhead_file*`]`
`["boot!",` *overhead_file*`]`
Reabsorbing test execution overhead because *overhead_file* has changed.
*...*
Expand Down
16 changes: 7 additions & 9 deletions bin/tork-engine
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,28 @@ stdin that are single-line JSON arrays, it splits each of them into an array
of words, using the same word-splitting algorithm as sh(1), before processing
them. For example, the line `a "b c"` is split into the `["a", "b c"]` array.
`["reabsorb_overhead"]`
`["boot!"]`
Stops any test files that are currently running, reabsorbs the test
execution overhead, and then re-runs those stopped test files.
`["run_test_file"`, *test_file*`,` *line_numbers*...`]`
`["test"`, *test_file*`,` *line_numbers*...`]`
`["test"`, `[`*test_file*`,` *line_numbers*...`]`...`]`
Runs tests that correspond to the given sequence of *line_numbers* in the
given *test_file*. If no *line_numbers* are given, then only those lines
that have changed since the last run of *test_file* will be substituted.
If any *line_numbers* are zero, then the entire *test_file* will be run.
`["run_test_files"`, *test\_files\_with\_optional\_line\_numbers*`]`
Calls the `run_test_file` command once for each item in the given array.
`["stop_running_test_files"`, *signal*`]`
`["stop"`, *signal*`]`
Stops test files that are currently running by sending the given *signal*
(optional; defaults to "SIGTERM") to their respective worker processes.
`["rerun_passed_test_files"]`
`["pass!"]`
Runs all test files that have passed during their most recent run.
`["rerun_failed_test_files"]`
`["fail!"]`
Runs all test files that have failed during their most recent run.
`["list_failed_test_files"]`
`["fail?"]`
Lists all test files that have failed during their most recent run.
`["quit"]`
Expand Down
4 changes: 2 additions & 2 deletions bin/tork-runner
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ IO.popen('tork-driver', 'w+') do |driver|
test_files = Dir[*ARGV]
command =
if test_files.empty?
[:run_all_test_files]
[:test!]
else
[:run_test_files, test_files]
[:test, test_files]
end
driver.puts JSON.dump(command)

Expand Down
23 changes: 12 additions & 11 deletions lib/tork/cliapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def recv client, message
when :boot
tell @clients, 'Test execution overhead absorbed; ready to test!'

when :over
when :boot!
tell @clients, 'Test execution overhead changed; re-absorbing...'

when :test, :pass, :fail
Expand All @@ -57,6 +57,7 @@ def recv client, message
tested, passed, failed = details.map(&:length)
tell @clients, "#{tested} tested, #{passed} passed, #{failed} failed"
end

else
key = message.shift.lstrip[0,1].downcase
cmd = Array(COMMANDS.fetch(key, [:help, client])) + message
Expand All @@ -72,27 +73,27 @@ def recv client, message
private

COMMANDS = {
't' => :run_test_file,
'a' => :run_all_test_files,
's' => :stop_running_test_files,
'k' => [:stop_running_test_files, :SIGKILL],
'p' => :rerun_passed_test_files,
'f' => :rerun_failed_test_files,
'l' => :list_failed_test_files,
'o' => :reabsorb_overhead,
't' => :test,
'a' => :test!,
's' => :stop,
'k' => [:stop, :SIGKILL],
'p' => :pass!,
'f' => :fail!,
'l' => :fail?,
'b' => :boot!,
'q' => :quit,
}

def help client
tell client, <<HELP
Type a then ENTER to run all test files.
Type a then ENTER to run all available test files.
Type t then SPACE then a filename then ENTER to run a specific test file.
Type s then ENTER to stop currently running test files.
Type k then ENTER to kill currently running test files.
Type p then ENTER to re-run currently passing test files.
Type f then ENTER to re-run currently failing test files.
Type l then ENTER to list currently failing test files.
Type o then ENTER to re-absorb test execution overhead.
Type b then ENTER to re-absorb test execution overhead.
Type h then ENTER to see this help message.
Type q then ENTER to quit.
HELP
Expand Down
10 changes: 5 additions & 5 deletions lib/tork/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def loop
pclose @engine
end

def run_all_test_files
def test!
test_files_found = false
Dir.glob(ALL_TEST_FILE_GLOBS) do |test_file|
next if overhead_file? test_file
run_test_file test_file
test test_file
test_files_found = true
end
tell @client, 'There are no test files to run.' unless test_files_found
Expand Down Expand Up @@ -59,8 +59,8 @@ def recv client, message

# reabsorb text execution overhead if overhead files changed
if overhead_file? changed_file
send @clients, [:over, changed_file]
reabsorb_overhead
send @clients, [:boot!, changed_file]
boot!
else
run_non_overhead_test_files find_dependent_test_files(changed_file)
end
Expand All @@ -74,7 +74,7 @@ def recv client, message
private

def run_non_overhead_test_files test_files
run_test_files test_files.reject {|f| overhead_file? f }
test test_files.reject {|f| overhead_file? f }
end

def overhead_file? file
Expand Down
30 changes: 15 additions & 15 deletions lib/tork/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ def loop
pclose @master
end

def reabsorb_overhead
def boot!
@master.reconnect

# resume running all previously running test files and
# all previously failed test files in the new master
resume = @running_test_files + @failed_test_files
resumable = @running_test_files + @failed_test_files
@running_test_files.clear
run_test_files resume
test resumable
end

def run_test_file test_file, *line_numbers
if File.exist? test_file and @running_test_files.add? test_file
def test test_file, *line_numbers
# a list of tests was passed in for the first argument
if test_file.respond_to? :each and line_numbers.empty?
test_file.each {|args| test(*args) }

elsif File.exist? test_file and @running_test_files.add? test_file
if line_numbers.empty?
line_numbers = find_changed_line_numbers(test_file)
else
Expand All @@ -47,11 +51,7 @@ def run_test_file test_file, *line_numbers
end
end

def run_test_files test_files_with_optional_line_numbers
test_files_with_optional_line_numbers.each {|f| run_test_file(*f) }
end

def stop_running_test_files signal=nil
def stop signal=nil
if @running_test_files.empty?
tell @client, 'There are no running test files to stop.'
else
Expand All @@ -60,23 +60,23 @@ def stop_running_test_files signal=nil
end
end

def rerun_passed_test_files
def pass!
if @passed_test_files.empty?
tell @client, 'There are no passed test files to re-run.'
else
run_test_files @passed_test_files
test @passed_test_files
end
end

def rerun_failed_test_files
def fail!
if @failed_test_files.empty?
tell @client, 'There are no failed test files to re-run.'
else
run_test_files @failed_test_files
test @failed_test_files
end
end

def list_failed_test_files
def fail?
if @failed_test_files.empty?
tell @client, 'There are no failed test files to list.'
else
Expand Down

0 comments on commit bbef74c

Please sign in to comment.