{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/dnx/pulls/comments/38691035","id":38691035,"diff_hunk":"@@ -0,0 +1,152 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.IO;\n+using System.Linq;\n+\n+namespace Microsoft.Dnx.Testing\n+{\n+    public class Dir\n+    {\n+        public const string EmptyFile = \"\";\n+        private readonly Dictionary<string, object> _nodes = new Dictionary<string, object>();\n+\n+        public Dir(string rootPath): this()\n+        {\n+            Load(rootPath);\n+        }\n+\n+        public Dir()\n+        {\n+            ReadFile = fileInfo => File.ReadAllText(fileInfo.FullName);\n+        }\n+\n+        public Dir(Dir parent)\n+        {\n+            ReadFile = parent.ReadFile;\n+        }\n+\n+        public Func<FileInfo, object> ReadFile;\n+\n+        public string LoadPath { get; private set; } = \"In Memory\";\n+\n+        public IEnumerable<KeyValuePair<string, object>> Nodes\n+        {\n+            get\n+            {\n+                return _nodes;\n+            }\n+        }\n+\n+        public object this[params string[] keys]\n+        {\n+            set\n+            {\n+                foreach (var key in keys)\n+                {\n+                    _nodes[key] = value;\n+                }\n+            }\n+        }\n+\n+        public void Load(string path)\n+        {\n+            LoadPath = path;\n+            var directory = new DirectoryInfo(path);\n+\n+            foreach (var subDirectoryInfo in directory.EnumerateDirectories())\n+            {\n+                Read(this, subDirectoryInfo);\n+            }\n+\n+            foreach (var file in directory.EnumerateFiles())\n+            {\n+                this[file.Name] = ReadFile(file);\n+            }\n+        }\n+\n+        public void Save(string path)\n+        {\n+            Write(path, this);\n+        }\n+\n+        private void Write(string path, object value)\n+        {\n+            var tree = value as Dir;\n+            if (tree != null)\n+            {\n+                Directory.CreateDirectory(path);\n+\n+                foreach (var node in tree.Nodes)\n+                {\n+                    Write(Path.Combine(path, node.Key), node.Value);\n+                }\n+            }\n+            else\n+            {\n+                Directory.CreateDirectory(Path.GetDirectoryName(path));\n+                File.WriteAllText(path, value?.ToString() ?? string.Empty);\n+            }\n+        }\n+\n+        private static void Read(Dir parent, DirectoryInfo directoryInfo)\n+        {\n+            var directory = new Dir(parent);","path":"test/Microsoft.Dnx.Testing.CommonUtils/Directory/Dir.cs","position":93,"original_position":93,"commit_id":"5f5d2efd6c2739b2bb38727bebece459050677f1","original_commit_id":"5f5d2efd6c2739b2bb38727bebece459050677f1","user":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"body":"There's a lot of duplicated code here and in `Load`. Can we just use `Read` directly in `Load`?","created_at":"2015-09-03T20:14:09Z","updated_at":"2015-09-03T20:14:09Z","html_url":"https://github.com/aspnet/dnx/pull/2627#discussion_r38691035","pull_request_url":"https://api.github.com/repos/aspnet/dnx/pulls/2627","_links":{"self":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/comments/38691035"},"html":{"href":"https://github.com/aspnet/dnx/pull/2627#discussion_r38691035"},"pull_request":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/2627"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/dnx/pulls/2627","id":44144581,"html_url":"https://github.com/aspnet/dnx/pull/2627","diff_url":"https://github.com/aspnet/dnx/pull/2627.diff","patch_url":"https://github.com/aspnet/dnx/pull/2627.patch","issue_url":"https://api.github.com/repos/aspnet/dnx/issues/2627","number":2627,"state":"open","locked":false,"title":"#2617 Adding Wei's work on the new testing infrastructure","user":{"login":"JunTaoLuo","id":2030323,"avatar_url":"https://avatars.githubusercontent.com/u/2030323?v=3","gravatar_id":"","url":"https://api.github.com/users/JunTaoLuo","html_url":"https://github.com/JunTaoLuo","followers_url":"https://api.github.com/users/JunTaoLuo/followers","following_url":"https://api.github.com/users/JunTaoLuo/following{/other_user}","gists_url":"https://api.github.com/users/JunTaoLuo/gists{/gist_id}","starred_url":"https://api.github.com/users/JunTaoLuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JunTaoLuo/subscriptions","organizations_url":"https://api.github.com/users/JunTaoLuo/orgs","repos_url":"https://api.github.com/users/JunTaoLuo/repos","events_url":"https://api.github.com/users/JunTaoLuo/events{/privacy}","received_events_url":"https://api.github.com/users/JunTaoLuo/received_events","type":"User","site_admin":false},"body":"Adding Wei's work on the new testing infrastructure to dnx:\r\n\r\nNew testing utilities are located in test/Microsoft.Dnx.Testing.CommonUtils\r\nSample tests using the new infrastructure are located in test/Microsoft.Dnx.Testing.SampleTests\r\nTest files (dummy solutions and projects) are located in misc/\r\nTests will leave the solutions/projects used during testing under TestOutput/\r\n\r\nSome of the features of the new infrastructure\r\n- Creating projects and solutions is changed. See the sample test in DnuPublishTests.cs for an example.\r\n- Tests can grab preconstructed projects and solutions. See the sample test in DnuRestoreTests.cs for an example.\r\n- dnu calls are now made through DnxSdk.Dnu.<command> where the DnxSdk object specifies the runtime and is passed in to every test.\r\n\r\nPossible future work\r\n- Options for saving or deleting the solutions/projects of the tests. Currently all output is saved and this can lead to clutter in the TestOutput/ directory. Ideally, the output should be saved for failing tests only.\r\n- Relocate some of the hardcoded constants to a centralized file in the style of Microsoft.Dnx.Runtime.EnvironmentNames\r\n- Time limits on tests. Currently all calls to Exec.Run will always wait for the command to finish. To prevent a test from hanging forever maybe we should automatically kill off a test after a certain duration.\r\n- Display difference between files that differ from the expected result in DirDiff.cs","created_at":"2015-09-03T19:04:31Z","updated_at":"2015-09-03T20:14:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fab2a38b439c26cb66210d0310eccffb50fcd555","assignee":{"login":"JunTaoLuo","id":2030323,"avatar_url":"https://avatars.githubusercontent.com/u/2030323?v=3","gravatar_id":"","url":"https://api.github.com/users/JunTaoLuo","html_url":"https://github.com/JunTaoLuo","followers_url":"https://api.github.com/users/JunTaoLuo/followers","following_url":"https://api.github.com/users/JunTaoLuo/following{/other_user}","gists_url":"https://api.github.com/users/JunTaoLuo/gists{/gist_id}","starred_url":"https://api.github.com/users/JunTaoLuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JunTaoLuo/subscriptions","organizations_url":"https://api.github.com/users/JunTaoLuo/orgs","repos_url":"https://api.github.com/users/JunTaoLuo/repos","events_url":"https://api.github.com/users/JunTaoLuo/events{/privacy}","received_events_url":"https://api.github.com/users/JunTaoLuo/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/dnx/milestones/16","html_url":"https://github.com/aspnet/dnx/milestones/1.0.0-beta8","labels_url":"https://api.github.com/repos/aspnet/dnx/milestones/16/labels","id":1224345,"number":16,"title":"1.0.0-beta8","description":null,"creator":{"login":"muratg","id":1808428,"avatar_url":"https://avatars.githubusercontent.com/u/1808428?v=3","gravatar_id":"","url":"https://api.github.com/users/muratg","html_url":"https://github.com/muratg","followers_url":"https://api.github.com/users/muratg/followers","following_url":"https://api.github.com/users/muratg/following{/other_user}","gists_url":"https://api.github.com/users/muratg/gists{/gist_id}","starred_url":"https://api.github.com/users/muratg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muratg/subscriptions","organizations_url":"https://api.github.com/users/muratg/orgs","repos_url":"https://api.github.com/users/muratg/repos","events_url":"https://api.github.com/users/muratg/events{/privacy}","received_events_url":"https://api.github.com/users/muratg/received_events","type":"User","site_admin":false},"open_issues":51,"closed_issues":16,"state":"open","created_at":"2015-07-24T16:37:05Z","updated_at":"2015-09-03T19:04:31Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/aspnet/dnx/pulls/2627/commits","review_comments_url":"https://api.github.com/repos/aspnet/dnx/pulls/2627/comments","review_comment_url":"https://api.github.com/repos/aspnet/dnx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/dnx/issues/2627/comments","statuses_url":"https://api.github.com/repos/aspnet/dnx/statuses/5f5d2efd6c2739b2bb38727bebece459050677f1","head":{"label":"aspnet:johluo/new-testing-infrastructure","ref":"johluo/new-testing-infrastructure","sha":"5f5d2efd6c2739b2bb38727bebece459050677f1","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":14225208,"name":"dnx","full_name":"aspnet/dnx","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/dnx","description":"The DNX (a .NET Execution Environment) contains the code required to bootstrap and run an application, including the compilation system, SDK tools, and the native CLR hosts.","fork":false,"url":"https://api.github.com/repos/aspnet/dnx","forks_url":"https://api.github.com/repos/aspnet/dnx/forks","keys_url":"https://api.github.com/repos/aspnet/dnx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/dnx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/dnx/teams","hooks_url":"https://api.github.com/repos/aspnet/dnx/hooks","issue_events_url":"https://api.github.com/repos/aspnet/dnx/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/dnx/events","assignees_url":"https://api.github.com/repos/aspnet/dnx/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/dnx/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/dnx/tags","blobs_url":"https://api.github.com/repos/aspnet/dnx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/dnx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/dnx/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/dnx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/dnx/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/dnx/languages","stargazers_url":"https://api.github.com/repos/aspnet/dnx/stargazers","contributors_url":"https://api.github.com/repos/aspnet/dnx/contributors","subscribers_url":"https://api.github.com/repos/aspnet/dnx/subscribers","subscription_url":"https://api.github.com/repos/aspnet/dnx/subscription","commits_url":"https://api.github.com/repos/aspnet/dnx/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/dnx/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/dnx/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/dnx/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/dnx/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/dnx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/dnx/merges","archive_url":"https://api.github.com/repos/aspnet/dnx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/dnx/downloads","issues_url":"https://api.github.com/repos/aspnet/dnx/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/dnx/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/dnx/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/dnx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/dnx/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/dnx/releases{/id}","created_at":"2013-11-08T06:01:29Z","updated_at":"2015-09-03T20:14:06Z","pushed_at":"2015-09-03T19:49:26Z","git_url":"git://github.com/aspnet/dnx.git","ssh_url":"git@github.com:aspnet/dnx.git","clone_url":"https://github.com/aspnet/dnx.git","svn_url":"https://github.com/aspnet/dnx","homepage":"","size":56619,"stargazers_count":875,"watchers_count":875,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":207,"mirror_url":null,"open_issues_count":402,"forks":207,"open_issues":402,"watchers":875,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"1c7636c2ef1f03537ac8cfe30c229e77c938b422","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":14225208,"name":"dnx","full_name":"aspnet/dnx","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/dnx","description":"The DNX (a .NET Execution Environment) contains the code required to bootstrap and run an application, including the compilation system, SDK tools, and the native CLR hosts.","fork":false,"url":"https://api.github.com/repos/aspnet/dnx","forks_url":"https://api.github.com/repos/aspnet/dnx/forks","keys_url":"https://api.github.com/repos/aspnet/dnx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/dnx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/dnx/teams","hooks_url":"https://api.github.com/repos/aspnet/dnx/hooks","issue_events_url":"https://api.github.com/repos/aspnet/dnx/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/dnx/events","assignees_url":"https://api.github.com/repos/aspnet/dnx/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/dnx/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/dnx/tags","blobs_url":"https://api.github.com/repos/aspnet/dnx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/dnx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/dnx/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/dnx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/dnx/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/dnx/languages","stargazers_url":"https://api.github.com/repos/aspnet/dnx/stargazers","contributors_url":"https://api.github.com/repos/aspnet/dnx/contributors","subscribers_url":"https://api.github.com/repos/aspnet/dnx/subscribers","subscription_url":"https://api.github.com/repos/aspnet/dnx/subscription","commits_url":"https://api.github.com/repos/aspnet/dnx/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/dnx/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/dnx/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/dnx/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/dnx/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/dnx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/dnx/merges","archive_url":"https://api.github.com/repos/aspnet/dnx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/dnx/downloads","issues_url":"https://api.github.com/repos/aspnet/dnx/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/dnx/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/dnx/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/dnx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/dnx/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/dnx/releases{/id}","created_at":"2013-11-08T06:01:29Z","updated_at":"2015-09-03T20:14:06Z","pushed_at":"2015-09-03T19:49:26Z","git_url":"git://github.com/aspnet/dnx.git","ssh_url":"git@github.com:aspnet/dnx.git","clone_url":"https://github.com/aspnet/dnx.git","svn_url":"https://github.com/aspnet/dnx","homepage":"","size":56619,"stargazers_count":875,"watchers_count":875,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":207,"mirror_url":null,"open_issues_count":402,"forks":207,"open_issues":402,"watchers":875,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/2627"},"html":{"href":"https://github.com/aspnet/dnx/pull/2627"},"issue":{"href":"https://api.github.com/repos/aspnet/dnx/issues/2627"},"comments":{"href":"https://api.github.com/repos/aspnet/dnx/issues/2627/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/2627/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/dnx/pulls/2627/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/dnx/statuses/5f5d2efd6c2739b2bb38727bebece459050677f1"}}}}