From 71483d333d5ab1cbed3d904b22acf61a6584574b Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 8 Feb 2022 16:26:41 +0100 Subject: [PATCH] Run tox by module name (python -m tox) Change-Id: Iafb1d3efe6d44d58f2c8bf7f72026b4873d725d9 --- roles/tests/test_infrared_plugin.yaml | 2 +- roles/tobiko-ensure-tox/tasks/tox.yaml | 28 ++++++-------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/roles/tests/test_infrared_plugin.yaml b/roles/tests/test_infrared_plugin.yaml index cd73b49ac..d574f508d 100644 --- a/roles/tests/test_infrared_plugin.yaml +++ b/roles/tests/test_infrared_plugin.yaml @@ -38,7 +38,7 @@ - name: "run Tox InfraRed plugin" shell: cmd: > - '{{ tox_executable }}' -e infrared -- --collect-dir '{{ test_collect_dir }}' + {{ tox_executable }} -e infrared -- --collect-dir '{{ test_collect_dir }}' chdir: '{{ test_dir }}' ignore_errors: yes register: run_tox diff --git a/roles/tobiko-ensure-tox/tasks/tox.yaml b/roles/tobiko-ensure-tox/tasks/tox.yaml index 33a16b809..3e3cb4cb6 100644 --- a/roles/tobiko-ensure-tox/tasks/tox.yaml +++ b/roles/tobiko-ensure-tox/tasks/tox.yaml @@ -1,39 +1,23 @@ --- - name: "ensure Tox is installed" - command: | - '{{ python_executable }}' -m pip install --user 'tox>={{ tox_min_version }}' + command: > + {{ python_executable }} -m pip install --user 'tox>={{ tox_min_version }}' register: install_tox changed_when: "'Successfully installed' in install_tox.stdout" - -- block: - - name: "get '{{ tox_command }}' full path" - shell: | - export PATH={{ python_exe_path }} - which '{{ tox_command }}' - register: get_tox_path - - - name: "set tox_executable fact" - set_fact: - tox_executable: '{{ get_tox_path.stdout_lines | first }}' - - rescue: - - name: "set tox_executable fact" - set_fact: - tox_executable: '{{ ansible_user_dir }}/.local/bin/tox' - +- name: "set tox_executable fact" + set_fact: + tox_executable: "{{ python_executable }} -m tox" - name: "get installed Tox version" - command: "'{{ tox_executable }}' --version" + command: "{{ tox_executable }} --version" register: get_tox_version - - name: "update tox_version fact" set_fact: tox_version: '{{ get_tox_version.stdout_lines | first }}' - - name: "show Tox facts" debug: msg: