Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Replace deprecated_be_close(x,y) with be_within(y).of(x)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/buildr/trunk@1536192 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
realityforge committed Oct 27, 2013
1 parent 9d7d32f commit 6d1069b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions spec/core/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,13 @@ def source
it 'should touch target directory' do
mkpath 'target' ; File.utime @early, @early, 'target'
@filter.from('src').into('target').run
File.stat('target').mtime.should be_close(Time.now, 10)
File.stat('target').mtime.should be_within(10).of(Time.now)
end

it 'should not touch target directory unless running' do
mkpath 'target' ; File.utime @early, @early, 'target'
@filter.from('src').into('target').exclude('*').run
File.mtime('target').should be_close(@early, 10)
File.mtime('target').should be_within(10).of(@early)
end

it 'should run only on new files' do
Expand Down
10 changes: 5 additions & 5 deletions spec/core/compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,29 +389,29 @@ def jars
time = now_at_fs_resolution - 10
mkpath compile_task.target.to_s
File.utime(time, time, compile_task.target.to_s)
compile_task.timestamp.should be_close(time, 1)
compile_task.timestamp.should be_within(1).of(time)
end

it 'should touch target if anything compiled' do
mkpath compile_task.target.to_s
File.utime(now_at_fs_resolution - 10, now_at_fs_resolution - 10, compile_task.target.to_s)
compile_task.from(sources).invoke
File.stat(compile_task.target.to_s).mtime.should be_close(now_at_fs_resolution, 2)
File.stat(compile_task.target.to_s).mtime.should be_within(2).of(now_at_fs_resolution)
end

it 'should not touch target if nothing compiled' do
mkpath compile_task.target.to_s
File.utime(now_at_fs_resolution - 10, now_at_fs_resolution - 10, compile_task.target.to_s)
compile_task.invoke
File.stat(compile_task.target.to_s).mtime.should be_close(now_at_fs_resolution - 10, 2)
File.stat(compile_task.target.to_s).mtime.should be_within(2).of(now_at_fs_resolution - 10)
end

it 'should not touch target if failed to compile' do
mkpath compile_task.target.to_s
File.utime(now_at_fs_resolution - 10, now_at_fs_resolution - 10, compile_task.target.to_s)
write 'failed.java', 'not a class'
suppress_stdout { compile_task.from('failed.java').invoke rescue nil }
File.stat(compile_task.target.to_s).mtime.should be_close(now_at_fs_resolution - 10, 2)
File.stat(compile_task.target.to_s).mtime.should be_within(2).of(now_at_fs_resolution - 10)
end

it 'should complain if source directories and no compiler selected' do
Expand All @@ -429,7 +429,7 @@ def jars
touch 'target/classes/foo/Foo.class'
File.utime(now_at_fs_resolution - 10, now_at_fs_resolution - 10, compile_task.target.to_s)
compile_task.invoke
File.stat(compile_task.target.to_s).mtime.should be_close(now_at_fs_resolution - 10, 2)
File.stat(compile_task.target.to_s).mtime.should be_within(2).of(now_at_fs_resolution - 10)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/java/test_coverage_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def instrumented_dir
mkpath instrumented_dir.to_s
File.utime(a_long_time_ago, a_long_time_ago, instrumented_dir.to_s)
task("foo:#{toolname}:instrument").invoke
instrumented_dir.timestamp.should be_close(Time.now, 2)
instrumented_dir.timestamp.should be_within(2).of(Time.now)
end

it 'should not touch instrumented directory if nothing instrumented' do
Expand All @@ -137,7 +137,7 @@ def instrumented_dir
mkpath instrumented_dir.to_s
[project('foo').compile.target, instrumented_dir].map(&:to_s).each { |dir| File.utime(a_long_time_ago, a_long_time_ago, dir) }
task("foo:#{toolname}:instrument").invoke
instrumented_dir.timestamp.should be_close(a_long_time_ago, 2)
instrumented_dir.timestamp.should be_within(2).of(a_long_time_ago)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/packaging/archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def init_dir
# all included files newer.
File.utime Time.now - 100, Time.now - 100, @archive
archive(@archive).include(@files).invoke
File.stat(@archive).mtime.should be_close(Time.now, 10)
File.stat(@archive).mtime.should be_within(10).of(Time.now)
end

it 'should update if a file in a subdir is more recent' do
Expand All @@ -369,7 +369,7 @@ def init_dir
# By touching all files in the past, there's nothing new to update.
(@files + [@archive]).each { |f| File.utime Time.now - 100, Time.now - 100, f }
archive(@archive).include(@files).invoke
File.stat(@archive).mtime.should be_close(Time.now - 100, 10)
File.stat(@archive).mtime.should be_within(10).of(Time.now - 100)
end

it 'should update if one of the files is recent' do
Expand Down Expand Up @@ -609,7 +609,7 @@ def with_zip(*args)
File.utime(Time.now - 10, Time.now - 10, @target)
unzip(@target=>@zip).target.invoke
end
File.stat(@target).mtime.should be_close(Time.now, 2)
File.stat(@target).mtime.should be_within(2).of(Time.now)
end

it 'should expand files' do
Expand Down

0 comments on commit 6d1069b

Please sign in to comment.