Skip to content

Commit 350ef3d

Browse files
authored
testing_sanity.rst: improvement (#2441)
* testing_sanity.rst: improvement * Add collection specific remarks * Change suggested
1 parent 8555ab6 commit 350ef3d

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

docs/docsite/rst/dev_guide/testing_sanity.rst

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,50 @@ The primary purpose of these tests is to enforce Ansible coding standards and re
1414
Tests are run with ``ansible-test sanity``.
1515
All available tests are run unless the ``--test`` option is used.
1616

17+
.. _set_up_env_to_run_tests:
18+
19+
Set up your environment
20+
=======================
21+
22+
1. :ref:`Install ansible-core<installation_guide>` that provides the ``ansible-test`` tool.
23+
24+
* If you want to run checks available in the development version of ``ansible-core``, :ref:`install it from source code<from_source>`.
25+
26+
* Run ``source hacking/env-setup`` from its source code directory in the same terminal session you run your tests.
27+
28+
2. Install ``podman`` or ``docker`` to avoid installing all the dependencies on your system.
29+
3. If you test files in a collection:
30+
31+
* Ensure you have your collection installed in the following path in your home directory: ``~/ansible_collections/<NAMESPACE>/<COLLECTION_NAME>``. For instance, in case of the ``community.general`` collection, it will be ``~/ansible_collections/community/general``
32+
* If your collection is hosted on a remote server such as GitHub, clone it to that path as follows: ``git clone <COLLECTION_REPO_URL> ~/ansible_collections/<NAMESPACE>/<COLLECTION_NAME>``
1733

1834
How to run
1935
==========
2036

2137
.. note::
22-
To run sanity tests using docker, always use the default docker image
23-
by passing the ``--docker`` or ``--docker default`` argument.
38+
To run sanity tests using podman or docker, always use the default docker image
39+
by passing the ``--docker`` argument without specifying the image name.
40+
41+
42+
1. When testing files in a collection, change your location to your collection directory you created while :ref:`setting up your environment<set_up_env_to_run_tests>`:
2443

2544
.. code:: shell
2645
27-
source hacking/env-setup
46+
cd ~/ansible_collections/<NAMESPACE>/<COLLECTION_NAME>
2847
29-
# Run all sanity tests
30-
ansible-test sanity
48+
2. To run all sanity tests in a container:
3149

32-
# Run all sanity tests including disabled ones
33-
ansible-test sanity --allow-disabled
50+
.. code:: shell
3451
35-
# Run all sanity tests against certain file(s)
36-
ansible-test sanity lib/ansible/modules/files/template.py
37-
38-
# Run all sanity tests against certain folder(s)
39-
ansible-test sanity lib/ansible/modules/files/
52+
ansible-test sanity --docker
4053
41-
# Run all tests inside docker (good if you don't have dependencies installed)
42-
ansible-test sanity --docker default
54+
* To run a :ref:`specific test<all_sanity_tests>`, add the ``--test <NAME>`` argument, for example, ``--test validate-modules``.
4355

44-
# Run validate-modules against a specific file
45-
ansible-test sanity --test validate-modules lib/ansible/modules/files/template.py
56+
* To list available tests, run: ``ansible-test sanity --list-tests``
57+
58+
* To include disabled tests, add the ``--allow-disabled`` argument.
4659

4760
Available Tests
4861
===============
4962

50-
Tests can be listed with ``ansible-test sanity --list-tests``.
51-
52-
See the full list of :ref:`sanity tests <all_sanity_tests>`, which details the various tests and details how to fix identified issues.
63+
See the full list of :ref:`sanity tests <all_sanity_tests>`, which also details how to fix identified issues.

0 commit comments

Comments
 (0)