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