Permalink
Browse files

update valgrind config and fix stat watcher unit test to not fail spo…

…ratically
  • Loading branch information...
1 parent 8ee4303 commit e7d2c55ca0ffc5222f1ffec510ced8fee9b3d0a8 @rares rares committed Feb 9, 2011
Showing with 20 additions and 10 deletions.
  1. +6 −4 Rakefile
  2. +14 −6 spec/stat_watcher_spec.rb
View
@@ -73,15 +73,17 @@ def specs_command
Find.find("spec") do |f|
files << f if File.basename(f) =~ /.*spec.*\.rb$/
end
- cmdline = "#{RUBY} -w -I.:lib:ext:spec \
+ cmdline = "#{RUBY} -I.:lib:ext:spec \
-e '%w[#{files.join(' ')}].each { |f| require f }'"
end
namespace :test do
- desc "run specs under valgrind with basic ruby options"
+ desc "run specs with valgrind"
task :valgrind => :compile do
- system "valgrind --num-callers=50 --error-limit=no \
- --partial-loads-ok=yes --undef-value-errors=no #{specs_command}"
+ system "valgrind --num-callers=15 \
+ --partial-loads-ok=yes --undef-value-errors=no \
+ --tool=memcheck --leak-check=yes --track-fds=yes \
+ --show-reachable=yes #{specs_command}"
end
end
@@ -27,7 +27,7 @@ def run_with_file_change(path)
tw = Cool.io::TimerWatcher.new(INTERVAL, true)
tw.on_timer do
reactor.stop if sw.accessed
- File.open(path, "w+") { |f| f.write(rand.to_s) }
+ write_file(path)
end
tw.attach(reactor)
@@ -39,26 +39,34 @@ def run_with_file_change(path)
sw
end
+def write_file(path)
+ File.open(path, "w+") { |f| f.write(rand.to_s) }
+end
+
+def delete_file(path)
+ File.delete(TEMP_FILE_PATH)
+end
+
describe Cool.io::StatWatcher do
- let :sw do
+ let :watcher do
run_with_file_change(TEMP_FILE_PATH)
end
before :each do
- `touch #{TEMP_FILE_PATH}`
+ write_file(TEMP_FILE_PATH)
end
after :each do
- `rm #{TEMP_FILE_PATH}`
+ delete_file(TEMP_FILE_PATH)
end
it "fire on_change when the file it is watching is modified" do
- sw.accessed.should eql(true)
+ watcher.accessed.should eql(true)
end
it "should pass previous and current file stat info given a stat watcher" do
- sw.previous.ino.should eql(sw.current.ino)
+ watcher.previous.ino.should eql(watcher.current.ino)
end
end

0 comments on commit e7d2c55

Please sign in to comment.