Speed up SCM tests through cached checkout management.

Review Request #11824 — Created Sept. 27, 2021 and submitted

Information

RBTools
master

Reviewers

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
really slow.

Now, SCMClientTestCase (the new name for SCMClientTests) provides
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. SCMClientTestCase then 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 rbtools.clients.tests
time by about 30-40 seconds.

Unit tests pass.

Summary ID
Speed up SCM tests through cached checkout management.
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 really slow. Now, `SCMClientTestCase` (the new name for `SCMClientTests`) provides 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. `SCMClientTestCase` then 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 `rbtools.clients.tests` time by about 30 seconds.
4302a2ce43ead1d442169e1fd2502486badf378e
Description From Last Updated

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (c1aa8a0)