better messages when matching no files in run_on_change

This commit is contained in:
John Bintz 2011-08-07 12:51:42 -04:00
parent 7e31c0d2d7
commit 9734d6cbeb

View File

@ -37,9 +37,10 @@ class Guard::Hydra < Guard::Guard
end end
def run_on_change(files = []) def run_on_change(files = [])
files = ensure_files(files) if !(files = ensure_files(files)).empty?
Guard::UI.info "Running Hydra on #{files.join(', ')}" Guard::UI.info "Running Hydra on #{files.join(', ')}"
run_all if run_hydra(files) run_all if run_hydra(files)
end
end end
def run_all def run_all
@ -49,21 +50,26 @@ class Guard::Hydra < Guard::Guard
private private
def run_hydra(files = []) def run_hydra(files = [])
File.unlink @options[:runner_log] if runner_log? && @options[:clear_runner_log] if !files.empty?
File.unlink @options[:runner_log] if runner_log? && @options[:clear_runner_log]
start = Time.now start = Time.now
hydra = Hydra::Master.new( hydra = Hydra::Master.new(
:listeners => [ Hydra::Listener::ProgressBar.new ], :listeners => [ Hydra::Listener::ProgressBar.new ],
:files => files, :files => files,
:environment => @options[:env], :environment => @options[:env],
:config => @options[:hydra_config] :config => @options[:hydra_config]
) )
Guard::UI.info sprintf("Tests completed in %.6f seconds", Time.now - start) Guard::UI.info sprintf("Tests completed in %.6f seconds", Time.now - start)
puts File.read(@options[:runner_log]) if runner_log? && @options[:show_runner_log] puts File.read(@options[:runner_log]) if runner_log? && @options[:show_runner_log]
hydra.failed_files.empty? hydra.failed_files.empty?
else
Guard::UI.info "No files matched!"
false
end
end end
def runner_log? def runner_log?