{"action":"closed","issue":{"url":"https://api.github.com/repos/ruby/rubyspec/issues/125","labels_url":"https://api.github.com/repos/ruby/rubyspec/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/ruby/rubyspec/issues/125/comments","events_url":"https://api.github.com/repos/ruby/rubyspec/issues/125/events","html_url":"https://github.com/ruby/rubyspec/issues/125","id":105602018,"number":125,"title":"On NFS filesystem, File::Stat#<=> is able to compare files by the same modification times FAILED","user":{"login":"ngoto","id":14440,"avatar_url":"https://avatars.githubusercontent.com/u/14440?v=3","gravatar_id":"","url":"https://api.github.com/users/ngoto","html_url":"https://github.com/ngoto","followers_url":"https://api.github.com/users/ngoto/followers","following_url":"https://api.github.com/users/ngoto/following{/other_user}","gists_url":"https://api.github.com/users/ngoto/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoto/subscriptions","organizations_url":"https://api.github.com/users/ngoto/orgs","repos_url":"https://api.github.com/users/ngoto/repos","events_url":"https://api.github.com/users/ngoto/events{/privacy}","received_events_url":"https://api.github.com/users/ngoto/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-09T13:57:51Z","updated_at":"2015-09-10T12:17:42Z","closed_at":"2015-09-10T12:17:42Z","body":"On Debian GNU/Linux 7.8 (amd64) and on Solaris 10 (sparc), the following failure is observed when running the spec on NFS network file system.\r\n\r\n```\r\n1)\r\nFile::Stat#<=> is able to compare files by the same modification times FAILED\r\nExpected -1\r\n to equal 0\r\n\r\n/XXXXX-trunk-51815/spec/rubyspec/core/file/stat/comparison_spec.rb:21:in `block (2 levels) in <top (required)>'\r\n/XXXXX-trunk-51815/spec/rubyspec/core/file/stat/comparison_spec.rb:3:in `<top (required)>'\r\n```\r\n\r\nThis failure is caused by NFS cache. NFS cache lifetime is 1 second, and time stamps of a file is used to determine whether the cache for the file should be flushed or not.\r\n\r\nThe following simple patch to set 1 second ago timestamps solved the problem.\r\nIt seems that setting the file timestamps to more than 1 second ago would tell the system to expire the cache immediately.\r\n\r\n```\r\n--- a/core/file/stat/comparison_spec.rb\r\n+++ b/core/file/stat/comparison_spec.rb\r\n@@ -15,7 +15,7 @@ describe \"File::Stat#<=>\" do\r\n   end\r\n \r\n   it \"is able to compare files by the same modification times\" do\r\n-    now = Time.now\r\n+    now = Time.now - 1 # 1 second ago to avoid NFS cache issue\r\n     File.utime(now, now, @name1)\r\n     File.utime(now, now, @name2)\r\n     (@file1.stat <=> @file2.stat).should == 0\r\n```\r\n"}}