summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-07-27 22:18:08 +0200
committerArthur de Jong <arthur@arthurdejong.org>2013-07-28 19:49:38 +0200
commit5adc2cae8909924dadeac78916d1b14680dc8061 (patch)
treea81ce7ea9bb23b2a2556e3005c5b246b9ec3385f /tests
parente17730f5bd2ad179dbac47a11d56f86a0ea42f07 (diff)
Have test_pycompile not write any pyc files
We need to avoid writing pyc files because during make distcheck, the source directory is read-only. This also ensures that the test is skipped if the Python interpreter is not found.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_pycompile.sh37
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/test_pycompile.sh b/tests/test_pycompile.sh
index 21a1751..c429b1f 100755
--- a/tests/test_pycompile.sh
+++ b/tests/test_pycompile.sh
@@ -26,5 +26,38 @@ srcdir="${srcdir-`dirname "$0"`}"
top_srcdir="${top_srcdir-${srcdir}/..}"
python="${PYTHON-python}"
-# compile all Python files
-${python} -m compileall -f -q "${top_srcdir}"
+# if Python is missing, ignore
+if ! ${python} --version > /dev/null 2> /dev/null
+then
+ echo "Python (${python}) not found"
+ exit 77
+fi
+
+# compile all Python files (without writing pyc files)
+${python} -c "
+import os
+import py_compile
+import sys
+import traceback
+
+top_srcdir = '$top_srcdir'
+errors_found = 0
+tmpfile = 'tmpfile.pyc'
+
+for root, dirs, files in os.walk(top_srcdir):
+ for f in files:
+ if f.endswith('.py'):
+ filename = os.path.join(root, f)
+ try:
+ py_compile.compile(filename, tmpfile, doraise=True)
+ except py_compile.PyCompileError, e:
+ print 'Compiling %s ...' % os.path.abspath(filename)
+ print e
+ errors_found += 1
+
+os.unlink(tmpfile)
+
+if errors_found:
+ print '%d errors found' % errors_found
+ sys.exit(1)
+"