@@ -109,7 +109,30 @@ These are enabled by adding a ``--test-suite`` option to the pytest command.
109109 extensive data-driven and data validations (for package, copyright and license
110110 detection)
111111
112+ In some cases we need to regenerate test data when expected behavious/result data
113+ structures change, and we have an environement variable to regenerate test data.
114+ `SCANCODE_REGEN_TEST_FIXTURES ` is present in `scancode_config ` and this can be
115+ set to regenerate test data for specific tests like this:
112116
117+ ``SCANCODE_REGEN_TEST_FIXTURES=yes pytest -vvs tests/packagedcode/test_package_models.py ``
118+
119+ This command will only regenerate test data for only the tests in `test_package_models.py `,
120+ and we can further specify the tests to regen by using more pytest options like `--lf ` and
121+ `-k test_instances `.
122+
123+ If test data is regenerated, it is important to review the diff for test files and
124+ carefully go through all of it to make sure there are no unintended changes there,
125+ and then commit all the regenerated test data.
126+
127+ To help debug in scancode, we use logging. There are different environement variables
128+ you need to set to turn on logging. In packagedcode::
129+
130+ ``SCANCODE_DEBUG_PACKAGE=yes pytest -vvs tests/packagedcode/ --lf ``
131+
132+ Or set the ``TRACE `` variable to ``True ``. This enables ``logger_debug `` functions
133+ logging variables and shows code execution paths by logging and printing the logs
134+ in the terminal. If debugging full scans run by click, you have to raise exceptions
135+ in addition to setting the TRACE to enable logging.
113136
114137.. _scancode_toolkit_development_thirdparty_libraries :
115138
0 commit comments