From fa54ff21e1baba7717a4f9442c90596211b6d6ed Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 16 Jan 2018 12:32:49 -0600 Subject: [PATCH] Clean up when conditions in fetch-subunit-output Review comments from earlier requested a cleaner approach to the whens with using blocks. This patch started off as that, then realized we could make it even clearer by collapsing the tox_envlist when as well. Change-Id: I2a32f1aa802c0727b7d15f24f58322d5e26c8693 --- roles/fetch-subunit-output/tasks/main.yaml | 40 +++++++++------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/roles/fetch-subunit-output/tasks/main.yaml b/roles/fetch-subunit-output/tasks/main.yaml index ae0d74323..4d0e76e2e 100644 --- a/roles/fetch-subunit-output/tasks/main.yaml +++ b/roles/fetch-subunit-output/tasks/main.yaml @@ -1,3 +1,17 @@ +# TODO(mordred) tox_envlist can be a list. If it is, we should look for each +# command in each envlist dir until we find one that has it. +- name: Set paths to testr and stestr commands from tox + set_fact: + testr_command: .tox/{{ tox_envlist }}/bin/testr + stestr_command: .tox/{{ tox_envlist }}/bin/stestr + when: tox_envlist is defined + +- name: Set paths to testr and stestr commands from system + set_fact: + testr_command: testr + stestr_command: stestr + when: tox_envlist is not defined + # NOTE(mordred) Check for the failing file in the .stestr directory instead of # just the directory. An stestr run that fails due to python parsing errors # will leave a directory but with no test results, which will result in an @@ -9,19 +23,9 @@ - name: Generate stestr subunit file shell: - cmd: ".tox/{{ tox_envlist }}/bin/stestr last --subunit > ./testrepository.subunit" + cmd: "{{ stestr_command }} last --subunit > ./testrepository.subunit" chdir: "{{ zuul_work_dir }}" - when: - - tox_envlist is defined - - stestr_stat.stat.exists - -- name: Generate stestr subunit file - shell: - cmd: "stestr last --subunit > ./testrepository.subunit" - chdir: "{{ zuul_work_dir }}" - when: - - tox_envlist is not defined - - stestr_stat.stat.exists + when: stestr_stat.stat.exists - name: Check for testr directory stat: @@ -31,19 +35,9 @@ - name: Generate testrepository.subunit file shell: - cmd: ".tox/{{ tox_envlist }}/bin/testr last --subunit > ./testrepository.subunit" + cmd: "{{ testr_command }} last --subunit > ./testrepository.subunit" chdir: "{{ zuul_work_dir }}" when: - - tox_envlist is defined - - not stestr_stat.stat.exists - - testr_stat.stat.exists - -- name: Generate testrepository.subunit file - shell: - cmd: "testr last --subunit > ./testrepository.subunit" - chdir: "{{ zuul_work_dir }}" - when: - - tox_envlist is not defined - not stestr_stat.stat.exists - testr_stat.stat.exists