From: Gordon Thiesfeld on
On Wed, Mar 10, 2010 at 2:35 AM, Luis Lavena <luislavena(a)gmail.com> wrote:

> ====
>
> Stops there, all without colors.
>
> Now, running rake spec or spec -c spec display all colors too, so is
> something around autospec/autotest and Ruby 1.9
>
> ====
>
> Hope I explained better this time since seems nobody answered on RSpec-
> dev maybe my english wasn't good enough.
>

Ah! I see the problem now. I'm afraid it is in win32console[1], and
I'm afraid I wrote it.
This code will reproduce the bug:

ruby -e "require 'rubygems'; require 'win32console'; %Q{\e[31mred\e[0m
\e[32mgreen\e[0m}.each_byte{|i| putc
i }"

ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
red green
# in color

ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
red green
# in color

ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
red green

Autotest uses getc to read from stdout, and putc to write to it. I
redefined Kernel#putc to cache escape codes and write them all at
once. Otherwise, win32console won't work. The problem in 1.9 is that
"?\e" doesn't return the byte value, but the string. I'll submit a
patch.


[1] http://github.com/luislavena/win32console/blob/master/lib/Win32/Console/ANSI.rb#L103

> Regards,
> --
> Luis Lavena
>
>

From: Luis Lavena on
On Mar 10, 3:40 pm, Gordon Thiesfeld <gthiesf...(a)gmail.com> wrote:
> On Wed, Mar 10, 2010 at 2:35 AM, Luis Lavena <luislav...(a)gmail.com> wrote:
> > ====
>
> > Stops there, all without colors.
>
> > Now, running rake spec or spec -c spec display all colors too, so is
> > something around autospec/autotest and Ruby 1.9
>
> > ====
>
> > Hope I explained better this time since seems nobody answered on RSpec-
> > dev maybe my english wasn't good enough.
>
> Ah! I see the problem now.  I'm afraid it is in win32console[1], and
> I'm afraid I wrote it.
> This code will reproduce the bug:
>
> ruby -e "require 'rubygems'; require 'win32console'; %Q{\e[31mred\e[0m
> \e[32mgreen\e[0m}.each_byte{|i| putc
> i }"
>
> ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
> red green
>  # in color
>
> ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
> red green
>  # in color
>
> ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
>  [31mred [0m  [32mgreen [0m
>
> Autotest uses getc to read from stdout, and putc to write to it.  I
> redefined Kernel#putc to cache escape codes and write them all at
> once.  Otherwise, win32console won't work.  The problem in 1.9 is that
> "?\e" doesn't return the byte value, but the string.  I'll submit a
> patch.
>
> [1]http://github.com/luislavena/win32console/blob/master/lib/Win32/Conso....
>

Gordon, your patch fix the issue with red/green sample, but still
generates ANSI codes when running under 1.9.1 with autospec.

I just cleared all the previous versions of win32console due buggy
load path of 1.9 and still see the same issue.

The positive side is that the specs now completes instead of
prematurely terminate itself.

Adding this to either project .autospec file or ~/.autospec file:

%Q{\e[31mred\e[0m \e[32mgreen\e[0m}.each_byte{|i| putc i }

Produces colored output, while adding to spec_helper.rb or any of the
files being evaluated inside autospec returns ANSI color codes.

--
Luis Lavena
From: Gordon Thiesfeld on
On Wed, Mar 10, 2010 at 6:00 PM, Luis Lavena <luislavena(a)gmail.com> wrote:
> On Mar 10, 3:40 pm, Gordon Thiesfeld <gthiesf...(a)gmail.com> wrote:
>> On Wed, Mar 10, 2010 at 2:35 AM, Luis Lavena <luislav...(a)gmail.com> wrote:
>> > ====
>>
>> > Stops there, all without colors.
>>
>> > Now, running rake spec or spec -c spec display all colors too, so is
>> > something around autospec/autotest and Ruby 1.9
>>
>> > ====
>>
>> > Hope I explained better this time since seems nobody answered on RSpec-
>> > dev maybe my english wasn't good enough.
>>
>> Ah! I see the problem now.  I'm afraid it is in win32console[1], and
>> I'm afraid I wrote it.
>> This code will reproduce the bug:
>>
>> ruby -e "require 'rubygems'; require 'win32console'; %Q{\e[31mred\e[0m
>> \e[32mgreen\e[0m}.each_byte{|i| putc
>> i }"
>>
>> ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
>> red green
>>  # in color
>>
>> ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
>> red green
>>  # in color
>>
>> ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
>>  [31mred [0m  [32mgreen [0m
>>
>> Autotest uses getc to read from stdout, and putc to write to it.  I
>> redefined Kernel#putc to cache escape codes and write them all at
>> once.  Otherwise, win32console won't work.  The problem in 1.9 is that
>> "?\e" doesn't return the byte value, but the string.  I'll submit a
>> patch.
>>
>> [1]http://github.com/luislavena/win32console/blob/master/lib/Win32/Conso...
>>
>
> Gordon, your patch fix the issue with red/green sample, but still
> generates ANSI codes when running under 1.9.1 with autospec.
>
> I just cleared all the previous versions of win32console due buggy
> load path of 1.9 and still see the same issue.
>
> The positive side is that the specs now completes instead of
> prematurely terminate itself.
>
> Adding this to either project .autospec file or ~/.autospec file:
>
> %Q{\e[31mred\e[0m \e[32mgreen\e[0m}.each_byte{|i| putc i }
>
> Produces colored output, while adding to spec_helper.rb or any of the
> files being evaluated inside autospec returns ANSI color codes.
>
> --
> Luis Lavena
>
>

My patch didn't fix the whole problem. I was assuming that the
argument to putc would always be an integer, but apparently in 1.9 it
can be an integer or a string. I'll send you another pull request. I
tested with autospec this time on 1.8.6, 1.8.7, and 1.9.1.

From: Luis Lavena on
On Mar 11, 4:24 am, Gordon Thiesfeld <gthiesf...(a)gmail.com> wrote:
>
> My patch didn't fix the whole problem.  I was assuming that the
> argument to putc would always be an integer, but apparently in 1.9 it
> can be an integer or a string.  I'll send you another pull request.  I
> tested with autospec this time on 1.8.6, 1.8.7, and 1.9.1.

Change received, merged and tested.

I've pushed a new beta release (beta3). This closes GH-3 report about
the incorrect behavior under autospec.

Can you guys install the new prerelease and let me know? That way we
can make it official 1.3.0 and I can move to the other projects with
pending releases ;-)

Thank you.
--
Luis Lavena
From: Gordon Thiesfeld on
On Fri, Mar 12, 2010 at 2:40 AM, Luis Lavena <luislavena(a)gmail.com> wrote:
> On Mar 11, 4:24 am, Gordon Thiesfeld <gthiesf...(a)gmail.com> wrote:
>>
>> My patch didn't fix the whole problem.  I was assuming that the
>> argument to putc would always be an integer, but apparently in 1.9 it
>> can be an integer or a string.  I'll send you another pull request.  I
>> tested with autospec this time on 1.8.6, 1.8.7, and 1.9.1.
>
> Change received, merged and tested.
>
> I've pushed a new beta release (beta3). This closes GH-3 report about
> the incorrect behavior under autospec.
>
> Can you guys install the new prerelease and let me know? That way we
> can make it official 1.3.0 and I can move to the other projects with
> pending releases ;-)
>
> Thank you.
> --
> Luis Lavena
>
>

It looks good to me. Thanks, Luis.