Skip to content

perf(list_plugin): make test_map lazy - #336

Open
speriaswamy-amd wants to merge 2 commits into
speriaswamy/cvsman-02-package-rootfrom
speriaswamy/cvsman-03-lazy-test-map
Open

perf(list_plugin): make test_map lazy#336
speriaswamy-amd wants to merge 2 commits into
speriaswamy/cvsman-02-package-rootfrom
speriaswamy/cvsman-03-lazy-test-map

Conversation

@speriaswamy-amd

Copy link
Copy Markdown
Contributor

Part 3 of 14 in a stack for AIMVT-276. Base: #335.

Why

main.py's discover_plugins() instantiates every plugin on every CLI invocation to build the argparse structure, regardless of which subcommand actually runs. ListPlugin.__init__ computed test_map eagerly via a full os.walk of cvs/tests/, so list and run (both ListPlugin subclasses) already walked the tree twice per invocation for no reason. A third subclass (man) is coming later in this stack, which would make it three.

What changed

  • cvs/cli_plugins/list_plugin.pytest_map is now a lazily-computed @property backed by self._test_map, walked on first access instead of at construction.
  • cvs/cli_plugins/unittests/test_list_plugin.py — updated the one test that asserted discovery happened at construction time.

main.py's discover_plugins() instantiates every plugin on every CLI
invocation to build the argparse structure, regardless of which subcommand
actually runs. ListPlugin computed test_map eagerly in __init__ via a full
os.walk of cvs/tests/, so `list` and `run` (both ListPlugin subclasses)
already walked the tree twice per invocation for nothing; a third subclass
is coming next. Make it a lazily-computed property instead.

AIMVT-276.
…rebase

An earlier commit on this branch was built from a stale base and
silently reverted main's fix that excludes private helper modules
(e.g. _shared.py) from test discovery. Re-apply it alongside the lazy
test_map property.

AIMVT-276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant