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

Re: [patch] regression tests for issues 439 and 440

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2002-01-12 23:18:42 CET

On Sat, Jan 12, 2002 at 02:10:25PM -0800, Greg Stein wrote:

> > > +# (abbreviation)
> > > +path_index = svntest.actions.path_index
>
> path_index isn't used anywhere, so this isn't needed

the dangers of cut and pasting from another file...

> > > +def stat_unversioned_file_in_current_dir():
> > > + "stat an unversioned file in the current directory"
> > > +
> > > + sbox = sandbox(stat_unversioned_file_in_current_dir)
> > > + wc_dir = os.path.join(svntest.main.general_wc_dir, sbox)
> > > + if svntest.actions.make_repo_and_wc(sbox): return 1
> > > +
> > > + was_cwd = os.getcwd()
> > > + os.chdir(wc_dir)
> > > +
> > > + svntest.main.file_append('foo', 'a new file')
> > > +
> > > + stat_output, err_output = svntest.main.run_svn(None, 'stat', 'foo')
> > > +
> > > + if len(stat_output) != 1:
> > > + os.chdir(was_cwd)
> > > + return 1
> > > +
> > > + if len(err_output) != 0:
> > > + os.chdir(was_cwd)
> > > + return 1
> > > +
> > > + os.chdir(was_cwd)
> > > + return 0
>
> The easiest thing to do above is:
>
> was_cwd = os.getcwd()
> try:
> os.chdir(wc_dir)
>
> svntest.main.file_append('foo', 'a new file')
> stat_output, ...
> if len(stat_output) != 1:
> return 1
> if len(err_output) != 0:
> return 1
> return 0
> finally:
> os.chdir(was_cwd)
>
> In the above code, the "finally" step will *always* execute. Thus, you will
> always get back to the original directory whether you exit with success,
> failure, or even because of an exception.

cool, that is a much better way to do it. thanks for the tim.

> (and those two "if" conditions are simple enough to join with "or")

wow, i didn't even know there was an 'or' keyword...

> Otherwise, +1 with or without the above changes.

i'll make the suggested changes and commit. thanks for the review.

-garrett

-- 
garrett rooney                     Unix was not designed to stop you from 
rooneg@electricjellyfish.net       doing stupid things, because that would  
http://electricjellyfish.net/      stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:56 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.