{"id":31,"date":"2007-06-29T02:39:36","date_gmt":"2007-06-29T08:39:36","guid":{"rendered":"http:\/\/www.pervasivecode.com\/blog\/2007\/06\/29\/removing-framework-clutter-from-autotest-failure-stacktraces\/"},"modified":"2016-01-03T21:27:06","modified_gmt":"2016-01-04T05:27:06","slug":"removing-framework-clutter-from-autotest-failure-stacktraces","status":"publish","type":"post","link":"http:\/\/www.pervasivecode.com\/blog\/2007\/06\/29\/removing-framework-clutter-from-autotest-failure-stacktraces\/","title":{"rendered":"Removing framework clutter from autotest failure stacktraces"},"content":{"rendered":"<p>If you&#8217;re programming in Ruby, then in the list of &#8220;should be&#8217;s&#8221; is &#8220;using <a href=\"http:\/\/www.zenspider.com\/ZSS\/Products\/ZenTest\/\">autotest<\/a>&#8220;, assuming you&#8217;re doing automated testing, which of course is a giant &#8220;should be&#8221;. One problem if you&#8217;re using a bunch of gems or Rails is that their code works and yours is broken but the failure stacktraces you&#8217;re reading contain their method names mixed in with yours. 99% of the time this is distracting. So, using some code from <a href=\"http:\/\/www.faisal.com\/\">Faisal<\/a> that did the same thing with an older version of Autotest but doesn&#8217;t work in the latest release, I hacked up the code to help remove unwanted text from Autotest test output. And now I present it to you.<br \/>\n<!--more--><\/p>\n<p>This goes in your .autotest file:<\/p>\n<pre>\r\nAutotest.add_hook :ran_command do |autotest|\r\n  eliminate_matching = [%r{vendor\/plugins\/mocha}]\r\n  modify_matching = {%r{\/Applications\/Locomotive2\/.*\/gems} => '{gems}'}\r\n  \r\n  eliminate_matching.each do |u|\r\n    autotest.results = autotest.results.delete_if do |line|\r\n      line.match(u)\r\n    end\r\n  end\r\n\r\n  modify_matching.each do |k,v|\r\n    autotest.results.collect! do |line|\r\n      line.gsub(k, v)\r\n    end\r\n  end\r\n\r\n  puts autotest.results\r\nend\r\n<\/pre>\n<p>Note that autotest will still print the unfiltered version; the filtered output will print afterwards, so just ignore the unfiltered stuff.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re programming in Ruby, then in the list of &#8220;should be&#8217;s&#8221; is &#8220;using autotest&#8220;, assuming you&#8217;re doing automated testing, which of course is a giant &#8220;should be&#8221;. One problem if you&#8217;re using a bunch of gems or Rails is that their code works and yours is broken but the failure stacktraces you&#8217;re reading contain &hellip; <a href=\"http:\/\/www.pervasivecode.com\/blog\/2007\/06\/29\/removing-framework-clutter-from-autotest-failure-stacktraces\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Removing framework clutter from autotest failure stacktraces&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,20,30,9],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-ruby","category-ruby-on-rails","category-testing","category-tools"],"_links":{"self":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts\/31"}],"collection":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":2,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":360,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions\/360"}],"wp:attachment":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}