This role currently does
which tox || pip install --user tox
and then sets "tox_exectuable" iff it has installed tox into the
user's pip environment.
This isn't idempotent -- if you run ensure-tox again, it will again
run "which tox" and miss that it already installed tox in the private
pip environment. Instead, make it look for
"which {{ tox_executable }}" ... this way it will find the install it
just did if it runs again.
There seems to be no reason to only set "tox_exectuable" in the case
this role had to install tox. Make this *always* set tox_exectuable
so that you can run ensure-tox and then be sure tox_exectuable is
something sane.
The current testing assumes that tox is installed in the base image.
We are working to remove this assumption; remove this part of the
test.
Rework the testing to first clear out any existing tox, which is
present on most images but will have no effect on the -plain images.
Then test when we install fresh it goes into the user pip install
area, and then test if we explicitly set tox_exectuable it overrides.
Change-Id: I36cfb62f2a2e2b9c2bbe92b46ed0b8098a873732
53 lines
1.5 KiB
YAML
53 lines
1.5 KiB
YAML
- hosts: all
|
|
name: Remove any pre-installed tox
|
|
tasks:
|
|
- name: Remove tox package with pip
|
|
shell: pip uninstall -y tox
|
|
become: true
|
|
failed_when: false
|
|
- name: Remove tox package with pip3
|
|
shell: pip3 uninstall -y tox
|
|
become: true
|
|
failed_when: false
|
|
- name: Verify tox is not installed
|
|
command: "tox --version"
|
|
register: result
|
|
failed_when: result.rc == 0
|
|
|
|
- hosts: all
|
|
name: Test ensure-tox installs into user environment
|
|
tasks:
|
|
- name: Verify tox is not installed
|
|
command: "tox --version"
|
|
register: result
|
|
failed_when: result.rc == 0
|
|
- name: Run ensure-tox with tox not installed
|
|
include_role:
|
|
name: ensure-tox
|
|
- name: Verify tox_executable is set
|
|
assert:
|
|
that:
|
|
- tox_executable == "{{ ansible_user_dir }}/.local/bin/tox"
|
|
- name: Verify tox is installed
|
|
command: "{{ tox_executable }} --version"
|
|
register: result
|
|
failed_when: result.rc != 0
|
|
|
|
- hosts: all
|
|
name: Test ensure-tox when tox_executable is set to an already installed tox
|
|
tasks:
|
|
- name: Install tox inside a virtualenv
|
|
pip:
|
|
name: tox
|
|
virtualenv: "{{ ansible_user_dir }}/tox-venv"
|
|
- name: Run ensure-tox pointing to an already installed tox
|
|
include_role:
|
|
name: ensure-tox
|
|
vars:
|
|
tox_executable: "{{ ansible_user_dir }}/tox-venv/bin/tox"
|
|
- name: Verify tox_executable is set to the virtualenv tox
|
|
assert:
|
|
that:
|
|
- tox_executable == '{{ ansible_user_dir}}/tox-venv/bin/tox'
|
|
|