meson icon indicating copy to clipboard operation
meson copied to clipboard

Cleanups and Speedup for python unittests

Open dcbaker opened this issue 1 year ago • 3 comments

I initially set out to just do some long overdue maintenance of our unit tests, along way I cleaned up a number of issues that have been bugging me for a while:

  • use mock instead of try/finally blocks
  • use os.enivon.get so that some things don't have to be set to run
  • move a lot of constant setup to setUpClass instead of setUp, which means the fixtures get run less
  • use more of our helpers instead of open coding
  • make more use of UnitTest.addCleanup
  • actually clean up more often, and move the cleanup code closer to the producer.
  • Allow our cleanup of Meson calls to happen even if the call to Meson itself fails
  • cleanup some complicated logic
  • use better/faster types
  • use properties for rarely used dynamic attributes
  • Use tmpdir instead of source dir when we can reasonably assume that there will not be Anti-Virus, and allow Windows users to force the use of the tmpdir

For me the end result is a reduction in a full unit test run time by ~15%, and there are no stray files left in the source tree compared to the main branch.

I wont be surprised if there are a few regressions on Windows to clean up.

dcbaker avatar Jul 16 '24 22:07 dcbaker

I've also reworded a few of the commit messages to fix typos, but I'll wait to re-push so I don't flood the CI

dcbaker avatar Jul 16 '24 22:07 dcbaker

Squashed and re-ordered a bit to address comments from IRC/Matrix. Attempting to fix the one test that is failing on Windows

dcbaker avatar Jul 17 '24 16:07 dcbaker

Partial review and partial merge of commits 85e92331c...4b76aabe3

eli-schwartz avatar Aug 15 '24 19:08 eli-schwartz

Other than the one change LGTM.

jpakkane avatar Oct 02 '24 22:10 jpakkane