Browse files

Add --just-tests option.

Don't guess tests to run, just run the test when the test itself
changes.
  • Loading branch information...
1 parent 7449dec commit 82c9619efcb5e0dc22686edf219097c23b497a9d @billhorsman committed Feb 1, 2012
Showing with 28 additions and 6 deletions.
  1. +14 −1 bin/testowl
  2. +14 −5 lib/testowl/monitor.rb
View
15 bin/testowl
@@ -1,14 +1,27 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'testowl'
+require 'optparse'
require 'active_support/inflector'
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
CONFIG = File.dirname(__FILE__) + '/../lib/testowl/config.rb'
begin
- success = Testowl::Monitor.new.run
+ options = {}
+ OptionParser.new do|opts|
+ opts.banner = "Usage: testowl [options]"
+ options[:just_tests] = false
+ opts.on('-j', '--just-tests', "Just run tests, no heuristics") do |v|
+ options[:just_tests] = v
+ end
+ opts.on( '-h', '--help', 'Display this screen' ) do
+ puts opts
+ exit
+ end
+ end.parse!
+ success = Testowl::Monitor.new(options).run
Kernel.exit 1 unless success
rescue SystemExit => e
Kernel.exit(e.status)
View
19 lib/testowl/monitor.rb
@@ -3,7 +3,8 @@ class Monitor
attr_reader :test_dir, :test_suffix
- def initialize()
+ def initialize(options)
+ @options = options
if File.exist?("spec/spec_helper.rb")
@runner = RspecRunner.new
@test_dir = "spec"
@@ -28,13 +29,21 @@ def run
end
# Watch models
script.watch("app/models/(.*)\.rb") do |match|
- puts "Detected change in #{match[0]}"
- run_model(match[1], "triggered by #{match[0]}")
+ if @options[:just_tests]
+ puts "Ignoring change in #{match[0]}"
+ else
+ puts "Detected change in #{match[0]}"
+ run_model(match[1], "triggered by #{match[0]}")
+ end
end
# Watch controllers
script.watch("app/controllers/(.*)_controller\.rb") do |match|
- puts "Detected change in #{match[0]}"
- run_controller(match[1], "triggered by #{match[0]}")
+ if @options[:just_tests]
+ puts "Ignoring change in #{match[0]}"
+ else
+ puts "Detected change in #{match[0]}"
+ run_controller(match[1], "triggered by #{match[0]}")
+ end
end
puts "Waiting for code changes..."
Watchr::Controller.new(script, Watchr.handler.new).run

0 comments on commit 82c9619

Please sign in to comment.