Browse Source

Extended tests documentation

Matthias Reso 1 year ago
parent
commit
4f837bc827
1 changed files with 12 additions and 1 deletions
  1. 12 1
      CONTRIBUTING.md

+ 12 - 1
CONTRIBUTING.md

@@ -33,6 +33,7 @@ under the LICENSE file in the root directory of this source tree.
 ## Tests
 Llama-recipes currently comes with a basic set of unit tests but we strive to increase our test coverage in the future in order to mitigate silent errors.
 When submitting a new feature PR please make sure to cover the newly added code with a unit test.
+Run the tests locally to ensure the new feature does not break an old one.
 We use **pytest** for our unit tests and to run them locally you need to install llama-recipes with optional [tests] dependencies enabled:
 ```
 pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-recipes[tests]
@@ -40,4 +41,14 @@ pip install --extra-index-url https://download.pytorch.org/whl/test/cu118 llama-
 The unit tests can be found in the [tests](./tests/) folder and you can run them from the main directory using:
 ```
 python -m pytest tests/
-```
+```
+To run all tests of a single file you can give the filename directly:
+```
+python -m pytest tests/test_finetuning.py
+```
+To run a specific test you can filter for its name with
+```
+python -m pytest tests/test_finetuning.py -k test_finetuning_peft
+```
+To add a new test simply create a new test file under the tests folder (filename has to start with `test_`).
+Group tests spanning the same feature in the same file and create a subfolder if the tests are very extensive.