2018-09-11 18:51:47 +02:00
|
|
|
:orphan:
|
|
|
|
|
2018-09-07 15:57:36 +02:00
|
|
|
.. _testing_sanity:
|
|
|
|
|
2017-04-28 10:08:26 +02:00
|
|
|
************
|
2017-04-14 02:46:21 +02:00
|
|
|
Sanity Tests
|
2017-04-28 10:08:26 +02:00
|
|
|
************
|
|
|
|
|
|
|
|
.. contents:: Topics
|
2017-04-14 02:46:21 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
How to run
|
|
|
|
==========
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2020-04-07 16:17:44 +02:00
|
|
|
.. note::
|
|
|
|
To run sanity tests using docker, always use the default docker image
|
|
|
|
by passing the ``--docker`` or ``--docker default`` argument.
|
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
.. code:: shell
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
source hacking/env-setup
|
2017-04-28 10:08:26 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
# Run all sanity tests
|
|
|
|
ansible-test sanity
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
# Run all sanity tests against against certain files
|
|
|
|
ansible-test sanity lib/ansible/modules/files/template.py
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
# Run all tests inside docker (good if you don't have dependencies installed)
|
|
|
|
ansible-test sanity --docker default
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
# Run validate-modules against a specific file
|
|
|
|
ansible-test sanity --test validate-modules lib/ansible/modules/files/template.py
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
Available Tests
|
|
|
|
===============
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
Tests can be listed with ``ansible-test sanity --list-tests``.
|
2017-04-14 02:46:21 +02:00
|
|
|
|
2019-02-26 18:27:39 +01:00
|
|
|
See the full list of :ref:`sanity tests <all_sanity_tests>`, which details the various tests and details how to fix identified issues.
|