Use pymultic for executing the rt_test
This commit is contained in:
@@ -9,72 +9,19 @@ if [[ -z "$testdir" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
py_versions=('1.5.2' '2.2.3' '2.5.6' '2.6.9' '2.7.12' '3.1.5' '3.4.5' '3.5.2')
|
||||
py_url="http://www.python.org/ftp/python"
|
||||
|
||||
# Make subcommand errors fatal
|
||||
set -e
|
||||
|
||||
fetch_python() {
|
||||
local url="$1"
|
||||
local tarball="${url##*/}"
|
||||
local version="$2"
|
||||
|
||||
if [[ ! -d "Python-${version}" ]]; then
|
||||
echo "Downloading Python ${version}"
|
||||
curl -LfO# "$url"
|
||||
tar xzf "$tarball"
|
||||
if [[ -f "${srcdir}/scripts/python-builds/Python-${version}.patch" ]]; then
|
||||
cd "Python-${version}"
|
||||
patch -p1 < "${srcdir}/scripts/python-builds/Python-${version}.patch"
|
||||
cd ..
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cd "$startdir"
|
||||
mkdir -p python-builds
|
||||
cd python-builds
|
||||
|
||||
# Special case for Python 1.5
|
||||
fetch_python "${py_url}/src/py152.tgz" "1.5.2"
|
||||
|
||||
for pv in ${py_versions[@]:1}; do
|
||||
fetch_python "${py_url}/${pv}/Python-${pv}.tgz" "$pv"
|
||||
done
|
||||
|
||||
for pv in ${py_versions[@]}; do
|
||||
if [[ ! -x "Python-${pv}/python" ]]; then
|
||||
echo -n "Building Python ${pv}... "
|
||||
cd "Python-${pv}"
|
||||
rm -f "../Python-${pv}.conf.log"
|
||||
rm -f "../Python-${pv}.build.log"
|
||||
if ! ./configure > "../Python-${pv}.conf.log" 2>&1 ; then
|
||||
echo "Configure failed!"
|
||||
echo "See python-builds/Python-${pv}.conf.log for details"
|
||||
exit 1
|
||||
fi
|
||||
if ! make > "../Python-${pv}.build.log" 2>&1 ; then
|
||||
echo "Build failed!"
|
||||
echo "See python-builds/Python-${pv}.build.log for details"
|
||||
exit 1
|
||||
fi
|
||||
cd ..
|
||||
echo "Success!"
|
||||
fi
|
||||
done
|
||||
if [[ ! -d "$testdir" ]]; then
|
||||
echo "Test directory $testdir does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
cd "$testdir"
|
||||
|
||||
# Run any .pyc.src files in $testdir back through its respective python compiler
|
||||
cd "$startdir"
|
||||
|
||||
fails=0
|
||||
files=()
|
||||
errors=()
|
||||
|
||||
set +e
|
||||
|
||||
shopt -s nullglob
|
||||
rtsources=("$testdir"/*.pyc.src.py)
|
||||
rtsources=(*.pyc.src.py)
|
||||
shopt -u nullglob
|
||||
|
||||
if (( ${#rtsources[@]} == 0 )); then
|
||||
@@ -86,29 +33,12 @@ for srcf in "${rtsources[@]}"; do
|
||||
# There's probably a better way...
|
||||
srcver=$(grep '# File: .* (Python [0-9]\.[0-9]\+)$' "$srcf" | sed -e 's/.* (Python //' -e 's/)//')
|
||||
|
||||
_found=0
|
||||
for version in ${py_versions[@]}; do
|
||||
if [[ "${version%.*}" == "$srcver" ]]; then
|
||||
_found=1
|
||||
base="tests/$(basename "$srcf")"
|
||||
python-builds/Python-${version}/python \
|
||||
-c "import py_compile; py_compile.compile('$srcf')" 2>"$base.rterr"
|
||||
if (( $? )) || [[ -s "$base.rterr" ]]; then
|
||||
let fails+=1
|
||||
files+=("$srcf")
|
||||
errors+=("$(cat "$base.rterr")")
|
||||
echo -ne "\033[31m.\033[m"
|
||||
else
|
||||
echo -ne "\033[32m.\033[m"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if (( _found == 0 )); then
|
||||
base="$(basename "$srcf")"
|
||||
"$srcdir"/scripts/pymultic "$srcver" "$srcf" 2> "$base.rterr"
|
||||
if (( $? )) || [[ -s "$base.rterr" ]]; then
|
||||
let fails+=1
|
||||
files+=("$srcf")
|
||||
errors+=("No python compiler found for $srcf ($srcver)")
|
||||
echo -ne "\033[31m.\033[m"
|
||||
errors+=("$(cat "$base.rterr")")
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ if len(pythons) == 0:
|
||||
sys.exit(1)
|
||||
|
||||
snekdir = os.path.dirname(os.path.realpath(__file__))
|
||||
result = 0
|
||||
for ver in pythons:
|
||||
pyexe = acquire_python(snekdir, ver)
|
||||
proc = subprocess.Popen([pyexe, '-c', 'import sys; print(sys.version)'],
|
||||
@@ -161,17 +162,20 @@ for ver in pythons:
|
||||
out, _ = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print('Could not determine Python version for {}'.format(ver))
|
||||
result = 1
|
||||
continue
|
||||
|
||||
bcver = str(out, 'iso-8859-1').split(' ', 1)[0]
|
||||
if not bcver.startswith(ver):
|
||||
print('Python {} reported itself as version {}!'.format(ver, bcver))
|
||||
result = 1
|
||||
continue
|
||||
|
||||
if '.py' in infile:
|
||||
outfile = infile.replace('.py', '.{}.pyc'.format(ver))
|
||||
if infile.endswith('.py'):
|
||||
outfile = os.path.basename(infile)[:-3]
|
||||
else:
|
||||
outfile = infile + '.{}.pyc'.format(ver)
|
||||
outfile = os.path.basename(infile)
|
||||
outfile += '.{}.pyc'.format(ver)
|
||||
if os.path.exists(outfile):
|
||||
os.unlink(outfile)
|
||||
|
||||
@@ -201,3 +205,8 @@ for ver in pythons:
|
||||
"import py_compile; py_compile.compile('{}', '{}')" \
|
||||
.format(infile, outfile)])
|
||||
proc.communicate()
|
||||
|
||||
if not os.path.exists(outfile):
|
||||
result = 1
|
||||
|
||||
sys.exit(result)
|
||||
|
||||
Reference in New Issue
Block a user