summaryrefslogtreecommitdiffstats
path: root/docs/docsite/rst/dev_guide/testing_sanity.rst
blob: a4f99eddecf8179afd281e617cf50a568ee82c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
:orphan:

.. _testing_sanity:

************
Sanity Tests
************

.. contents:: Topics

Sanity tests are made up of scripts and tools used to perform static code analysis.
The primary purpose of these tests is to enforce Ansible coding standards and requirements.

Tests are run with ``ansible-test sanity``.
All available tests are run unless the ``--test`` option is used.


How to run
==========

.. note::
   To run sanity tests using docker, always use the default docker image
   by passing the ``--docker`` or ``--docker default`` argument.

.. note::
   When using docker and the ``--base-branch`` argument,
   also use the ``--docker-keep-git`` argument to avoid git related errors.

.. code:: shell

   source hacking/env-setup

   # Run all sanity tests
   ansible-test sanity

   # Run all sanity tests including disabled ones
   ansible-test sanity --allow-disabled

   # Run all sanity tests against against certain files
   ansible-test sanity lib/ansible/modules/files/template.py

   # Run all tests inside docker (good if you don't have dependencies installed)
   ansible-test sanity --docker default

   # Run validate-modules against a specific file
   ansible-test sanity --test validate-modules lib/ansible/modules/files/template.py

Available Tests
===============

Tests can be listed with ``ansible-test sanity --list-tests``.

See the full list of :ref:`sanity tests <all_sanity_tests>`, which details the various tests and details how to fix identified issues.