----Next_Part(Fri_Feb_16_22_30_20_2007_207)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

In <45D5A837.9000407 / 9online.fr>
  "Re: [PATCH] make Test::Unit output more Emacs friendly format" on Fri, 16 Feb 2007 21:48:59 +0900,
  Vincent Fourmond <vincent.fourmond / 9online.fr> wrote:

> Kouhei Sutou wrote:
> >   FILE_NAME:LINE_NO:ANY_MESSAGE
> > 
> > On Emacs, we can easily jump to the FILE_NAME at LINE_NO by
> > C-x `. This function is very useful for debugging and helps
> > me to do test driven development.
> > 
> > I also requested this output format to RSpec and the request
> > was accepted. I hope that Test::Unit accepts this request
> > too.
> 
>   Though I agree it would make life easier for emacs users, I find it is
> less readable in a terminal (but anyway, I don't have any power on thds
> :-)...). I don't know how you're launching the tests from emacs (and I'm
> interested to know), but try out this way:

I'm using run-test.el:
  http://www.cozmixng.org/~kou/emacs/run_test.html.en
  http://www.cozmixng.org/repos/gauche/gaunit/trunk/sample/site-lisp/


> ruby test.rb | sed -r 's/^ +//g'

If I need to use sed, I'll re-define Test::Unit's methods
dynamically in test script.


I noticed that I needed to include patches for
lib/test/unit/failure.rb and
test/testunit/test_{error,failure}.rb.

Thanks,
--
kou

----Next_Part(Fri_Feb_16_22_30_20_2007_207)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenameuby-test-unit-more-emacs-friendly.diff"

Index: lib/test/unit/error.rb
--- lib/test/unit/error.rb	(revision 11763)
+++ lib/test/unit/error.rb	(working copy)
@@ -43,8 +43,8 @@
 
       # Returns a verbose version of the error description.
       def long_display
-        backtrace  ilter_backtrace(@exception.backtrace).join("\n    ")
-        "Error:\n#@test_name:\n#{message}\n    #{backtrace}"
+        backtrace  ilter_backtrace(@exception.backtrace).join("\n")
+        "Error:\n#@test_name:\n#{message}\n#{backtrace}"
       end
 
       # Overridden to return long_display.
Index: lib/test/unit/failure.rb
--- lib/test/unit/failure.rb	(revision 11763)
+++ lib/test/unit/failure.rb	(working copy)
@@ -35,9 +35,9 @@
       # Returns a verbose version of the error description.
       def long_display
         location_display  f(location.size 1)
-          location[0].sub(/\A(.+:\d+).*/, ' [\\1]')
+          location[0].sub(/\A(.+:\d+).*/, "\n\\1")
         else
-          "\n    [#{location.join("\n     ")}]"
+          "\n#{location.join("\n")}"
         end
         "Failure:\n#@test_name#{location_display}:\n#@message"
       end
Index: test/testunit/test_failure.rb
--- test/testunit/test_failure.rb	(revision 11763)
+++ test/testunit/test_failure.rb	(working copy)
@@ -8,23 +8,24 @@
 module Test::Unit
   class TestFailure < TestCase
     def test_display
-      f  ailure.new("name", [%q{location:1 in 'l'}], "message1\nmessage2")
+      f  ailure.new("name", [%q{location:1:in 'l'}], "message1\nmessage2")
       assert_equal("name: message1", f.short_display)
       assert_equal(<<EOM.strip, f.long_display)
 Failure:
-name [location:1]:
+name
+location:1:
 message1
 message2
 EOM
 
-      f  ailure.new("name", [%q{location1:2 in 'l1'}, 'location2:1', %q{location3:3 in 'l3'}], "message1\nmessage2")
+      f  ailure.new("name", [%q{location1:2:in 'l1'}, 'location2:1:', %q{location3:3:in 'l3'}], "message1\nmessage2")
       assert_equal("name: message1", f.short_display)
       assert_equal(<<EOM.strip, f.long_display)
 Failure:
 name
-    [location1:2 in 'l1'
-     location2:1
-     location3:3 in 'l3']:
+location1:2:in 'l1'
+location2:1:
+location3:3:in 'l3':
 message1
 message2
 EOM
Index: test/testunit/test_error.rb
--- test/testunit/test_error.rb	(revision 11763)
+++ test/testunit/test_error.rb	(working copy)
@@ -9,7 +9,7 @@
     class TC_Error < TestCase
       TF_Exception  truct.new('TF_Exception', :message, :backtrace)
       def test_display
-        ex  F_Exception.new("message1\nmessage2", ['line1', 'line2'])
+        ex  F_Exception.new("message1\nmessage2", ['file1:1', 'file2:5'])
         e  rror.new("name", ex)
         assert_equal("name: #{TF_Exception.name}: message1", e.short_display)
         assert_equal(<<EOM.strip, e.long_display)
@@ -17,8 +17,8 @@
 name:
 Struct::TF_Exception: message1
 message2
-    line1
-    line2
+file1:1
+file2:5
 EOM
       end
     end

----Next_Part(Fri_Feb_16_22_30_20_2007_207)----