bzr's doctests are not isolated (branchbuilder doctests check global gpg configuration)

Bug #321320 reported by Andrew Bennetts
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Vincent Ladeuil

Bug Description

There's a doctest in bzrlib.branchbuilder, but it isn't properly isolated from the environment like the rest of the test suite. e.g. if I have a broken GPG configuration in ~/.bazaar the test will fail because it will fail trying to sign the commits it generates.

Related branches

Revision history for this message
Andrew Bennetts (spiv) wrote :

A good fix would probably be to change the way we construct DocTestSuite. We could pass setUp and tearDown params to its constructor to do the same sort of setUp and tearDown as we do in normal TestCases. In particular do the isolation of the test environment from the user's normal day-to-day environment.

(It might be neat to also provide an addCleanup facility in the globs param, too, but that's a separate issue.)

Revision history for this message
John A Meinel (jameinel) wrote :

This annoys anyone who runs the full test suite and has gpg signing defaulted to true.

summary: - bzrlib.branchbuilder tests run GPG (not isolated enough)
+ bzr's doctests are not isolated (branchbuilder doctests check global gpg
+ configuration)
Changed in bzr:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Martin Packman (gz) wrote :

Probably also this bug, in some slightly mysterious circumstances that depends on my particular test setup and on what other tests are also run, I get this failure:

File ".\bzrlib\branchbuilder.py", line 42, in bzrlib.branchbuilder.BranchBuilder
Failed example:
    builder.build_snapshot('rev-id', None, [
        ('add', ('', 'root-id', 'directory', '')),
        ('add', ('filename', 'f-id', 'file', 'content\n'))])
Exception raised:
    Traceback (most recent call last):
      File "...\python-trunk\lib\doctest.py", line 1248, in __run
        compileflags, 1) in test.globs
      File "<doctest bzrlib.branchbuilder.BranchBuilder[3]>", line 3, in <module>
        ('add', ('filename', 'f-id', 'file', 'content\n'))])
      File ".\bzrlib\branchbuilder.py", line 250, in build_snapshot
        message_callback=message_callback)
      File ".\bzrlib\branchbuilder.py", line 112, in _do_commit
        **kwargs)
      File "<string>", line 4, in commit_write_locked
      File ".\bzrlib\mutabletree.py", line 200, in commit
        *args, **kwargs)
      File ".\bzrlib\commit.py", line 286, in commit
        possible_master_transports=possible_master_transports)
      File ".\bzrlib\cleanup.py", line 131, in run
        self.cleanups, self.func, self, *args, **kwargs)
      File ".\bzrlib\cleanup.py", line 165, in _do_with_cleanups
        result = func(*args, **kwargs)
      File ".\bzrlib\commit.py", line 402, in _commit
        self.config, timestamp, timezone, committer, self.revprops, rev_id)
      File ".\bzrlib\branch.py", line 704, in get_commit_builder
        timestamp, timezone, committer, revprops, revision_id)
      File ".\bzrlib\repository.py", line 1765, in get_commit_builder
        timestamp, timezone, committer, revprops, revision_id)
      File ".\bzrlib\repofmt\pack_repo.py", line 117, in __init__
        revprops=revprops, revision_id=revision_id)
      File ".\bzrlib\repository.py", line 114, in __init__
        self._committer = self._config.username()
      File ".\bzrlib\config.py", line 279, in username
        raise errors.NoWhoami()
    NoWhoami: Unable to determine your name.
    Please, set your name with the 'whoami' command.
    E.g. bzr whoami "Your Name <email address hidden>"

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 321320] Re: bzr's doctests are not isolated (branchbuilder doctests check global gpg configuration)

Nice catch, please add a setup and teardown that isolate appropriately
to the doctest factory in tests/__init__.py.

-Rob

Revision history for this message
Vincent Ladeuil (vila) wrote :

With bug #690563 fixed, the doctest in bzrlib.branchbuiler is now failing on pqm.

I've commented out bzrlib.branchbuilder in bzrlib.tests.__init__.py with a FIXME mentioning this bug.

Whoever ends up fixing *this* bug should make sure to uncomment the line.

Vincent Ladeuil (vila)
Changed in bzr:
assignee: nobody → Vincent Ladeuil (vila)
status: Confirmed → In Progress
Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 2.3b5
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.