Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 70786
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: HMBRAND [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.11009
Fixed in: 0.11011



Subject: [PATCH] XML formatter can return non-default style/indentation
Patch below and attached --8<--- --- a/t/17sqlfxml-producer.t 2011-04-25 11:00:14.000000000 +0200 +++ b/t/17sqlfxml-producer.t 2011-09-07 15:27:27.158000115 +0200 @@ -40,6 +40,17 @@ use Test::Differences; use SQL::Translator; use SQL::Translator::Producer::XML::SQLFairy; +# Due to formatters being able to change style, e.g. by entries in .rc files +# in $HOME, the layout and or indent might differ slightly. As leading white +# is not important in XML, strip it when comparing +sub xml_equals +{ + my ($got, $expect, $msg) = (@_, "XML looks right"); + $got =~ s/^ +//gm; + $expect =~ s/^ +//gm; + eq_or_diff $got, $expect, $msg; +} + # # basic stuff # @@ -105,7 +116,7 @@ ok("$xml" ne "" print "XML:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; -eq_or_diff $xml, $ans, "XML looks right"; +xml_equals $xml, $ans; } # end basic stuff @@ -158,7 +169,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end View # @@ -221,7 +232,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end Trigger # @@ -277,7 +288,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end Procedure # @@ -353,5 +364,5 @@ EOXML print "XML:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end extra -->8---
Subject: t17.patch
--- a/t/17sqlfxml-producer.t 2011-04-25 11:00:14.000000000 +0200 +++ b/t/17sqlfxml-producer.t 2011-09-07 15:27:27.158000115 +0200 @@ -40,6 +40,17 @@ use Test::Differences; use SQL::Translator; use SQL::Translator::Producer::XML::SQLFairy; +# Due to formatters being able to change style, e.g. by entries in .rc files +# in $HOME, the layout and or indent might differ slightly. As leading white +# is not important in XML, strip it when comparing +sub xml_equals +{ + my ($got, $expect, $msg) = (@_, "XML looks right"); + $got =~ s/^ +//gm; + $expect =~ s/^ +//gm; + eq_or_diff $got, $expect, $msg; +} + # # basic stuff # @@ -105,7 +116,7 @@ ok("$xml" ne "" print "XML:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; -eq_or_diff $xml, $ans, "XML looks right"; +xml_equals $xml, $ans; } # end basic stuff @@ -158,7 +169,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end View # @@ -221,7 +232,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end Trigger # @@ -277,7 +288,7 @@ EOXML print "XML attrib_values=>1:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end Procedure # @@ -353,5 +364,5 @@ EOXML print "XML:\n$xml" if DEBUG; # Strip sqlf header with its variable date so we diff safely $xml =~ s/^([^\n]*\n){7}//m; - eq_or_diff $xml, $ans ,"XML looks right"; + xml_equals $xml, $ans; } # end extra
Subject: Re: [rt.cpan.org #70786] [PATCH] XML formatter can return non-default style/indentation
Date: Wed, 7 Sep 2011 12:18:43 -0400
To: "H.Merijn Brand via RT" <bug-SQL-Translator [...] rt.cpan.org>
From: Peter Rabbitson <ribasushi [...] cpan.org>
BOn Wed, Sep 07, 2011 at 09:31:01AM -0400, H.Merijn Brand via RT wrote: Show quoted text
> Wed Sep 07 09:31:01 2011: Request 70786 was acted upon. > Transaction: Ticket created by HMBRAND > Queue: SQL-Translator > Subject: [PATCH] XML formatter can return non-default style/indentation > Broken in: 0.11009 > Severity: (no value) > Owner: Nobody > Requestors: HMBRAND@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=70786 > > > > Patch below and attached > --8<--- > --- a/t/17sqlfxml-producer.t 2011-04-25 11:00:14.000000000 +0200 > +++ b/t/17sqlfxml-producer.t 2011-09-07 15:27:27.158000115 +0200 > @@ -40,6 +40,17 @@ use Test::Differences; > use SQL::Translator; > use SQL::Translator::Producer::XML::SQLFairy; > > +# Due to formatters being able to change style, e.g. by entries in .rc > files > +# in $HOME, the layout and or indent might differ slightly. As leading > white > +# is not important in XML, strip it when comparing > +sub xml_equals > +{
What if the .rc entry affects something more, like newlines? I'd prefer you devise a way to ignore the user-side config entirely. Can haz? :)
On Wed Sep 07 12:18:57 2011, RIBASUSHI wrote: Show quoted text
> What if the .rc entry affects something more, like newlines? I'd > prefer you devise a way to ignore the user-side config entirely. > Can haz? :)
No, as 1. I do not know what formatter is used 2. The layout might have been changed in other ways (environment variables) The basic here is that the code is checking is the returned code matches the given code where in both layout whitespace is irrelavant. The above patch is safe and fast and still let the users free in the configuration of the formatter. It is dead easy to change the patch to deal with trailing space and/or line endings, but that was not what I stumbled upon.
On Wed Sep 07 12:33:42 2011, HMBRAND wrote: Show quoted text
> On Wed Sep 07 12:18:57 2011, RIBASUSHI wrote:
> > What if the .rc entry affects something more, like newlines? I'd > > prefer you devise a way to ignore the user-side config entirely. > > Can haz? :)
> > No, as > > 1. I do not know what formatter is used > 2. The layout might have been changed in other ways (environment > variables) > > The basic here is that the code is checking is the returned code > matches the given code where in both layout whitespace is irrelavant. > > The above patch is safe and fast and still let the users free in > the configuration of the formatter. > > It is dead easy to change the patch to deal with trailing space > and/or line endings, but that was not what I stumbled upon.
Fair nuff, patch applied. Thanks and sorry for the delay :)