libabigail/tests/runtestfedabipkgdiffpy3.sh.in
Chenxiong Qi 1ac0c055fa Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2
This patch makes fedabipkgdiff Python 3 compatible.  All tests written
in Python are updated and compatible with Python 3 as well.

The patch looks for a Python 3 interperter.  If it finds one then it
runs the tests using that interpreter.  Otherwise it just tries to use
the Python 2 interpreter.

This behaviour can be disabled by the new --disable-python3 option.

	* configure.ac: Add new option --enable-python3. Add new
	test runner file tests/runtestdefaultsupprs-py3 and
	tests/runtestfedabipkgdiffpy3.sh. Add required six Python module.
	* tests/Makefile.am: Add new test files
	tests/runtestdefaultsupprspy3.sh and
	tests/runtestfedabipkgdiffpy3.sh accordingly.
	* tests/mockfedabipkgdiff.in: Convert print statement to
	six.print_. Replace call to function filter with list
	comprehension. Replace basestring with six.string_types.
	* tests/runtestdefaultsupprspy3.sh.in: New shell script to run
	test runtestdefaultsupprs with Python 3.
	* tests/runtestdefaultsupprs.py.in: Repalce a few tabs with
	proper number of spaces which is detected by Python 3
	interpreter.
	* tests/runtestfedabipkgdiffpy3.sh.in: New shell script to run
	test runtestfedabipkgdiff with Python 3.
	* tests/runtestfedabipkgdiff.py.in: Use python from env in
	shebang instead of a fixed path to a Python interpreter.
	* tools/fedabipkgdiff: Globally replace print statement with a
	function call to print which is available by importing
	print_function from __future__ module. Use six.print_ to output
	string to stderr instead. Convert function call to map to
	for-loop. (cmp_nvr): Change argument to handle a Koji build
	mapping instead of only the nvr. (Brew.listBuilds): use the new
	cmp_nvr to sort builds.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-29 13:46:50 +02:00

23 lines
557 B
Bash

#!/bin/bash -e
# Either tests runner script or the tools/fedabipkgdiff has shebang
# `/usr/bin/env python`, as a result, to run tests in Python 3, we have to
# change PATH in order to make sure python can be found before the current
# $PATH.
PY3_TEMP=$(mktemp -d --tmpdir libabigail-py3-temp-XXXXXXXX)
ln -s $(which @PYTHON3_INTERPRETER@) $PY3_TEMP/python
export PATH=$PY3_TEMP:$PATH
function clean_env
{
unlink $PY3_TEMP/python
rmdir $PY3_TEMP
}
trap "clean_env" EXIT
@PYTHON3_INTERPRETER@ "@abs_top_builddir@/tests/runtestfedabipkgdiff.py"