{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/34218621","id":34218621,"diff_hunk":"@@ -1,131 +1,45 @@\n // Copyright (c) Microsoft. All rights reserved.\n // Licensed under the MIT license. See LICENSE file in the project root for full license information.\n \n-using System;\n-using System.Runtime.CompilerServices;\n-using System.IO;\n-using System.Collections;\n-using System.Globalization;\n-using System.Text;\n-using System.Threading.Tasks;\n using Xunit;\n \n-public class FileInfo_get_LastWriteTime\n+namespace System.IO.FileSystem.Tests\n {\n-    public static String s_strActiveBugNums = \"\";\n-    public static String s_strDtTmVer = \"2000/05/09 13:19\";\n-    public static String s_strClassMethod = \"File.Directory()\";\n-    public static String s_strTFName = \"get_LastWriteTime.cs\";\n-    public static String s_strTFPath = Directory.GetCurrentDirectory();\n-\n-    [Fact]\n-    [OuterLoop]\n-    public static void runTest()\n+    public class FileInfo_get_LastWriteTime : FileSystemTest\n     {\n-        String strLoc = \"Loc_000oo\";\n-        String strValue = String.Empty;\n-        int iCountErrors = 0;\n-        int iCountTestcases = 0;\n-\n-        try\n+        [Fact]\n+        public void WriteTimeRefreshes()\n         {\n-            /////////////////////////  START TESTS ////////////////////////////\n-            ///////////////////////////////////////////////////////////////////\n-\n-\n-            String filName = Path.Combine(TestInfo.CurrentDirectory, Path.GetRandomFileName());\n-            FileInfo fil2;\n-            Stream stream;\n-\n-\n-            if (File.Exists(filName))\n-                File.Delete(filName);\n-\n-\n-\n-            // [] Exception for null string\n-            //-----------------------------------------------------------\n-\n-            // [] Create a directory and check the creation time\n-\n-            strLoc = \"Loc_r8r7j\";\n-\n-            new FileStream(filName, FileMode.Create).Dispose();\n-            fil2 = new FileInfo(filName);\n-            stream = fil2.OpenWrite();\n-            stream.Write(new Byte[] { 10 }, 0, 1);\n-            stream.Dispose();\n-            Task.Delay(4000).Wait();\n-            fil2.Refresh();\n-            iCountTestcases++;\n-            DateTime lastWriteTime = fil2.LastWriteTime;\n-            if ((DateTime.Now - lastWriteTime).TotalMilliseconds < 2000 ||\n-               (DateTime.Now - lastWriteTime).TotalMilliseconds > 5000)\n+            string fileName = GetTestFilePath();\n+            File.Create(fileName).Dispose();\n+            FileInfo fileInfo = new FileInfo(fileName);\n+            DateTime beforeWrite = DateTime.Now;\n+            using (Stream stream = new FileInfo(fileName).OpenWrite())\n             {\n-                iCountErrors++;\n-                Console.WriteLine(lastWriteTime);\n-                Console.WriteLine((DateTime.Now - lastWriteTime).TotalMilliseconds);\n-                printerr(\"Error_20hjx! Last Write Time time cannot be correct\");\n+                stream.Write(new Byte[] { 10 }, 0, 1);\n             }\n+            DateTime afterWrite = DateTime.Now;\n+            fileInfo.Refresh();\n+            DateTime lastWriteTime = fileInfo.LastWriteTime;\n+            Assert.InRange<long>(fileInfo.LastWriteTime.Ticks, beforeWrite.Ticks, afterWrite.Ticks);","path":"src/System.IO.FileSystem/tests/FileInfo/get_LastWriteTime.cs","position":83,"original_position":83,"commit_id":"ff0aa35b0573a824557766adfabaf5ba855b93ea","original_commit_id":"ff0aa35b0573a824557766adfabaf5ba855b93ea","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"body":"This could be problematic on Linux (not sure about OSX).  Our current implementation uses utime, with a resolution of one second I believe.  If that's true, we could easily have a case where, for example, the last write time is at 1:23:45, the before time is 1:23:45.67 and the after time is 1:23:45.89... everything is correct, but the InRange will fail.\r\n\r\nIf I'm right that this is problematic, I'd suggest loosening the test a bit to allow some buffer.  Separately, you might open an issue and/or look to address the implementation to see about providing more accuracy, e.g. using utimes instead of utime, but we might want to wait for #2137 before doing that, as if memory serves it involves a structure that'll be very fragile to declare in managed code.","created_at":"2015-07-09T02:15:14Z","updated_at":"2015-07-09T02:15:14Z","html_url":"https://github.com/dotnet/corefx/pull/2281#discussion_r34218621","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/2281","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/34218621"},"html":{"href":"https://github.com/dotnet/corefx/pull/2281#discussion_r34218621"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2281"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/2281","id":39534876,"html_url":"https://github.com/dotnet/corefx/pull/2281","diff_url":"https://github.com/dotnet/corefx/pull/2281.diff","patch_url":"https://github.com/dotnet/corefx/pull/2281.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/2281","number":2281,"state":"open","locked":false,"title":"FileSystem updates and test modernization to fix intermittent test failures and concurrency issues.","user":{"login":"ianhays","id":2606879,"avatar_url":"https://avatars.githubusercontent.com/u/2606879?v=3","gravatar_id":"","url":"https://api.github.com/users/ianhays","html_url":"https://github.com/ianhays","followers_url":"https://api.github.com/users/ianhays/followers","following_url":"https://api.github.com/users/ianhays/following{/other_user}","gists_url":"https://api.github.com/users/ianhays/gists{/gist_id}","starred_url":"https://api.github.com/users/ianhays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianhays/subscriptions","organizations_url":"https://api.github.com/users/ianhays/orgs","repos_url":"https://api.github.com/users/ianhays/repos","events_url":"https://api.github.com/users/ianhays/events{/privacy}","received_events_url":"https://api.github.com/users/ianhays/received_events","type":"User","site_admin":false},"body":"- System.IO.UnixFileSystem has an issue with the \"overwrite\" being interpreted backwards. I simply reversed the conditional statement to be correct. There were previously no tests to cover this possibility. Resolves #2276\r\n- Updated over a dozen test files to use the modern Xunit syntax.\r\n- Solved file-in-use concurrency issues in the altered tests. Resolves #1313, #2227\r\n- Tests will no longer intermittently fail.\r\n- Slightly improved code coverage for the FileSystem files whose tests I altered (Directory, DirectoryInfo, File, FileInfo)\r\n- Most tests altered now inherit from similar tests to consolidate the testing robustness into as few locations as possible. For example, Directory_GetFiles_str now inherits from Directory_GetFileSystemEntries_str since the tests for Directory_GetFiles_str were the exact same ones as in Directory_GetFileSystemEntries_str anyways.\r\n- All altered tests now use the System.IO.FileSystem.Tests namespace\r\n- Renamed the File_WriteAll_all class name/file name to File_WriteAllText.\r\n- I tested my changes on Windows overnight to verify that there is no more intermittent test failures. I didn't have to modify all of the files listed in #2227 to get them to pass; this concerns me but I found no way to replicate the errors I was receiving before. My guess would be that the tests in the files I didn't alter (e.g. File_WriteAll and File_ReadAll) used the same names as the tests I did alter but now that the tests I altered are changed they no longer share test file names and no longer fail as a result.\r\n- Re-added ActiveIssue #2205 to the Unix Whitespace tests and added more whitespace possibilities like tab.","created_at":"2015-07-08T23:34:56Z","updated_at":"2015-07-09T02:15:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54d3b1ee0b8a52043ed735a3db9000a39a899f8b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/2281/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/2281/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/2281/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/ff0aa35b0573a824557766adfabaf5ba855b93ea","head":{"label":"ianhays:master","ref":"master","sha":"ff0aa35b0573a824557766adfabaf5ba855b93ea","user":{"login":"ianhays","id":2606879,"avatar_url":"https://avatars.githubusercontent.com/u/2606879?v=3","gravatar_id":"","url":"https://api.github.com/users/ianhays","html_url":"https://github.com/ianhays","followers_url":"https://api.github.com/users/ianhays/followers","following_url":"https://api.github.com/users/ianhays/following{/other_user}","gists_url":"https://api.github.com/users/ianhays/gists{/gist_id}","starred_url":"https://api.github.com/users/ianhays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianhays/subscriptions","organizations_url":"https://api.github.com/users/ianhays/orgs","repos_url":"https://api.github.com/users/ianhays/repos","events_url":"https://api.github.com/users/ianhays/events{/privacy}","received_events_url":"https://api.github.com/users/ianhays/received_events","type":"User","site_admin":false},"repo":{"id":37934303,"name":"corefx","full_name":"ianhays/corefx","owner":{"login":"ianhays","id":2606879,"avatar_url":"https://avatars.githubusercontent.com/u/2606879?v=3","gravatar_id":"","url":"https://api.github.com/users/ianhays","html_url":"https://github.com/ianhays","followers_url":"https://api.github.com/users/ianhays/followers","following_url":"https://api.github.com/users/ianhays/following{/other_user}","gists_url":"https://api.github.com/users/ianhays/gists{/gist_id}","starred_url":"https://api.github.com/users/ianhays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianhays/subscriptions","organizations_url":"https://api.github.com/users/ianhays/orgs","repos_url":"https://api.github.com/users/ianhays/repos","events_url":"https://api.github.com/users/ianhays/events{/privacy}","received_events_url":"https://api.github.com/users/ianhays/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ianhays/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/ianhays/corefx","forks_url":"https://api.github.com/repos/ianhays/corefx/forks","keys_url":"https://api.github.com/repos/ianhays/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ianhays/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ianhays/corefx/teams","hooks_url":"https://api.github.com/repos/ianhays/corefx/hooks","issue_events_url":"https://api.github.com/repos/ianhays/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/ianhays/corefx/events","assignees_url":"https://api.github.com/repos/ianhays/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/ianhays/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/ianhays/corefx/tags","blobs_url":"https://api.github.com/repos/ianhays/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ianhays/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ianhays/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/ianhays/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ianhays/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/ianhays/corefx/languages","stargazers_url":"https://api.github.com/repos/ianhays/corefx/stargazers","contributors_url":"https://api.github.com/repos/ianhays/corefx/contributors","subscribers_url":"https://api.github.com/repos/ianhays/corefx/subscribers","subscription_url":"https://api.github.com/repos/ianhays/corefx/subscription","commits_url":"https://api.github.com/repos/ianhays/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/ianhays/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/ianhays/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/ianhays/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/ianhays/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/ianhays/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ianhays/corefx/merges","archive_url":"https://api.github.com/repos/ianhays/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ianhays/corefx/downloads","issues_url":"https://api.github.com/repos/ianhays/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/ianhays/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/ianhays/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/ianhays/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ianhays/corefx/labels{/name}","releases_url":"https://api.github.com/repos/ianhays/corefx/releases{/id}","created_at":"2015-06-23T17:36:59Z","updated_at":"2015-06-23T17:37:18Z","pushed_at":"2015-07-08T23:23:09Z","git_url":"git://github.com/ianhays/corefx.git","ssh_url":"git@github.com:ianhays/corefx.git","clone_url":"https://github.com/ianhays/corefx.git","svn_url":"https://github.com/ianhays/corefx","homepage":"http://dotnet.github.io/core/","size":23475,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"89dd4fafeec3146708f6702d78219591b2bb31a6","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-07-08T22:51:24Z","pushed_at":"2015-07-09T01:55:43Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/core/","size":49824,"stargazers_count":8017,"watchers_count":8017,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1658,"mirror_url":null,"open_issues_count":461,"forks":1658,"open_issues":461,"watchers":8017,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2281"},"html":{"href":"https://github.com/dotnet/corefx/pull/2281"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2281"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2281/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2281/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2281/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/ff0aa35b0573a824557766adfabaf5ba855b93ea"}}}}