Today hacking only provides consumers specifying the local check
factory function via tox.ini (in the '[hacking]' section). While this works
fine in a number of cases, others need a way to specify multiple
check factories without using multiple tox.ini files.
For example, we'd like a library project to define a common set of hacking
check functions for consumers. Some of those factory functions
may register checks we want consumers to run in 'warn only' mode.
From a tox.ini perspective, we'd like to be able to do this:
[testenv:pep8]
commands =
# run mandatory checks in fail mode
flake8 --factory a.b.c.mandatory
# run incubating checks in warn-only mode
flake8 --factory a.b.c.incubating --exit-zero
Today the above isn't possible without 2 separate tox.ini files;
each to specify the local-check-factory. While we can use our
own flake8 extension [1], it would be better to have this
support built right into hacking enabling a broader set of use
cases.
This patch adds a CLI option called --local-check-factory that
allows consumers to pass a local-check-factory via CLI. If
specified on CLI, it overrides anything in tox.ini. Using this
patch consumers can achieve the use case noted above and this
should also be backwards compatible.
[1] https://review.openstack.org/#/c/350723/14/neutron_lib/hacking/checks.py@286
Change-Id: I26f68e11d21938a13974c4e7684eea604dfc2e69