diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-21 07:40:36 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-21 07:40:36 +0000 |
commit | a5c44807324afc06cac9975bfccd6579a0c07271 (patch) | |
tree | 519d11196097e79e90197340eaf2d05e23b84bc9 /test/fileutils/fileasserts.rb | |
parent | 53b3bf961cd4f4de0388d56c7d8b5059eba1c3c0 (diff) | |
download | ruby-a5c44807324afc06cac9975bfccd6579a0c07271.tar.gz |
* test/fileutils/fileasserts.rb (assert_equal_timestamp): new assert
to test tv_sec only for filestamp resolution portability.
(assert_same_entry): use assert_same_entry for mtime comparison.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils/fileasserts.rb')
-rw-r--r-- | test/fileutils/fileasserts.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb index 9347f6863a..41469a6ac6 100644 --- a/test/fileutils/fileasserts.rb +++ b/test/fileutils/fileasserts.rb @@ -17,7 +17,7 @@ module Test b = File.stat(to) assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}" #assert_equal a.atime, b.atime - assert_equal_time a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}" + assert_equal_timestamp a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}" assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}" assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}" end @@ -78,6 +78,23 @@ EOT } end + def assert_equal_timestamp(expected, actual, message=nil) + _wrap_assertion { + expected_str = expected.to_s + actual_str = actual.to_s + if expected_str == actual_str + expected_str << " (nsec=#{expected.nsec})" + actual_str << " (nsec=#{actual.nsec})" + end + full_message = build_message(message, <<EOT) +<#{expected_str}> expected but was +<#{actual_str}>. +EOT + # subsecond timestamp is not portable. + assert_block(full_message) { expected.tv_sec == actual.tv_sec } + } + end + end end end |