help needed in fixing test failure (#138600)

Martin Pool mbp at canonical.com
Wed Feb 17 00:39:30 GMT 2010


On 17 February 2010 03:57, Parth Malwankar <parth.malwankar at gmail.com> wrote:
> 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.

I would add a comment explaining why you're making a branch, with a
summary of John's mail.  Otherwise it looks a bit backwards.

Aside from that it looks reasonable.  What I would probably do next is
change from run_bzr to ScriptRunner (see the developer docs or grep
for examples) and use that to check the actual message returned by
mkdir.  Then put in a

  import pdb;pdb.set_trace()

line after running bzr and use that to see what's in the directory.

Also we should fix this test isolation thing in a cleaner way.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list