{"action":"created","issue":{"url":"https://api.github.com/repos/redding/assert/issues/274","repository_url":"https://api.github.com/repos/redding/assert","labels_url":"https://api.github.com/repos/redding/assert/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/redding/assert/issues/274/comments","events_url":"https://api.github.com/repos/redding/assert/issues/274/events","html_url":"https://github.com/redding/assert/pull/274","id":154174318,"number":274,"title":"accumulate: more fixes to result handling and view sorting","user":{"login":"kellyredding","id":82110,"avatar_url":"https://avatars.githubusercontent.com/u/82110?v=3","gravatar_id":"","url":"https://api.github.com/users/kellyredding","html_url":"https://github.com/kellyredding","followers_url":"https://api.github.com/users/kellyredding/followers","following_url":"https://api.github.com/users/kellyredding/following{/other_user}","gists_url":"https://api.github.com/users/kellyredding/gists{/gist_id}","starred_url":"https://api.github.com/users/kellyredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kellyredding/subscriptions","organizations_url":"https://api.github.com/users/kellyredding/orgs","repos_url":"https://api.github.com/users/kellyredding/repos","events_url":"https://api.github.com/users/kellyredding/events{/privacy}","received_events_url":"https://api.github.com/users/kellyredding/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-11T07:06:41Z","updated_at":"2016-05-11T15:22:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/redding/assert/pulls/274","html_url":"https://github.com/redding/assert/pull/274","diff_url":"https://github.com/redding/assert/pull/274.diff","patch_url":"https://github.com/redding/assert/pull/274.patch"},"body":"This is part of reworking assert to accumulate test run data and\r\ncame out of trying to remove the `results` accessor from the test\r\nobject (a future effort).  In working on this effort, I broke a\r\nbunch of tests.  I noticed that the test results weren't ordered\r\nas I expected and I started to investigate.\r\n\r\nThe first thing I noticed was that for the error result backtraces,\r\nthe line used for the result file line included extra characters\r\nafter the line number (`\".../test_tests.rb:123 in some_method\"` for\r\nexample).  The file line wasn't parsing the backtrace lines\r\ncorrectly.  So I updated the file line to properly parse backtrace\r\nlines in this form.\r\n\r\nOnce that was corrected, I noticed that errors that occurred in\r\nAssert's lib source code were being shown first, regardless of the\r\ndefinition order of the test that generated the error result.  The\r\nfirst problem was that the result file line used to sort the results\r\nwas built off the first filtered backtrace line.  If the backtrace\r\nonly contained assert lib lines, the filtered backtrace would be\r\nempty.  So I added a check for empty filtered backtraces and set\r\nthe `trace` attr to the first filtered line if present but fall\r\nback to just the first line of the backtrace if not.  Note: the\r\ncase where the filtered backtrace is empty is pretty edge - it\r\nshould only occur when errors in Assert's test suite come from the\r\nlib source.  This shouldn't occur in any other test suites.\r\n\r\nThis change got the errors coming from Assert's lib source to now\r\nhave a file line but they were still not sorting as expected.  This\r\nwas b/c their file line (in Assert's lib source) comes before any\r\nresults with a file line in Assert's test source.  This is true of\r\nany test suite - the results generated from non-test code would\r\nalways be sorted before results generated from test code,  So this\r\nled me to rework how the view's result data is sorted.  It is now\r\nsorted first by the test's file line and then by the results file\r\nline. This does two things: it ensures all results are jux'd next\r\nto other results from the same test and results are always sorted\r\nby the test that generates them. Within a single test, results will\r\nbe sorted by the code file line that generated the result.\r\n\r\nChanging the result data sort behavior required me to formally\r\nmodel not only the test file line, but also the test file name and\r\ntest line num.  This matches the result file name and line num\r\nattrs and allows proper sorting.  I also chose to make the test file\r\nline an actual file line object.  The test id attr is still the\r\nstring form of the test file line (no change from before).\r\n\r\nNote: I also updated the result `inspect` method to include both\r\nthe file line and test file line info.  I figured this was helpful\r\ninfo for determining where a result came from when debugging.\r\n\r\n@jcredding whew - that may be the longest commit msg I've ever written.  Sorry for the novel, but I didn't know a better way to give context on where all these rando result changes were coming from and why.  Essentially this is more fall-out from switching to explicit ordering of result data in the view.  I'm happy with the result, though, as it highlighted some edge-case deficiencies in calculating the file lines and cleaned up some result behavior.  Anyway, ready for review. "},"comment":{"url":"https://api.github.com/repos/redding/assert/issues/comments/218493254","html_url":"https://github.com/redding/assert/pull/274#issuecomment-218493254","issue_url":"https://api.github.com/repos/redding/assert/issues/274","id":218493254,"user":{"login":"jcredding","id":85966,"avatar_url":"https://avatars.githubusercontent.com/u/85966?v=3","gravatar_id":"","url":"https://api.github.com/users/jcredding","html_url":"https://github.com/jcredding","followers_url":"https://api.github.com/users/jcredding/followers","following_url":"https://api.github.com/users/jcredding/following{/other_user}","gists_url":"https://api.github.com/users/jcredding/gists{/gist_id}","starred_url":"https://api.github.com/users/jcredding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcredding/subscriptions","organizations_url":"https://api.github.com/users/jcredding/orgs","repos_url":"https://api.github.com/users/jcredding/repos","events_url":"https://api.github.com/users/jcredding/events{/privacy}","received_events_url":"https://api.github.com/users/jcredding/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T15:22:09Z","updated_at":"2016-05-11T15:22:09Z","body":"@kellyredding - Looks good :boom: Matches what we discussed this morning on the drive."}}