f6a92ecb6c
Use subunit2html from tox envs instead of os-testr-env We have an openstack-infra hard-coded location in this role. Rework it to try looking in the tox env if one exists or to look on the system. Leave /usr/os-testr-env in as a fallback but with a debug statement so that we can track instances of the fallback being used. tox_envlist can be a comma separated list. If it is, the "find subunit2html in a tox env" logic isn't going to work. Use a shell script so that we can do a first-found logic similar to what we use in ensure-sphinx for finding requirements files. It's a big bash blob. Put it in a file so it syntax highlights correctly and execute it with the script module. Change-Id: I0b468840fd04a379007fe5aca07feb2eaf7081ac
60 lines
1.9 KiB
Bash
60 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# Copyright (c) 2018 Red Hat, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
set -eu
|
|
|
|
zuul_work_dir=$1
|
|
|
|
# Use cd in the script rather than chdir from the script module. The chdir
|
|
# has some source-code comments that indicate for script that it needs to be
|
|
# an absolute path. Since our zuul_work_dir defaults to
|
|
# "{{ zuul.project.src_dir }}" in many places, that could be rather bad.
|
|
# The script can ensure it starts from the home dir and then change into the
|
|
# directory, which should work for both relative and absolute paths.
|
|
cd $HOME
|
|
cd $zuul_work_dir
|
|
|
|
commands=""
|
|
if [[ -d .testrepository ]] ; then
|
|
commands="testr ${commands}"
|
|
fi
|
|
|
|
# NOTE(mordred) Check for the failing file in the .stestr directory
|
|
# nstead of just the directory. A stestr run that fails due to python
|
|
# parsing errors will leave a directory but with no test results, which
|
|
# will result in an error in the subunit generation phase.
|
|
if [[ -f .stestr/failing ]] ; then
|
|
commands="stestr ${commands}"
|
|
fi
|
|
|
|
# Add all the tox envs to the path so that type will work. Prefer tox
|
|
# envs to system path. If there is more than one tox env, it doesn't
|
|
# matter which one we use, PATH will find the first command.
|
|
if [[ -d .tox ]] ; then
|
|
for tox_bindir in $(find .tox -mindepth 2 -maxdepth 2 -name 'bin') ; do
|
|
PATH=$(pwd)/$tox_bindir:$PATH
|
|
done
|
|
fi
|
|
|
|
for command in $commands; do
|
|
found=$(type -p $command)
|
|
if [[ -n $found ]] ; then
|
|
echo $found
|
|
break
|
|
fi
|
|
done
|