[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Need Ruby expertise to fix SvnClientTest::test_cleanup

From: Gustav Munkby <grddev_at_gmail.com>
Date: 2006-07-05 09:26:09 CEST

On 7/4/06, Malcolm Rowe <malcolm-svn-dev@farside.org.uk> wrote:
> On Tue, Jul 04, 2006 at 04:36:03PM +0100, Max Bowsher wrote:
> > When a svn_error_t whose constant happens to be the first in its
> > category (i.e., its apr_err equals one of the CATEGORY_START constants),
> > Ruby thinks it has a FOO_CATEGORY_START error, not whatever the real
> > error is.
> >
> > This is causing SvnClientTest::test_cleanup to fail.
> >
> > Someone needs to fix the "Ext::Core.constants.each do |const_name|" loop
> > in svn/error.rb to ignore constants ending with _CATEGORY_START. Since I
> > do not know any Ruby, that someone cannot be me.
> >
>
> I don't know any Ruby either, but this seems simple enough.
> Does this work?
>
> Index: subversion/bindings/swig/ruby/svn/error.rb
> ===================================================================
> --- subversion/bindings/swig/ruby/svn/error.rb (revision 20417)
> +++ subversion/bindings/swig/ruby/svn/error.rb (working copy)
> @@ -7,6 +7,7 @@
>
> Ext::Core.constants.each do |const_name|
> if /^SVN_ERR_(.*)/ =~ const_name
> + next if /^SVN_ERR_.*_CATEGORY_START$/ =~ #{$1}
> value = Ext::Core.const_get(const_name)
> module_eval(<<-EOC, __FILE__, __LINE__)
> class #{$1} < Error
>
>
> Or does the second regex destroy the value of $1 obtained from the
> grouping in the first regex?
>
> Regards,
> Malcolm
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>

It does not work, since the second test expects $1 to start with
SVN_ERR, which was stripped off by the first match. By keeping just
/_CATEGORY_START$/ this approach would work. I would suggest adding
the test either to the condition, or to make the existing regexp a bit
more advanced.

Inserting a negative group match (?! ... ) into the original
expression, should provide the correct result. Unfortunately I'm not
able to produce a diff right now, but the new condition should read
like:

     if /^SVN_ERR_(?!.*_CATEGORY_START$)(.*)/ =~ const_name

Since I've only typed the solution in this mail, be sure to test
whether this actually works.

!g

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 7 14:52:57 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.