You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Start another kind of testing...
And fix a bug found in that with 3-way equal
This commit is contained in:
BIN
test/bytecode_2.7/01_triple_compare.pyc
Normal file
BIN
test/bytecode_2.7/01_triple_compare.pyc
Normal file
Binary file not shown.
3
test/stdlib/README.md
Normal file
3
test/stdlib/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
The programs in here are to test Python stdlib tests in lib/pythonX.Y/test
|
||||||
|
|
||||||
|
We'll compile a test, then decompile it and then run the test
|
23
test/stdlib/compile-file.py
Executable file
23
test/stdlib/compile-file.py
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import sys
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: compile-file.py *python-file*")
|
||||||
|
sys.exit(1)
|
||||||
|
source = sys.argv[1]
|
||||||
|
|
||||||
|
assert source.endswith('.py')
|
||||||
|
basename = source[:-3]
|
||||||
|
|
||||||
|
# We do this crazy way to support Python 2.6 which
|
||||||
|
# doesn't support version_major, and has a bug in
|
||||||
|
# floating point so we can't divide 26 by 10 and get
|
||||||
|
# 2.6
|
||||||
|
PY_VERSION = sys.version_info[0] + (sys.version_info[1] / 10.0)
|
||||||
|
|
||||||
|
bytecode = "%s-%s.pyc" % (basename, PY_VERSION)
|
||||||
|
|
||||||
|
import py_compile
|
||||||
|
print("compiling %s to %s" % (source, bytecode))
|
||||||
|
py_compile.compile(source, bytecode, 'exec')
|
||||||
|
# import os
|
||||||
|
# os.system("../bin/uncompyle6 %s" % bytecode)
|
58
test/stdlib/runtests.sh
Executable file
58
test/stdlib/runtests.sh
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
me=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
|
# Python version setup
|
||||||
|
FULLVERSION=${1:-2.7.14}
|
||||||
|
PYVERSION=${FULLVERSION%.*}
|
||||||
|
MINOR=${FULLVERSION##?.?.}
|
||||||
|
|
||||||
|
typeset -i STOP_ONERROR=1
|
||||||
|
typeset -A SKIP_TESTS=( [test_aepack.py]=1 [audiotests.py]=1)
|
||||||
|
|
||||||
|
# Test directory setup
|
||||||
|
srcdir=$(dirname $me)
|
||||||
|
cd $srcdir
|
||||||
|
fulldir=$(pwd)
|
||||||
|
TESTDIR=/tmp/test${PYVERSION}
|
||||||
|
if [[ -e $TESTDIR ]] ; then
|
||||||
|
rm -fr $TESTDIR
|
||||||
|
fi
|
||||||
|
mkdir $TESTDIR || exit $?
|
||||||
|
cp -r ~/.pyenv/versions/${PYVERSION}.${MINOR}/lib/python${PYVERSION}/test $TESTDIR
|
||||||
|
cd $TESTDIR/test
|
||||||
|
export PYTHONPATH=$TESTDIR
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
typeset -i i=0
|
||||||
|
typeset -i allerrs=0
|
||||||
|
for file in test_*.py; do
|
||||||
|
[[ -v SKIP_TESTS[$file] ]] && continue
|
||||||
|
|
||||||
|
# If the fails *before* decompiling, skip it!
|
||||||
|
if ! python $file >/dev/null 2>&1 ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
((i++))
|
||||||
|
# (( i > 40 )) && break
|
||||||
|
short_name=$(basename $file .py)
|
||||||
|
decompiled_file=$short_name-${PYVERSION}.pyc
|
||||||
|
$fulldir/compile-file.py $file && \
|
||||||
|
mv $file{,.orig} && \
|
||||||
|
$fulldir/../../bin/uncompyle6 $decompiled_file > $file
|
||||||
|
rc=$?
|
||||||
|
if (( rc == 0 )) ; then
|
||||||
|
echo ========== Running $file ===========
|
||||||
|
python $file
|
||||||
|
rc=$?
|
||||||
|
else
|
||||||
|
echo ======= Skipping $file due to compile/decompile errors ========
|
||||||
|
fi
|
||||||
|
(( rc != 0 && allerrs++ ))
|
||||||
|
if (( STOP_ONERROR && rc )) ; then
|
||||||
|
echo "** Ran $i tests before failure **"
|
||||||
|
exit $allerrs
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Ran $i tests"
|
||||||
|
exit $allerrs
|
@@ -203,6 +203,8 @@ class Python2Parser(PythonParser):
|
|||||||
binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
|
binary_subscr2 ::= expr expr DUP_TOPX_2 BINARY_SUBSCR
|
||||||
|
|
||||||
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
|
conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr
|
||||||
|
cmp_list2 ::= expr COMPARE_OP RETURN_VALUE
|
||||||
|
cmp_list2 ::= expr COMPARE_OP RETURN_VALUE_LAMBDA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def p_slice2(self, args):
|
def p_slice2(self, args):
|
||||||
|
Reference in New Issue
Block a user