Travis test

This commit is contained in:
Thibaud Guillaume-Gentil 2011-09-03 21:33:06 +02:00
parent 41127e2cbf
commit 8b66b71716
2 changed files with 26 additions and 24 deletions

View File

@ -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

View File

@ -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