From 8b66b717163f2da02ad09f05a189076cc30d2cc3 Mon Sep 17 00:00:00 2001 From: Thibaud Guillaume-Gentil Date: Sat, 3 Sep 2011 21:33:06 +0200 Subject: [PATCH] Travis test --- lib/guard/listener.rb | 29 +++++++++++++++-------------- spec/support/listener_helper.rb | 21 +++++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index 31efc4c..ad2058f 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -87,8 +87,8 @@ module Guard last_event = @last_event update_last_event files = potentially_modified_files(dirs, options).select { |path| file_modified?(path, last_event) } - p "modified_files" - p files + # p "modified_files" + # p files relativize_paths(files) end @@ -143,30 +143,31 @@ module Guard end end - # Depending on the filesystem, mtime is probably only precise to the second, so round + # Depending on the filesystem, mtime/ctime is probably only precise to the second, so round # both values down to the second for the comparison. + # ctime is used only on == comparaison to always catches Rails 3.1 Assets pipelined on Mac OSX def file_modified?(path, last_event) - p path - p @last_event.to_i - p last_event.to_i - p File.ctime(path).to_i - p File.mtime(path).to_i + # p path + # p @last_event.to_i + # p last_event.to_i + # p File.ctime(path).to_i + # p File.mtime(path).to_i if File.ctime(path).to_i == last_event.to_i - p "File.ctime == last_event" + # p "File.ctime == last_event" res = file_content_modified?(path, sha1_checksum(path)) - p res.to_s + # p res.to_s res elsif File.mtime(path).to_i > last_event.to_i - p "File.ctime > last_event" + # p "File.ctime > last_event" set_sha1_checksums_hash(path, sha1_checksum(path)) - p "true" + # p "true" true else - p "false" + # p "false" false end rescue - p "false" + # p "false" false end diff --git a/spec/support/listener_helper.rb b/spec/support/listener_helper.rb index 7527627..1b26f1e 100644 --- a/spec/support/listener_helper.rb +++ b/spec/support/listener_helper.rb @@ -1,10 +1,10 @@ private - def start - sleep(@rest_delay || 1) + def start(rest_delay = @rest_delay) + sleep(rest_delay || 1) @listener.update_last_event - Thread.new { @listener.start } - sleep(@rest_delay || 1) + @thread = Thread.new { @listener.start } + sleep(rest_delay || 1) end def record_results @@ -16,10 +16,11 @@ private end end - def stop - sleep(@rest_delay || 1) + def stop(rest_delay = @rest_delay) + sleep(rest_delay || 1) @listener.stop - sleep(@rest_delay || 1) + Thread.kill(@thread) + sleep(rest_delay || 1) end def results @@ -61,14 +62,14 @@ shared_examples_for 'a listener that reacts to #on_change' do |rest_delay| results.should =~ ['spec/fixtures/folder1/file1.txt'] end - it "catches a single file chmod update" do + it "not catches a single file chmod update" do file = @fixture_path.join("folder1/file1.txt") File.exists?(file).should be_true File.chmod(0775, file) start File.chmod(0777, file) stop - results.should =~ ['spec/fixtures/folder1/file1.txt'] + results.should =~ [] end it "catches a dotfile update" do @@ -102,7 +103,7 @@ shared_examples_for 'a listener that reacts to #on_change' do |rest_delay| results.should =~ [] end - it "not catches a moved file", :focus => true do + it "not catches a moved file" do file1 = @fixture_path.join("folder1/file1.txt") file2 = @fixture_path.join("folder1/movedfile1.txt") File.exists?(file1).should be_true