On 5 Oct 2007, at 13:50, Mark Fowler wrote:
I would like to press a key shortcut in my text editor and have it run the test I'm currently editing. If there are any failures, I'd like to be able to click on them and it go to the line that the failing test was on. Since my current editor is TextMate this involves creating a script that runs my test and outputs HTML.

I assume that I want to use TAP::Parser for this. The interface for the version on CPAN seems clean, but how do I work out what line the failing test was on? Is there an existing module that does this (or can I do it with TAP::Parser somehow?)

I have something working. It's ugly.

You will need:

The latest snapshot of Test::Harness 2.99:
  http://svn.hexten.net/tapx/trunk/

Test::More::Diagnostic:
  http://svn.hexten.net/tapx/Test-More-Diagnostic/trunk/

TAP::Formatter::TextMate
  http://svn.hexten.net/tapx/TAP-Formatter-TextMate/trunk/

Set up a TextMate command that looks something like this:

  test=''
  opts='-rb'
  if [ ${TM_FILEPATH:(-2)} == '.t' ] ; then
      test=$TM_FILEPATH
      opts='-b'
  fi
cd $TM_PROJECT_DIRECTORY && prove --merge --formatter TAP::Formatter::TextMate $opts $test

and in your tests:

  use Test::More;
  use Test::More::Diagnostic;
  plan tests => 1000;

You'll get test output with any test failures linked to the right line the test.

It's a hasty lashup. Improvements welcome :)

--
Andy Armstrong, Hexten



Reply via email to