Fix regressions in running Mercurial unit tests.

Review Request #10994 — Created April 9, 2020 and submitted — Latest diff uploaded

Information

RBTools
release-1.0.x
b21364c...

Reviewers

The recent Mercurial SkipTest change broke running the Mercurial
Subversion tests, and any test suite that followed them. There were a
few causes:

  1. The setUpClass() for the Mercurial Subversion tests changed the
    current directory to a temp directory, which was then removed in
    tearDownClass(), leaving the current working directory set to
    a location that didn't exist (and breaking future os.getcwd()
    calls).

  2. The code shuffle resulted in a setUp() attempting to reference a
    variable that no longer existed.

  3. The .hgrc loading no longer worked, as setUpClass() created a
    temporary directory for it, set the path in the environment for all
    future calls, and then that directory was deleted after the first
    test's tearDown().

This change fixes each of these issues.

The base RBTestBase class now performs the same current directory
preservation/restoration in setUpClass()/tearDownClass() that it
does for individual test runs, ensuring we never end up in this
situation between test suite runs.

The initial .hgrc creation and environment population in
setUpClass() has been removed, instead passing the necessary arguments
directly on the command line to activate the extension, preventing any
test pollution. The old code for working with the class-level hg_env
map has also been removed, since it's dangerous and not used for
anything anymore.

The code to set up a $HOME/.hgrc for each test run was restored, which
also fixed the bad environment variable reference.

This fixes the full test suite, with and without hgsubversion installed,
on all versions of Python.

All RBTools unit tests pass (with and without Mercurial and hgsubversion)
on all supported versions of Python.

Tested with Mercurial 4.4.x and 5.0.x (though this version isn't
yet compatible with hgsubversion, and will still break even though
hg svn returns a suitable result).

    Loading...