From a5c44807324afc06cac9975bfccd6579a0c07271 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 21 Nov 2007 07:40:36 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ test/fileutils/fileasserts.rb | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c4001532d8..c812e63710 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 21 16:39:21 2007 Tanaka Akira + + * 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. + Wed Nov 21 14:55:13 2007 Koichi Sasada * array.c (rb_ary_permutation): add gc guard codes. 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, < 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