{"action":"created","comment":{"url":"https://api.github.com/repos/flowtype/flow-typed/pulls/comments/56505011","id":56505011,"diff_hunk":"@@ -0,0 +1,417 @@\n+// @flow\n+\n+import {child_process, fs, os, path} from \"../lib/node.js\";\n+import {copyFile, recursiveRmdir} from \"../lib/fileUtils.js\";\n+import {\n+  DEFINITIONS_DIR,\n+  getPkgNames,\n+  getPkgVersions,\n+  getFlowVersionsForPkgVersion,\n+  getTestsInPath,\n+  getTestsForPkgVersionFlowVersion,\n+} from \"../lib/definitions.js\";\n+\n+import GitHub from \"github\";\n+import request from \"request\";\n+import * as semver from \"semver\";\n+\n+// Used to decide which binary to fetch for each version of Flow\n+const BIN_PLATFORM = (_ => {\n+  const type = os.type();\n+  switch (type) {\n+    case \"Linux\": return \"linux64\";\n+    case \"Darwin\": return \"osx\";\n+    default: throw new Error(\n+      \"Unsupported os.type()! \" + type\n+    );\n+  }\n+})();\n+const PKG_ROOT_DIR = path.join(__dirname, \"..\", \"..\");\n+const TEST_DIR = path.join(PKG_ROOT_DIR, \"test-dir\");\n+const BIN_DIR = path.join(PKG_ROOT_DIR, \"flow-bins\");\n+const P = Promise;\n+\n+type TestGroup = {\n+  id: string,\n+  testFilePaths: Array<string>,\n+  libDefPath: string,\n+  flowVersion: string,\n+};\n+\n+/**\n+ * Scan the definitions/ directory to extract a flat list of TestGroup\n+ * structs. Each TestGroup represents a Package/PackageVersion/FlowVersion\n+ * directory.\n+ */\n+async function getTestGroups(): Promise<Array<TestGroup>> {\n+  const pkgNames = await getPkgNames();\n+  const pkgNameVers = await P.all(pkgNames.map(getPkgVersions));\n+\n+  const testGroups = [];\n+  await P.all(pkgNames.map(async (pkgName, idx) => {\n+    await P.all(pkgNameVers[idx].map(async (pkgVer) => {\n+      const flowVersions = await getFlowVersionsForPkgVersion(pkgName, pkgVer);\n+      const pkgVerDirPath = path.join(DEFINITIONS_DIR, pkgName, pkgVer);\n+\n+      const pkgVerTestPaths = (await getTestsInPath(pkgVerDirPath)).map(\n+        fileName => path.join(pkgVerDirPath, fileName)\n+      );\n+\n+      await P.all(flowVersions.map(async (flowVer) => {\n+        const flowVerDirPath = path.join(pkgVerDirPath, \"flow-\" + flowVer);\n+\n+        const flowVerTestPaths = (await getTestsInPath(flowVerDirPath)).map(\n+          fileName => path.join(flowVerDirPath, fileName)\n+        );\n+        pkgVerTestPaths.forEach(p => flowVerTestPaths.push(p));\n+\n+        testGroups.push({\n+          id: pkgName + \"-\" + pkgVer + \"-flow-\" + flowVer,\n+          testFilePaths: flowVerTestPaths,\n+          libDefPath: path.join(flowVerDirPath, pkgName + \"-\" + pkgVer + \".js\"),\n+          flowVersion: flowVer,\n+        });\n+      }));\n+    }))\n+  }))\n+  return testGroups;\n+}\n+\n+function binSearchArray<T>(arr: Array<T>, testFn: (elem: T) => number): ?T {","path":"npm/src/commands/runTests.js","position":80,"original_position":80,"commit_id":"59923b3d289e441a1a1d1fdde44af433a519b879","original_commit_id":"59923b3d289e441a1a1d1fdde44af433a519b879","user":{"login":"jeffmo","id":498293,"avatar_url":"https://avatars.githubusercontent.com/u/498293?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmo","html_url":"https://github.com/jeffmo","followers_url":"https://api.github.com/users/jeffmo/followers","following_url":"https://api.github.com/users/jeffmo/following{/other_user}","gists_url":"https://api.github.com/users/jeffmo/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmo/subscriptions","organizations_url":"https://api.github.com/users/jeffmo/orgs","repos_url":"https://api.github.com/users/jeffmo/repos","events_url":"https://api.github.com/users/jeffmo/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmo/received_events","type":"User","site_admin":false},"body":"good catch","created_at":"2016-03-17T13:43:57Z","updated_at":"2016-03-17T13:43:57Z","html_url":"https://github.com/flowtype/flow-typed/pull/15#discussion_r56505011","pull_request_url":"https://api.github.com/repos/flowtype/flow-typed/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/comments/56505011"},"html":{"href":"https://github.com/flowtype/flow-typed/pull/15#discussion_r56505011"},"pull_request":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/flowtype/flow-typed/pulls/15","id":63105751,"html_url":"https://github.com/flowtype/flow-typed/pull/15","diff_url":"https://github.com/flowtype/flow-typed/pull/15.diff","patch_url":"https://github.com/flowtype/flow-typed/pull/15.patch","issue_url":"https://api.github.com/repos/flowtype/flow-typed/issues/15","number":15,"state":"open","locked":false,"title":"Add a test runner","user":{"login":"jeffmo","id":498293,"avatar_url":"https://avatars.githubusercontent.com/u/498293?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmo","html_url":"https://github.com/jeffmo","followers_url":"https://api.github.com/users/jeffmo/followers","following_url":"https://api.github.com/users/jeffmo/following{/other_user}","gists_url":"https://api.github.com/users/jeffmo/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmo/subscriptions","organizations_url":"https://api.github.com/users/jeffmo/orgs","repos_url":"https://api.github.com/users/jeffmo/repos","events_url":"https://api.github.com/users/jeffmo/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmo/received_events","type":"User","site_admin":false},"body":"`flow-typed run-tests [opt-test-name-pattern]`\r\n\r\nRunning tests means the following: \r\n\r\n1. For each Package/Version/FlowVersion directory, find all versions of Flow that satisfy the specified Flow version\r\n1. Copy the libdef + all test files into a directory with a .flowconfig specifying a \"$ExpectError\" suppression comment\r\n1. Run `flow check` for each resolved version of Flow on the test directory. If there are any errors, assert them.\r\n\r\nThis also adds `run-tests` to the travis command","created_at":"2016-03-16T17:38:12Z","updated_at":"2016-03-17T13:43:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f517e20d034eab847f1e018aedeae44470a79d92","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flowtype/flow-typed/pulls/15/commits","review_comments_url":"https://api.github.com/repos/flowtype/flow-typed/pulls/15/comments","review_comment_url":"https://api.github.com/repos/flowtype/flow-typed/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flowtype/flow-typed/issues/15/comments","statuses_url":"https://api.github.com/repos/flowtype/flow-typed/statuses/59923b3d289e441a1a1d1fdde44af433a519b879","head":{"label":"jeffmo:test_runner","ref":"test_runner","sha":"59923b3d289e441a1a1d1fdde44af433a519b879","user":{"login":"jeffmo","id":498293,"avatar_url":"https://avatars.githubusercontent.com/u/498293?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmo","html_url":"https://github.com/jeffmo","followers_url":"https://api.github.com/users/jeffmo/followers","following_url":"https://api.github.com/users/jeffmo/following{/other_user}","gists_url":"https://api.github.com/users/jeffmo/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmo/subscriptions","organizations_url":"https://api.github.com/users/jeffmo/orgs","repos_url":"https://api.github.com/users/jeffmo/repos","events_url":"https://api.github.com/users/jeffmo/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmo/received_events","type":"User","site_admin":false},"repo":{"id":53622648,"name":"flow-typed","full_name":"jeffmo/flow-typed","owner":{"login":"jeffmo","id":498293,"avatar_url":"https://avatars.githubusercontent.com/u/498293?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmo","html_url":"https://github.com/jeffmo","followers_url":"https://api.github.com/users/jeffmo/followers","following_url":"https://api.github.com/users/jeffmo/following{/other_user}","gists_url":"https://api.github.com/users/jeffmo/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmo/subscriptions","organizations_url":"https://api.github.com/users/jeffmo/orgs","repos_url":"https://api.github.com/users/jeffmo/repos","events_url":"https://api.github.com/users/jeffmo/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeffmo/flow-typed","description":"A central repository for Flow library definitions","fork":true,"url":"https://api.github.com/repos/jeffmo/flow-typed","forks_url":"https://api.github.com/repos/jeffmo/flow-typed/forks","keys_url":"https://api.github.com/repos/jeffmo/flow-typed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeffmo/flow-typed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeffmo/flow-typed/teams","hooks_url":"https://api.github.com/repos/jeffmo/flow-typed/hooks","issue_events_url":"https://api.github.com/repos/jeffmo/flow-typed/issues/events{/number}","events_url":"https://api.github.com/repos/jeffmo/flow-typed/events","assignees_url":"https://api.github.com/repos/jeffmo/flow-typed/assignees{/user}","branches_url":"https://api.github.com/repos/jeffmo/flow-typed/branches{/branch}","tags_url":"https://api.github.com/repos/jeffmo/flow-typed/tags","blobs_url":"https://api.github.com/repos/jeffmo/flow-typed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeffmo/flow-typed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeffmo/flow-typed/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeffmo/flow-typed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeffmo/flow-typed/statuses/{sha}","languages_url":"https://api.github.com/repos/jeffmo/flow-typed/languages","stargazers_url":"https://api.github.com/repos/jeffmo/flow-typed/stargazers","contributors_url":"https://api.github.com/repos/jeffmo/flow-typed/contributors","subscribers_url":"https://api.github.com/repos/jeffmo/flow-typed/subscribers","subscription_url":"https://api.github.com/repos/jeffmo/flow-typed/subscription","commits_url":"https://api.github.com/repos/jeffmo/flow-typed/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeffmo/flow-typed/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeffmo/flow-typed/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeffmo/flow-typed/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeffmo/flow-typed/contents/{+path}","compare_url":"https://api.github.com/repos/jeffmo/flow-typed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeffmo/flow-typed/merges","archive_url":"https://api.github.com/repos/jeffmo/flow-typed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeffmo/flow-typed/downloads","issues_url":"https://api.github.com/repos/jeffmo/flow-typed/issues{/number}","pulls_url":"https://api.github.com/repos/jeffmo/flow-typed/pulls{/number}","milestones_url":"https://api.github.com/repos/jeffmo/flow-typed/milestones{/number}","notifications_url":"https://api.github.com/repos/jeffmo/flow-typed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeffmo/flow-typed/labels{/name}","releases_url":"https://api.github.com/repos/jeffmo/flow-typed/releases{/id}","deployments_url":"https://api.github.com/repos/jeffmo/flow-typed/deployments","created_at":"2016-03-10T22:47:26Z","updated_at":"2016-03-10T22:47:27Z","pushed_at":"2016-03-16T18:01:10Z","git_url":"git://github.com/jeffmo/flow-typed.git","ssh_url":"git@github.com:jeffmo/flow-typed.git","clone_url":"https://github.com/jeffmo/flow-typed.git","svn_url":"https://github.com/jeffmo/flow-typed","homepage":"","size":48,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"flowtype:master","ref":"master","sha":"bb2b9acf24c2aaa163cd2b1cb9d616e496c1bfd5","user":{"login":"flowtype","id":15352388,"avatar_url":"https://avatars.githubusercontent.com/u/15352388?v=3","gravatar_id":"","url":"https://api.github.com/users/flowtype","html_url":"https://github.com/flowtype","followers_url":"https://api.github.com/users/flowtype/followers","following_url":"https://api.github.com/users/flowtype/following{/other_user}","gists_url":"https://api.github.com/users/flowtype/gists{/gist_id}","starred_url":"https://api.github.com/users/flowtype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowtype/subscriptions","organizations_url":"https://api.github.com/users/flowtype/orgs","repos_url":"https://api.github.com/users/flowtype/repos","events_url":"https://api.github.com/users/flowtype/events{/privacy}","received_events_url":"https://api.github.com/users/flowtype/received_events","type":"Organization","site_admin":false},"repo":{"id":42698429,"name":"flow-typed","full_name":"flowtype/flow-typed","owner":{"login":"flowtype","id":15352388,"avatar_url":"https://avatars.githubusercontent.com/u/15352388?v=3","gravatar_id":"","url":"https://api.github.com/users/flowtype","html_url":"https://github.com/flowtype","followers_url":"https://api.github.com/users/flowtype/followers","following_url":"https://api.github.com/users/flowtype/following{/other_user}","gists_url":"https://api.github.com/users/flowtype/gists{/gist_id}","starred_url":"https://api.github.com/users/flowtype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowtype/subscriptions","organizations_url":"https://api.github.com/users/flowtype/orgs","repos_url":"https://api.github.com/users/flowtype/repos","events_url":"https://api.github.com/users/flowtype/events{/privacy}","received_events_url":"https://api.github.com/users/flowtype/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flowtype/flow-typed","description":"A central repository for Flow library definitions","fork":false,"url":"https://api.github.com/repos/flowtype/flow-typed","forks_url":"https://api.github.com/repos/flowtype/flow-typed/forks","keys_url":"https://api.github.com/repos/flowtype/flow-typed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flowtype/flow-typed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flowtype/flow-typed/teams","hooks_url":"https://api.github.com/repos/flowtype/flow-typed/hooks","issue_events_url":"https://api.github.com/repos/flowtype/flow-typed/issues/events{/number}","events_url":"https://api.github.com/repos/flowtype/flow-typed/events","assignees_url":"https://api.github.com/repos/flowtype/flow-typed/assignees{/user}","branches_url":"https://api.github.com/repos/flowtype/flow-typed/branches{/branch}","tags_url":"https://api.github.com/repos/flowtype/flow-typed/tags","blobs_url":"https://api.github.com/repos/flowtype/flow-typed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flowtype/flow-typed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flowtype/flow-typed/git/refs{/sha}","trees_url":"https://api.github.com/repos/flowtype/flow-typed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flowtype/flow-typed/statuses/{sha}","languages_url":"https://api.github.com/repos/flowtype/flow-typed/languages","stargazers_url":"https://api.github.com/repos/flowtype/flow-typed/stargazers","contributors_url":"https://api.github.com/repos/flowtype/flow-typed/contributors","subscribers_url":"https://api.github.com/repos/flowtype/flow-typed/subscribers","subscription_url":"https://api.github.com/repos/flowtype/flow-typed/subscription","commits_url":"https://api.github.com/repos/flowtype/flow-typed/commits{/sha}","git_commits_url":"https://api.github.com/repos/flowtype/flow-typed/git/commits{/sha}","comments_url":"https://api.github.com/repos/flowtype/flow-typed/comments{/number}","issue_comment_url":"https://api.github.com/repos/flowtype/flow-typed/issues/comments{/number}","contents_url":"https://api.github.com/repos/flowtype/flow-typed/contents/{+path}","compare_url":"https://api.github.com/repos/flowtype/flow-typed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flowtype/flow-typed/merges","archive_url":"https://api.github.com/repos/flowtype/flow-typed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flowtype/flow-typed/downloads","issues_url":"https://api.github.com/repos/flowtype/flow-typed/issues{/number}","pulls_url":"https://api.github.com/repos/flowtype/flow-typed/pulls{/number}","milestones_url":"https://api.github.com/repos/flowtype/flow-typed/milestones{/number}","notifications_url":"https://api.github.com/repos/flowtype/flow-typed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flowtype/flow-typed/labels{/name}","releases_url":"https://api.github.com/repos/flowtype/flow-typed/releases{/id}","deployments_url":"https://api.github.com/repos/flowtype/flow-typed/deployments","created_at":"2015-09-18T03:51:49Z","updated_at":"2016-03-17T08:29:10Z","pushed_at":"2016-03-16T18:01:11Z","git_url":"git://github.com/flowtype/flow-typed.git","ssh_url":"git@github.com:flowtype/flow-typed.git","clone_url":"https://github.com/flowtype/flow-typed.git","svn_url":"https://github.com/flowtype/flow-typed","homepage":"","size":35,"stargazers_count":61,"watchers_count":61,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":4,"forks":5,"open_issues":4,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/15"},"html":{"href":"https://github.com/flowtype/flow-typed/pull/15"},"issue":{"href":"https://api.github.com/repos/flowtype/flow-typed/issues/15"},"comments":{"href":"https://api.github.com/repos/flowtype/flow-typed/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flowtype/flow-typed/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/flowtype/flow-typed/statuses/59923b3d289e441a1a1d1fdde44af433a519b879"}}}}