Speed up SCM tests through cached checkout management.
Review Request #11824 — Created Sept. 27, 2021 and submitted
This change formalizes part of the setup process of SCM unit tests. Most
tests need to set up a checkout or clone of a repository that they can
run tests against, and as tests often need to modify the repository,
these checkouts needed to be freshly re-made on each test run. This was
SCMClientTestCase(the new name for
central management of checkouts that supports caching of checkouts. Upon
suite setup, a directory will be created where checkouts can go. There's
a working area, which the subclass can populate with as many or as few
checkouts as the suite needs, and there's a cache.
Subclasses that implement
setup_checkout()will place these checkouts
in the working area path.
SCMClientTestCasethen places that in the
cache, and deletes it when the suite tears down.
On each test run, the cached copy is restored back to the workarea
through a tree copy, which is generally faster than a clone/checkout
operation. The tests can do what they need with the checkout. That
checkout will then be cleared away and repopulated on the next test run.
In my tests here, this effectively reduces the
time by about 30-40 seconds.
Unit tests pass.
Fixed alignment issues.
Revision 2 (+680 -208)
Checks run (2 succeeded)