{"action":"created","comment":{"url":"https://api.github.com/repos/Araq/Nim/pulls/comments/32010665","id":32010665,"diff_hunk":"@@ -211,68 +219,103 @@ proc compilerOutputTests(test: TTest, given: var TSpec, expected: TSpec;\n   if given.err == reSuccess: inc(r.passed)\n   r.addResult(test, expectedmsg, givenmsg, given.err)\n \n+proc analyzeAndConsolidateOutput(s: string): string =\n+  result = \"\"\n+  let rows = s.splitLines\n+  for i in 0 ..< rows.len:\n+    if (let pos = find(rows[i], \"Traceback (most recent call last)\"); pos != -1):\n+      result = substr(rows[i], pos) & \"\\n\"\n+      for i in i+1 ..< rows.len:\n+        result.add rows[i] & \"\\n\"\n+        if not (rows[i] =~ re\"^[^(]+\\(\\d+\\)\\s+\"):\n+          return\n+    elif (let pos = find(rows[i], \"SIGSEGV: Illegal storage access.\"); pos != -1):\n+      result = substr(rows[i], pos)\n+      return\n+\n proc testSpec(r: var TResults, test: TTest) =\n   # major entry point for a single test\n   let tname = test.name.addFileExt(\".nim\")\n   inc(r.total)\n-  styledEcho \"Processing \", fgCyan, extractFilename(tname)\n   var expected: TSpec\n   if test.action != actionRunNoSpec:\n     expected = parseSpec(tname)\n   else:\n     specDefaults expected\n     expected.action = actionRunNoSpec\n+\n   if expected.err == reIgnored:\n     r.addResult(test, \"\", \"\", reIgnored)\n     inc(r.skipped)\n-  else:\n-    case expected.action\n-    of actionCompile:\n-      var given = callCompiler(expected.cmd, test.name,\n-        test.options & \" --hint[Path]:off --hint[Processing]:off\", test.target)\n-      compilerOutputTests(test, given, expected, r)\n-    of actionRun, actionRunNoSpec:\n-      var given = callCompiler(expected.cmd, test.name, test.options,\n-                               test.target)\n-      if given.err != reSuccess:\n-        r.addResult(test, \"\", given.msg, given.err)\n-      else:\n-        var exeFile: string\n-        if test.target == targetJS:\n-          let (dir, file, ext) = splitFile(tname)\n-          exeFile = dir / \"nimcache\" / file & \".js\"\n-        else:\n-          exeFile = changeFileExt(tname, ExeExt)\n-        if existsFile(exeFile):\n-          let nodejs = findNodeJs()\n-          if test.target == targetJS and nodejs == \"\":\n-            r.addResult(test, expected.outp, \"nodejs binary not in PATH\",\n-                        reExeNotFound)\n-            return\n-          var (buf, exitCode) = execCmdEx(\n-            (if test.target == targetJS: nodejs & \" \" else: \"\") & exeFile)\n-          if exitCode != expected.exitCode:\n-            r.addResult(test, \"exitcode: \" & $expected.exitCode,\n-                              \"exitcode: \" & $exitCode, reExitCodesDiffer)\n-          else:\n-            var bufB = strip(buf.string)\n-            if expected.sortoutput: bufB = makeDeterministic(bufB)\n-            if bufB != strip(expected.outp):\n-              if not (expected.substr and expected.outp in bufB):\n-                given.err = reOutputsDiffer\n-            compilerOutputTests(test, given, expected, r)\n-        else:\n-          r.addResult(test, expected.outp, \"executable not found\", reExeNotFound)\n-    of actionReject:\n-      var given = callCompiler(expected.cmd, test.name, test.options,\n-                               test.target)\n-      cmpMsgs(r, expected, given, test)\n+    return\n+\n+  case expected.action\n+  of actionCompile:\n+    var given = callCompiler(expected.cmd, test.name,\n+      test.options & \" --hint[Path]:off --hint[Processing]:off\", test.target)\n+    compilerOutputTests(test, given, expected, r)\n+  of actionRun, actionRunNoSpec:\n+    # In this branch of code \"early return\" pattern is clearer than deep\n+    # nested conditionals - the empty rows in between to clarify the \"danger\"\n+    var given = callCompiler(expected.cmd, test.name, test.options,\n+                             test.target)\n+\n+    if given.err != reSuccess:\n+      r.addResult(test, \"\", given.msg, given.err)\n+      return\n+\n+    let isJsTarget = test.target == targetJS\n+    var exeFile: string\n+    if isJsTarget:\n+      let (dir, file, ext) = splitFile(tname)\n+      exeFile = dir / \"nimcache\" / file & \".js\" # *TODO* hardcoded \"nimcache\"\n+    else:\n+      exeFile = changeFileExt(tname, ExeExt)\n+\n+    if not existsFile(exeFile):\n+      r.addResult(test, expected.outp, \"executable not found\", reExeNotFound)\n+      return\n+\n+    let nodejs = if isJsTarget: findNodeJs() else: \"\"\n+    if isJsTarget and nodejs == \"\":\n+      r.addResult(test, expected.outp, \"nodejs binary not in PATH\",\n+                  reExeNotFound)\n+      return\n+\n+    let exeCmd = (if isJsTarget: nodejs & \" \" else: \"\") & exeFile\n+    let (buf, exitCode) = execCmdEx(exeCmd)\n+    let bufB = if expected.sortoutput: makeDeterministic(strip(buf.string))\n+               else: strip(buf.string)\n+    let expectedOut = strip(expected.outp)\n+\n+    if exitCode != expected.exitCode:\n+      r.addResult(test, \"exitcode: \" & $expected.exitCode,\n+                        \"exitcode: \" & $exitCode & \"\\n\\nOutput:\\n\" & \n+                        analyzeAndConsolidateOutput(bufB), \n+                        reExitCodesDiffer)\n+      return\n+\n+    # This is a bit ugly atm.\n+    if bufB != expectedOut:\n+      if not (expected.substr and expectedOut in bufB):\n+        if not (expectedOut == \"\" and bufB == \"\\27[0m\"):","path":"tests/testament/tester.nim","position":173,"original_position":173,"commit_id":"f0b6c03b2686aca85670cd35f84c6b0bdc3ff23d","original_commit_id":"f0b6c03b2686aca85670cd35f84c6b0bdc3ff23d","user":{"login":"Araq","id":287816,"avatar_url":"https://avatars.githubusercontent.com/u/287816?v=3","gravatar_id":"","url":"https://api.github.com/users/Araq","html_url":"https://github.com/Araq","followers_url":"https://api.github.com/users/Araq/followers","following_url":"https://api.github.com/users/Araq/following{/other_user}","gists_url":"https://api.github.com/users/Araq/gists{/gist_id}","starred_url":"https://api.github.com/users/Araq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Araq/subscriptions","organizations_url":"https://api.github.com/users/Araq/orgs","repos_url":"https://api.github.com/users/Araq/repos","events_url":"https://api.github.com/users/Araq/events{/privacy}","received_events_url":"https://api.github.com/users/Araq/received_events","type":"User","site_admin":false},"body":"BufB is an escape code? Seriously? Not acceptable.","created_at":"2015-06-09T13:14:41Z","updated_at":"2015-06-09T13:14:41Z","html_url":"https://github.com/Araq/Nim/pull/2862#discussion_r32010665","pull_request_url":"https://api.github.com/repos/Araq/Nim/pulls/2862","_links":{"self":{"href":"https://api.github.com/repos/Araq/Nim/pulls/comments/32010665"},"html":{"href":"https://github.com/Araq/Nim/pull/2862#discussion_r32010665"},"pull_request":{"href":"https://api.github.com/repos/Araq/Nim/pulls/2862"}}},"pull_request":{"url":"https://api.github.com/repos/Araq/Nim/pulls/2862","id":36822371,"html_url":"https://github.com/Araq/Nim/pull/2862","diff_url":"https://github.com/Araq/Nim/pull/2862.diff","patch_url":"https://github.com/Araq/Nim/pull/2862.patch","issue_url":"https://api.github.com/repos/Araq/Nim/issues/2862","number":2862,"state":"open","locked":false,"title":"Bugfix 2858 Testament Sources Files System Wide","user":{"login":"ozra","id":563674,"avatar_url":"https://avatars.githubusercontent.com/u/563674?v=3","gravatar_id":"","url":"https://api.github.com/users/ozra","html_url":"https://github.com/ozra","followers_url":"https://api.github.com/users/ozra/followers","following_url":"https://api.github.com/users/ozra/following{/other_user}","gists_url":"https://api.github.com/users/ozra/gists{/gist_id}","starred_url":"https://api.github.com/users/ozra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozra/subscriptions","organizations_url":"https://api.github.com/users/ozra/orgs","repos_url":"https://api.github.com/users/ozra/repos","events_url":"https://api.github.com/users/ozra/events{/privacy}","received_events_url":"https://api.github.com/users/ozra/received_events","type":"User","site_admin":false},"body":"A very simple fix, which I think is windows compat for the paths.\r\n\r\n- Make double sure compiler is built from sources before running tests (in koch)\r\n- Ensure local dir 'lib' and compiler is used (expected behaviour)\r\n","created_at":"2015-06-03T11:24:58Z","updated_at":"2015-06-09T13:14:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5208316d97c89fed1b94b7cbdb5b5472f04088b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Araq/Nim/pulls/2862/commits","review_comments_url":"https://api.github.com/repos/Araq/Nim/pulls/2862/comments","review_comment_url":"https://api.github.com/repos/Araq/Nim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Araq/Nim/issues/2862/comments","statuses_url":"https://api.github.com/repos/Araq/Nim/statuses/f0b6c03b2686aca85670cd35f84c6b0bdc3ff23d","head":{"label":"ozra:bugfix-2858-testament-sources-system-wide","ref":"bugfix-2858-testament-sources-system-wide","sha":"f0b6c03b2686aca85670cd35f84c6b0bdc3ff23d","user":{"login":"ozra","id":563674,"avatar_url":"https://avatars.githubusercontent.com/u/563674?v=3","gravatar_id":"","url":"https://api.github.com/users/ozra","html_url":"https://github.com/ozra","followers_url":"https://api.github.com/users/ozra/followers","following_url":"https://api.github.com/users/ozra/following{/other_user}","gists_url":"https://api.github.com/users/ozra/gists{/gist_id}","starred_url":"https://api.github.com/users/ozra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozra/subscriptions","organizations_url":"https://api.github.com/users/ozra/orgs","repos_url":"https://api.github.com/users/ozra/repos","events_url":"https://api.github.com/users/ozra/events{/privacy}","received_events_url":"https://api.github.com/users/ozra/received_events","type":"User","site_admin":false},"repo":{"id":36576924,"name":"Nim","full_name":"ozra/Nim","owner":{"login":"ozra","id":563674,"avatar_url":"https://avatars.githubusercontent.com/u/563674?v=3","gravatar_id":"","url":"https://api.github.com/users/ozra","html_url":"https://github.com/ozra","followers_url":"https://api.github.com/users/ozra/followers","following_url":"https://api.github.com/users/ozra/following{/other_user}","gists_url":"https://api.github.com/users/ozra/gists{/gist_id}","starred_url":"https://api.github.com/users/ozra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozra/subscriptions","organizations_url":"https://api.github.com/users/ozra/orgs","repos_url":"https://api.github.com/users/ozra/repos","events_url":"https://api.github.com/users/ozra/events{/privacy}","received_events_url":"https://api.github.com/users/ozra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ozra/Nim","description":"Nim (formerly known as \"Nimrod\") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":true,"url":"https://api.github.com/repos/ozra/Nim","forks_url":"https://api.github.com/repos/ozra/Nim/forks","keys_url":"https://api.github.com/repos/ozra/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ozra/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ozra/Nim/teams","hooks_url":"https://api.github.com/repos/ozra/Nim/hooks","issue_events_url":"https://api.github.com/repos/ozra/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/ozra/Nim/events","assignees_url":"https://api.github.com/repos/ozra/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/ozra/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/ozra/Nim/tags","blobs_url":"https://api.github.com/repos/ozra/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ozra/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ozra/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/ozra/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ozra/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/ozra/Nim/languages","stargazers_url":"https://api.github.com/repos/ozra/Nim/stargazers","contributors_url":"https://api.github.com/repos/ozra/Nim/contributors","subscribers_url":"https://api.github.com/repos/ozra/Nim/subscribers","subscription_url":"https://api.github.com/repos/ozra/Nim/subscription","commits_url":"https://api.github.com/repos/ozra/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/ozra/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/ozra/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/ozra/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/ozra/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/ozra/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ozra/Nim/merges","archive_url":"https://api.github.com/repos/ozra/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ozra/Nim/downloads","issues_url":"https://api.github.com/repos/ozra/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/ozra/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/ozra/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/ozra/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ozra/Nim/labels{/name}","releases_url":"https://api.github.com/repos/ozra/Nim/releases{/id}","created_at":"2015-05-30T21:49:24Z","updated_at":"2015-05-30T21:49:28Z","pushed_at":"2015-06-09T12:44:27Z","git_url":"git://github.com/ozra/Nim.git","ssh_url":"git@github.com:ozra/Nim.git","clone_url":"https://github.com/ozra/Nim.git","svn_url":"https://github.com/ozra/Nim","homepage":"http://nim-lang.org/","size":38404,"stargazers_count":0,"watchers_count":0,"language":"Nimrod","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":"devel"}},"base":{"label":"Araq:devel","ref":"devel","sha":"bbb1bdb4a939aa43ed981acc2f96bce918be7d21","user":{"login":"Araq","id":287816,"avatar_url":"https://avatars.githubusercontent.com/u/287816?v=3","gravatar_id":"","url":"https://api.github.com/users/Araq","html_url":"https://github.com/Araq","followers_url":"https://api.github.com/users/Araq/followers","following_url":"https://api.github.com/users/Araq/following{/other_user}","gists_url":"https://api.github.com/users/Araq/gists{/gist_id}","starred_url":"https://api.github.com/users/Araq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Araq/subscriptions","organizations_url":"https://api.github.com/users/Araq/orgs","repos_url":"https://api.github.com/users/Araq/repos","events_url":"https://api.github.com/users/Araq/events{/privacy}","received_events_url":"https://api.github.com/users/Araq/received_events","type":"User","site_admin":false},"repo":{"id":842037,"name":"Nim","full_name":"Araq/Nim","owner":{"login":"Araq","id":287816,"avatar_url":"https://avatars.githubusercontent.com/u/287816?v=3","gravatar_id":"","url":"https://api.github.com/users/Araq","html_url":"https://github.com/Araq","followers_url":"https://api.github.com/users/Araq/followers","following_url":"https://api.github.com/users/Araq/following{/other_user}","gists_url":"https://api.github.com/users/Araq/gists{/gist_id}","starred_url":"https://api.github.com/users/Araq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Araq/subscriptions","organizations_url":"https://api.github.com/users/Araq/orgs","repos_url":"https://api.github.com/users/Araq/repos","events_url":"https://api.github.com/users/Araq/events{/privacy}","received_events_url":"https://api.github.com/users/Araq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Araq/Nim","description":"Nim (formerly known as \"Nimrod\") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":false,"url":"https://api.github.com/repos/Araq/Nim","forks_url":"https://api.github.com/repos/Araq/Nim/forks","keys_url":"https://api.github.com/repos/Araq/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Araq/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Araq/Nim/teams","hooks_url":"https://api.github.com/repos/Araq/Nim/hooks","issue_events_url":"https://api.github.com/repos/Araq/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/Araq/Nim/events","assignees_url":"https://api.github.com/repos/Araq/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/Araq/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/Araq/Nim/tags","blobs_url":"https://api.github.com/repos/Araq/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Araq/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Araq/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/Araq/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Araq/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/Araq/Nim/languages","stargazers_url":"https://api.github.com/repos/Araq/Nim/stargazers","contributors_url":"https://api.github.com/repos/Araq/Nim/contributors","subscribers_url":"https://api.github.com/repos/Araq/Nim/subscribers","subscription_url":"https://api.github.com/repos/Araq/Nim/subscription","commits_url":"https://api.github.com/repos/Araq/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/Araq/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/Araq/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/Araq/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/Araq/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/Araq/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Araq/Nim/merges","archive_url":"https://api.github.com/repos/Araq/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Araq/Nim/downloads","issues_url":"https://api.github.com/repos/Araq/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/Araq/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/Araq/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/Araq/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Araq/Nim/labels{/name}","releases_url":"https://api.github.com/repos/Araq/Nim/releases{/id}","created_at":"2010-08-16T20:38:58Z","updated_at":"2015-06-09T12:52:27Z","pushed_at":"2015-06-09T13:10:21Z","git_url":"git://github.com/Araq/Nim.git","ssh_url":"git@github.com:Araq/Nim.git","clone_url":"https://github.com/Araq/Nim.git","svn_url":"https://github.com/Araq/Nim","homepage":"http://nim-lang.org/","size":351249,"stargazers_count":2019,"watchers_count":2019,"language":"Nimrod","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":272,"mirror_url":null,"open_issues_count":562,"forks":272,"open_issues":562,"watchers":2019,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/Araq/Nim/pulls/2862"},"html":{"href":"https://github.com/Araq/Nim/pull/2862"},"issue":{"href":"https://api.github.com/repos/Araq/Nim/issues/2862"},"comments":{"href":"https://api.github.com/repos/Araq/Nim/issues/2862/comments"},"review_comments":{"href":"https://api.github.com/repos/Araq/Nim/pulls/2862/comments"},"review_comment":{"href":"https://api.github.com/repos/Araq/Nim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Araq/Nim/pulls/2862/commits"},"statuses":{"href":"https://api.github.com/repos/Araq/Nim/statuses/f0b6c03b2686aca85670cd35f84c6b0bdc3ff23d"}}}}