Allow the diff tools registry to be reset, and reset in one test.

Review Request #12632 — Created Sept. 23, 2022 and submitted

Information

RBTools
release-4.x

Reviewers

We have a unit test that spies on GNUDiffTool.check_available() to
simulate a result, and this ended up leaking state into other tests,
since instances of diff tools are cached by the registry.

This change implements the ability to reset the registry. This is
currently done in only the one test that leaks state at the moment,
though potentially we'd consider it worthwhile to do this on test
teardown later.

It also changes the caching mechanism used for
BaseSCMClient.get_diff_tool() to just store a local copy on the
instance, as @lru_cache can cause memory leaks when used on class
methods.

Unit tests pass.

Tested this with upcoming changes, which were sensitive to this state
leak.

Summary ID
Allow the diff tools registry to be reset, and reset in one test.
We have a unit test that spies on `GNUDiffTool.check_available()` to simulate a result, and this ended up leaking state into other tests, since instances of diff tools are cached by the registry. This change implements the ability to reset the registry. This is currently done in only the one test that leaks state at the moment, though potentially we'd consider it worthwhile to do this on test teardown later.
eac7a16897c29a1a5e727a773f28bfa0da3635b8
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.x (8557181)