summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-19 15:57:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-19 15:57:52 +0000
commitb4a002070779beaf267ae86bb9c54ba50e99d633 (patch)
tree3811883522afe3966e4f0b81cba0be6ffd0cca75
parent18b46e0c21738f128a21519fd87ff5d38800deeb (diff)
* test/fileutils/fileasserts.rb (assert_equal_time): show nsec if
assertion fails but time.to_s equals. (assert_same_entry): use assert_equal_time. * test/fileutils/test_fileutils.rb (test_install): use assert_equal_time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--test/fileutils/fileasserts.rb18
-rw-r--r--test/fileutils/test_fileutils.rb2
3 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 44a6e3c3b2..0dfce85f4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Nov 20 00:52:46 2007 Tanaka Akira <akr@fsij.org>
+
+ * test/fileutils/fileasserts.rb (assert_equal_time): show nsec if
+ assertion fails but time.to_s equals.
+ (assert_same_entry): use assert_equal_time.
+
+ * test/fileutils/test_fileutils.rb (test_install): use
+ assert_equal_time.
+
Mon Nov 19 18:46:49 2007 Tanaka Akira <akr@fsij.org>
* file.c (utime_internal): fallback utimensat to utimes.
diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb
index c2e9244a96..d72d9f3932 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 a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
+ assert_equal_time 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
@@ -62,6 +62,22 @@ module Test
}
end
+ def assert_equal_time(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, actual_str)
+<?> expected but was
+<?>.
+EOT
+ assert_block(full_message) { expected == actual }
+ }
+ end
+
end
end
end
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index 3826d9b28e..a52eb50071 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -789,7 +789,7 @@ end
install 'tmp/aaa', 'tmp/bbb'
assert_equal "aaa\n", File.read('tmp/bbb')
assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) if have_file_perm?
- assert_equal t, File.mtime('tmp/bbb')
+ assert_equal_time t, File.mtime('tmp/bbb')
File.unlink 'tmp/aaa'
File.unlink 'tmp/bbb'