Compile Tests

Overview

Compile tests check source files for valid syntax on all supported python versions:

  • 2.4 (Ansible 2.3 only)
  • 2.6
  • 2.7
  • 3.5
  • 3.6

Running compile tests locally

Unit tests can be run across the whole code base by doing:

cd /path/to/ansible/source
source hacking/env-setup
ansible-test compile

Against a single file by doing:

ansible-test compile lineinfile

Or against a specific Python version by doing:

ansible-test compile --python 2.7 lineinfile

For advanced usage see the help:

ansible-test units --help

Installing dependencies

ansible-test has a number of dependencies , for compile tests we suggest running the tests with --local, which is the default

The dependencies can be installed using the --requirements argument. For example:

ansible-test units --requirements lineinfile

The full list of requirements can be found at test/runner/requirements. Requirements files are named after their respective commands. See also the constraints applicable to all commands.

Extending compile tests

If you believe changes are needed to the Compile tests please add a comment on the Testing Working Group Agenda so it can be discussed.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/dev_guide/testing_compile.html