help needed in fixing test failure (#138600)
Parth Malwankar
parth.malwankar at gmail.com
Tue Feb 16 16:57:44 GMT 2010
On Tue, Feb 16, 2010 at 9:08 PM, John Arbash Meinel
<john at arbash-meinel.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Parth Malwankar wrote:
>> What I am doing wrong here?
>
> The reason this is failing, is because the test infrastructure
> automatically creates a WorkingTree at the root of the temp directory,
> so that we don't accidentally have a bzr command 'leak' into the
> containing workspace. (We also analyze the WT after each test to make
> sure that the test didn't modify the tree, otherwise we fail so we know
> to fix that test.)
>
> In your test, it does return 'retcode=3' but it does so because of:
> .../work/abc is not versioned.
>
> The actual failure is that it cannot add 'abc' because 'work/' is not
> versioned.
>
> The only way I can think of to isolate the way you want is to create a
> branch or repository without a working tree inbetween you and the test
> infrastructure tree. So something like:
>
> self.make_branch('no_tree')
> self.run_bzr('no_tree/abc')
>
> I think that should make the test work for you.
>
Thanks for the explanation John. I think I understand this better now.
I tried creating the test case as follows:
def test_mkdir_invalid(self):
"""'mkdir' operation should fail if !branch. Fix #138600"""
self.make_branch('foobar')
self.run_bzr('mkdir foobar/abc', retcode=3)
self.failIfExists('foobar/abc')
For some reasons this passes all the time (even without the fix).
I also tried a bunch of other things including specifically creating
the dir using os.mkdir and changing to it using os.chdir (in this case,
the test fails with _and_ without the fix).
I am a little unsure how to go about this test case. Any further
pointers would be much appreciated.
Regards,
Parth
>>
>> Thanks,
>> Parth
>>
>> [1] https://bugs.launchpad.net/bzr/+bug/138600
>> [2] https://code.launchpad.net/~parthm/bzr/138600
>>
>> [blackbox]% bzr cdiff -r -3
>> === modified file 'bzrlib/builtins.py'
>> --- bzrlib/builtins.py 2010-02-12 04:33:05 +0000
>> +++ bzrlib/builtins.py 2010-02-16 08:28:57 +0000
>> @@ -682,8 +682,8 @@
>>
>> def run(self, dir_list):
>> for d in dir_list:
>> + wt, dd = WorkingTree.open_containing(d)
>> os.mkdir(d)
>> - wt, dd = WorkingTree.open_containing(d)
>> wt.add([dd])
>> self.outf.write('added %s\n' % d)
>>
>>
>> === modified file 'bzrlib/tests/blackbox/test_versioning.py'
>> --- bzrlib/tests/blackbox/test_versioning.py 2009-08-28 05:00:33 +0000
>> +++ bzrlib/tests/blackbox/test_versioning.py 2010-02-16 09:24:13 +0000
>> @@ -23,7 +23,7 @@
>> import os
>>
>> from bzrlib.branch import Branch
>> -from bzrlib.osutils import pathjoin
>> +from bzrlib.osutils import pathjoin, isdir
>> from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport
>> from bzrlib.trace import mutter
>> from bzrlib.workingtree import WorkingTree
>> @@ -121,6 +121,14 @@
>> from bzrlib.check import check
>> check(b, False)
>>
>> + def test_mkdir_invalid(self):
>> + """Basic 'bzr mkdir' operation should fail if !branch. Fix #138600"""
>> +
>> + self.run_bzr('mkdir abc', retcode=3)
>> + print "isdir foo returns: ", isdir('foo')
>> + print "isdir abc returns: ", isdir('abc')
>> + self.assertFalse(isdir('foo'))
>> + self.assertFalse(isdir('abc'))
>
> ^- Better here would be "self.failIfExists('foo')"
>
>>
>> class SubdirCommit(TestCaseWithTransport):
>>
>>
>
> John
> =:_>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Cygwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkt6u+kACgkQJdeBCYSNAANoRgCdFMeFypsLVMNYj/9napwCOTvO
> UNoAoJa4a2/bBPDbDfqoVR7ZYb+K8XuY
> =OXfz
> -----END PGP SIGNATURE-----
>
More information about the bazaar
mailing list