{"action":"created","comment":{"url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/comments/91828229","pull_request_review_id":12341282,"id":91828229,"diff_hunk":"@@ -353,6 +353,53 @@ def get_files_changed():\n             for item in files[:-1].split(\"\\0\")]\n \n \n+def get_affected_testfiles(files_changed):\n+    affected_testfiles = []\n+    ignore_dirs = [\"conformance-checkers\", \"docs\"]\n+    manifest_file = os.path.join(os.path.abspath(os.curdir), \"w3c\", \"web-platform-tests\", \"MANIFEST.json\")\n+    with open(manifest_file, \"r\") as fh:\n+        manifest_contents = fh.read()\n+    for changedfile_pathname in files_changed:\n+        repo_root = os.path.abspath(os.path.join(os.path.abspath(os.curdir), \"w3c\", \"web-platform-tests\"))\n+        changed_file_repo_path = changedfile_pathname[len(repo_root):]\n+        if changed_file_repo_path in manifest_contents:\n+            # This changed file is actually a test, so skip it.\n+            continue\n+        os.path.normpath(changed_file_repo_path)\n+        path_components = changed_file_repo_path.split(os.sep)[1:]\n+        if len(path_components) < 2:\n+            # This changed file is in the repo root, so skip it\n+            # (because it's not part of any test).\n+            continue\n+        top_level_subdir = changed_file_repo_path.split(os.sep)[1]\n+        if top_level_subdir in ignore_dirs:\n+            continue\n+        # OK, this changed file is the kind we care about: It's something\n+        # other than a test (e.g., it's a .js or .json file), and it's\n+        # somewhere down beneath one of the top-level \"spec\" directories.\n+        # So now we try to find any tests that reference it.\n+        for root, dirs, fnames in os.walk(os.path.join(repo_root, top_level_subdir)):\n+            # Walk top_level_subdir looking for test files containing either the\n+            # relative filepath or absolute filepatch to the changed file.\n+            for fname in fnames:\n+                testfile_full_path = os.path.join(repo_root, root, fname)\n+                # Skip any file that's already in files_changed.\n+                if testfile_full_path in files_changed:\n+                    continue\n+                # Skip any file that's not a test file.\n+                if os.path.splitext(testfile_full_path)[1] not in manifest_contents:\n+                    continue\n+                if not os.path.isfile(testfile_full_path):\n+                    continue\n+                with open(testfile_full_path, \"r\") as fh:\n+                    file_contents = fh.read()\n+                    curdir = os.path.dirname(testfile_full_path)\n+                    changed_file_relpath = os.path.relpath(changedfile_pathname, curdir)\n+                    if changed_file_relpath in file_contents or changedfile_pathname in file_contents:","path":"check_stability.py","position":46,"original_position":46,"commit_id":"49c96bf4a18679a40b23d3d2b406a7a0638a9d56","original_commit_id":"49c96bf4a18679a40b23d3d2b406a7a0638a9d56","user":{"login":"jgraham","id":294864,"avatar_url":"https://avatars.githubusercontent.com/u/294864?v=3","gravatar_id":"","url":"https://api.github.com/users/jgraham","html_url":"https://github.com/jgraham","followers_url":"https://api.github.com/users/jgraham/followers","following_url":"https://api.github.com/users/jgraham/following{/other_user}","gists_url":"https://api.github.com/users/jgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/jgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgraham/subscriptions","organizations_url":"https://api.github.com/users/jgraham/orgs","repos_url":"https://api.github.com/users/jgraham/repos","events_url":"https://api.github.com/users/jgraham/events{/privacy}","received_events_url":"https://api.github.com/users/jgraham/received_events","type":"User","site_admin":false},"body":"This should be changed_file_repo_path, right? (possibly modulo a leading `/`).\r\n\r\nAlso you should replace the path separator with `/` for the benefit of Windows in case we ever run this there.","created_at":"2016-12-10T03:56:18Z","updated_at":"2016-12-10T03:56:31Z","html_url":"https://github.com/w3c/web-platform-tests/pull/4100#discussion_r91828229","pull_request_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100","_links":{"self":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/comments/91828229"},"html":{"href":"https://github.com/w3c/web-platform-tests/pull/4100#discussion_r91828229"},"pull_request":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100"}}},"pull_request":{"url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100","id":91342960,"html_url":"https://github.com/w3c/web-platform-tests/pull/4100","diff_url":"https://github.com/w3c/web-platform-tests/pull/4100.diff","patch_url":"https://github.com/w3c/web-platform-tests/pull/4100.patch","issue_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/4100","number":4100,"state":"open","locked":false,"title":"Find affected test files when support files change, and run stability checker on the tests","user":{"login":"sideshowbarker","id":194984,"avatar_url":"https://avatars.githubusercontent.com/u/194984?v=3","gravatar_id":"","url":"https://api.github.com/users/sideshowbarker","html_url":"https://github.com/sideshowbarker","followers_url":"https://api.github.com/users/sideshowbarker/followers","following_url":"https://api.github.com/users/sideshowbarker/following{/other_user}","gists_url":"https://api.github.com/users/sideshowbarker/gists{/gist_id}","starred_url":"https://api.github.com/users/sideshowbarker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sideshowbarker/subscriptions","organizations_url":"https://api.github.com/users/sideshowbarker/orgs","repos_url":"https://api.github.com/users/sideshowbarker/repos","events_url":"https://api.github.com/users/sideshowbarker/events{/privacy}","received_events_url":"https://api.github.com/users/sideshowbarker/received_events","type":"User","site_admin":false},"body":"Currently if the only changes in a PR are to `.js[on]` file, the stability checker doesn’t run any tests—because it doesn’t know which tests to run.\n\nThe patch in this PR causes the stability checker to:\n1. Walk the parent of the subdirectory the changed `.js[on]` file is from.\n2. Find any test files that contain the name of the changed `.js[on]` file.\n3. Append the found test files to the list of test files given to `wptrunner` to run.\n","created_at":"2016-10-28T08:42:35Z","updated_at":"2016-12-10T03:56:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"697bc7e44cf645b4b1087c310e988bb214bd754c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100/commits","review_comments_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100/comments","review_comment_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/4100/comments","statuses_url":"https://api.github.com/repos/w3c/web-platform-tests/statuses/49c96bf4a18679a40b23d3d2b406a7a0638a9d56","head":{"label":"w3c:sideshowbarker/stability-add-affected-tests","ref":"sideshowbarker/stability-add-affected-tests","sha":"49c96bf4a18679a40b23d3d2b406a7a0638a9d56","user":{"login":"w3c","id":379216,"avatar_url":"https://avatars.githubusercontent.com/u/379216?v=3","gravatar_id":"","url":"https://api.github.com/users/w3c","html_url":"https://github.com/w3c","followers_url":"https://api.github.com/users/w3c/followers","following_url":"https://api.github.com/users/w3c/following{/other_user}","gists_url":"https://api.github.com/users/w3c/gists{/gist_id}","starred_url":"https://api.github.com/users/w3c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w3c/subscriptions","organizations_url":"https://api.github.com/users/w3c/orgs","repos_url":"https://api.github.com/users/w3c/repos","events_url":"https://api.github.com/users/w3c/events{/privacy}","received_events_url":"https://api.github.com/users/w3c/received_events","type":"Organization","site_admin":false},"repo":{"id":3618133,"name":"web-platform-tests","full_name":"w3c/web-platform-tests","owner":{"login":"w3c","id":379216,"avatar_url":"https://avatars.githubusercontent.com/u/379216?v=3","gravatar_id":"","url":"https://api.github.com/users/w3c","html_url":"https://github.com/w3c","followers_url":"https://api.github.com/users/w3c/followers","following_url":"https://api.github.com/users/w3c/following{/other_user}","gists_url":"https://api.github.com/users/w3c/gists{/gist_id}","starred_url":"https://api.github.com/users/w3c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w3c/subscriptions","organizations_url":"https://api.github.com/users/w3c/orgs","repos_url":"https://api.github.com/users/w3c/repos","events_url":"https://api.github.com/users/w3c/events{/privacy}","received_events_url":"https://api.github.com/users/w3c/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/w3c/web-platform-tests","description":"Test Suites for Web Platform specifications—including WHATWG, W3C and others","fork":false,"url":"https://api.github.com/repos/w3c/web-platform-tests","forks_url":"https://api.github.com/repos/w3c/web-platform-tests/forks","keys_url":"https://api.github.com/repos/w3c/web-platform-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/w3c/web-platform-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/w3c/web-platform-tests/teams","hooks_url":"https://api.github.com/repos/w3c/web-platform-tests/hooks","issue_events_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/events{/number}","events_url":"https://api.github.com/repos/w3c/web-platform-tests/events","assignees_url":"https://api.github.com/repos/w3c/web-platform-tests/assignees{/user}","branches_url":"https://api.github.com/repos/w3c/web-platform-tests/branches{/branch}","tags_url":"https://api.github.com/repos/w3c/web-platform-tests/tags","blobs_url":"https://api.github.com/repos/w3c/web-platform-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/w3c/web-platform-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/w3c/web-platform-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/w3c/web-platform-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/w3c/web-platform-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/w3c/web-platform-tests/languages","stargazers_url":"https://api.github.com/repos/w3c/web-platform-tests/stargazers","contributors_url":"https://api.github.com/repos/w3c/web-platform-tests/contributors","subscribers_url":"https://api.github.com/repos/w3c/web-platform-tests/subscribers","subscription_url":"https://api.github.com/repos/w3c/web-platform-tests/subscription","commits_url":"https://api.github.com/repos/w3c/web-platform-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/w3c/web-platform-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/w3c/web-platform-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/w3c/web-platform-tests/contents/{+path}","compare_url":"https://api.github.com/repos/w3c/web-platform-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/w3c/web-platform-tests/merges","archive_url":"https://api.github.com/repos/w3c/web-platform-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/w3c/web-platform-tests/downloads","issues_url":"https://api.github.com/repos/w3c/web-platform-tests/issues{/number}","pulls_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/w3c/web-platform-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/w3c/web-platform-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/w3c/web-platform-tests/labels{/name}","releases_url":"https://api.github.com/repos/w3c/web-platform-tests/releases{/id}","deployments_url":"https://api.github.com/repos/w3c/web-platform-tests/deployments","created_at":"2012-03-04T12:58:11Z","updated_at":"2016-12-09T07:34:20Z","pushed_at":"2016-12-10T01:58:50Z","git_url":"git://github.com/w3c/web-platform-tests.git","ssh_url":"git@github.com:w3c/web-platform-tests.git","clone_url":"https://github.com/w3c/web-platform-tests.git","svn_url":"https://github.com/w3c/web-platform-tests","homepage":"http://irc.w3.org/?channels=testing","size":341955,"stargazers_count":899,"watchers_count":899,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":974,"mirror_url":null,"open_issues_count":429,"forks":974,"open_issues":429,"watchers":899,"default_branch":"master"}},"base":{"label":"w3c:master","ref":"master","sha":"8e114c6cc3907f8c7e0866483c9c53a62d08d9c8","user":{"login":"w3c","id":379216,"avatar_url":"https://avatars.githubusercontent.com/u/379216?v=3","gravatar_id":"","url":"https://api.github.com/users/w3c","html_url":"https://github.com/w3c","followers_url":"https://api.github.com/users/w3c/followers","following_url":"https://api.github.com/users/w3c/following{/other_user}","gists_url":"https://api.github.com/users/w3c/gists{/gist_id}","starred_url":"https://api.github.com/users/w3c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w3c/subscriptions","organizations_url":"https://api.github.com/users/w3c/orgs","repos_url":"https://api.github.com/users/w3c/repos","events_url":"https://api.github.com/users/w3c/events{/privacy}","received_events_url":"https://api.github.com/users/w3c/received_events","type":"Organization","site_admin":false},"repo":{"id":3618133,"name":"web-platform-tests","full_name":"w3c/web-platform-tests","owner":{"login":"w3c","id":379216,"avatar_url":"https://avatars.githubusercontent.com/u/379216?v=3","gravatar_id":"","url":"https://api.github.com/users/w3c","html_url":"https://github.com/w3c","followers_url":"https://api.github.com/users/w3c/followers","following_url":"https://api.github.com/users/w3c/following{/other_user}","gists_url":"https://api.github.com/users/w3c/gists{/gist_id}","starred_url":"https://api.github.com/users/w3c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w3c/subscriptions","organizations_url":"https://api.github.com/users/w3c/orgs","repos_url":"https://api.github.com/users/w3c/repos","events_url":"https://api.github.com/users/w3c/events{/privacy}","received_events_url":"https://api.github.com/users/w3c/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/w3c/web-platform-tests","description":"Test Suites for Web Platform specifications—including WHATWG, W3C and others","fork":false,"url":"https://api.github.com/repos/w3c/web-platform-tests","forks_url":"https://api.github.com/repos/w3c/web-platform-tests/forks","keys_url":"https://api.github.com/repos/w3c/web-platform-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/w3c/web-platform-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/w3c/web-platform-tests/teams","hooks_url":"https://api.github.com/repos/w3c/web-platform-tests/hooks","issue_events_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/events{/number}","events_url":"https://api.github.com/repos/w3c/web-platform-tests/events","assignees_url":"https://api.github.com/repos/w3c/web-platform-tests/assignees{/user}","branches_url":"https://api.github.com/repos/w3c/web-platform-tests/branches{/branch}","tags_url":"https://api.github.com/repos/w3c/web-platform-tests/tags","blobs_url":"https://api.github.com/repos/w3c/web-platform-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/w3c/web-platform-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/w3c/web-platform-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/w3c/web-platform-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/w3c/web-platform-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/w3c/web-platform-tests/languages","stargazers_url":"https://api.github.com/repos/w3c/web-platform-tests/stargazers","contributors_url":"https://api.github.com/repos/w3c/web-platform-tests/contributors","subscribers_url":"https://api.github.com/repos/w3c/web-platform-tests/subscribers","subscription_url":"https://api.github.com/repos/w3c/web-platform-tests/subscription","commits_url":"https://api.github.com/repos/w3c/web-platform-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/w3c/web-platform-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/w3c/web-platform-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/w3c/web-platform-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/w3c/web-platform-tests/contents/{+path}","compare_url":"https://api.github.com/repos/w3c/web-platform-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/w3c/web-platform-tests/merges","archive_url":"https://api.github.com/repos/w3c/web-platform-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/w3c/web-platform-tests/downloads","issues_url":"https://api.github.com/repos/w3c/web-platform-tests/issues{/number}","pulls_url":"https://api.github.com/repos/w3c/web-platform-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/w3c/web-platform-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/w3c/web-platform-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/w3c/web-platform-tests/labels{/name}","releases_url":"https://api.github.com/repos/w3c/web-platform-tests/releases{/id}","deployments_url":"https://api.github.com/repos/w3c/web-platform-tests/deployments","created_at":"2012-03-04T12:58:11Z","updated_at":"2016-12-09T07:34:20Z","pushed_at":"2016-12-10T01:58:50Z","git_url":"git://github.com/w3c/web-platform-tests.git","ssh_url":"git@github.com:w3c/web-platform-tests.git","clone_url":"https://github.com/w3c/web-platform-tests.git","svn_url":"https://github.com/w3c/web-platform-tests","homepage":"http://irc.w3.org/?channels=testing","size":341955,"stargazers_count":899,"watchers_count":899,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":974,"mirror_url":null,"open_issues_count":429,"forks":974,"open_issues":429,"watchers":899,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100"},"html":{"href":"https://github.com/w3c/web-platform-tests/pull/4100"},"issue":{"href":"https://api.github.com/repos/w3c/web-platform-tests/issues/4100"},"comments":{"href":"https://api.github.com/repos/w3c/web-platform-tests/issues/4100/comments"},"review_comments":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100/comments"},"review_comment":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/w3c/web-platform-tests/pulls/4100/commits"},"statuses":{"href":"https://api.github.com/repos/w3c/web-platform-tests/statuses/49c96bf4a18679a40b23d3d2b406a7a0638a9d56"}}}}
{"actor":{"display_login":"jgraham"}}