Enhance cucumber coloring #50

Merged
merged 13 commits into from Feb 28, 2012

2 participants

@jondkinney

Thanks for the last commit where you added a few colors!

screenshot

It gave me a jumping off point and I added some custom regex matchers for the tmLanguage and tmTheme to more closely resemble the actual colored command line output.

screenshot

and

screenshot

However, I can't seem to get the 'dot matches newline' option (or any options) to work in a tmLanguage file. I'm trying to highlight all of the section between the "expected: blah" and the next step. I planned to build upon this and highlight the remaining (pending) steps after a failure and see if I could use some look-behind regex to highlight the green steps before a failure as well.

This was my attempt at highlighting the expected: block

http://rubular.com/r/JccQhKsJHA

I thought using this:

<string>(?imx-m:expected:.+?(\s{4}Given|\s{4}When|\s{4}Then|\s{4}And|\s{4}But)</string>

might work, but it doesn't match on newlines.

In fact, this (below) doesn't even work to highlight the rest of the output red (obviously we wouldn't want that ultimately, but I couldn't even get it to work):

<string>(?imx-m:expected:.+)</string>

I also tried:

<string>(?m:expected:.+)</string>

as I'm not sure what the syntax actually is for specifying options in a regex of a tmlanguage file. I couldn't find a clear example.

Would love to hear your thoughts!

Thanks much,
-Jon

@jondkinney

Since my original comment I've made some significant enhancements after discovering Textmate's "begin" and "end" capture matching capabilities to grab a section of text between two matches. There's also "beginCapture" and "endCapture" to help style the initial line you match on.

Here is a screenshot of a passing cuke (comparing it to the cucumber output in iTerm 2):

screenshot

Here is one with an error step and a pending step:

screenshot

So as you can see... there are a few things I can't work out. I'm worried that they might just not be technically possible with how we're limited inside the RubyTest console widget with the regex capabilities of the tmLanguage that defines that view. Namely, steps that have either failed or are pending are colored in green. This was the lesser of two evils IMHO because if I didn't style them green then there would be no way to show a green passing step ever.

Also, undefined steps can't really be targeted with regex (at least I can't see how)... so they show up as green too :( And of couse if you don't know it's an undefined step then there isn't a way to show that the ones after it were skipped... so they all show green as well.

screenshot

All and all I think this is better than not having any coloring. It's pretty close and just requires that you pay attention to what the bottom says for 'failed, skipped, pending, undefined, passed'.

However, if there is a way to fix any of the above I'd be happy to get some help on this!

@gs gs merged commit 9d9fa5a into maltize:master Feb 28, 2012
@gs
Collaborator
gs commented Feb 28, 2012

Hi,

Thanks for nice update and your effort.

I will try to look into it and maybe we will figure out the solution.

Br,
Grzegorz

@jondkinney

Hi Grzegorz!

You're welcome, I'm happy to help. Thanks to you for looking into the remaining issues. Hopefully you or someone can find a way to fix up the erroneous passing step coloration during a failure or pending. It'd be easier if we could use some code to count the number of steps before the 'error' or 'pending' text, but I'm not sure how we'd do that. Or if we could hijack the cucumber command line output before it hits the RubyTest console and inject some special characters on a failing step that we could more easily match on to color those lines.

Thanks,
-Jon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment