X Tutup
Skip to content

Commit 3d4e23c

Browse files
committed
Add tests and start a more turnkey testing system.
1 parent 832debe commit 3d4e23c

File tree

130 files changed

+12657
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+12657
-201
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
*_dis
12
*.pyc
23
*~
34
/.python-version
5+
/dist
46
/uncompyle6.egg-info
57
build

Makefile

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,22 @@ html:
2323
#: Same as "check"
2424
test: check
2525

26-
#: Same as "check"
27-
nosetests: check
28-
29-
#: Run all tests
30-
check-short: test-unit-short
31-
32-
#: Run all tests: unit, functional and integration verbosely
33-
check: test-unit lint
34-
35-
#: Run unit (white-box) tests
36-
test-unit:
37-
$(PYTHON) ./setup.py nosetests
38-
39-
#: Run unit (white-box) tests
40-
test-unit-short:
41-
$(PYTHON) ./setup.py nosetests --quiet 2>&1 | \
42-
$(PYTHON) ./test/make-check-filter.py
26+
#: Run tests
27+
check check-short:
28+
$(MAKE) -C test $@
4329

4430
#: Clean up temporary files and .pyc files
4531
clean: clean_pyc
4632
$(PYTHON) ./setup.py $@
33+
(cd test && $(MAKE) clean)
4734

4835
#: Create source (tarball) and binary (egg) distribution
4936
dist:
5037
$(PYTHON) ./setup.py sdist bdist_egg
5138

5239
#: Remove .pyc files
5340
clean_pyc:
54-
$(RM) -f */*.pyc */*/*.pyc */*/*/*.pyc */*/*/*/*.pyc
41+
( cd uncompyle6 && $(RM) -f *.pyc */*.pyc )
5542

5643
#: Create source tarball
5744
sdist:

README.rst

Lines changed: 53 additions & 44 deletions

test/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PHONY=check clean dist distclean test test-unit test-functional rmChangeLog clean_pyc nosetests
2+
3+
GIT2CL ?= git2cl
4+
PYTHON ?= python
5+
6+
# Set COMILE='--compile' to force compilation before check
7+
COMPILE ?=
8+
9+
#: Run all tests
10+
check: check-short check-2.7-ok
11+
12+
#: Run quick tests
13+
check-short:
14+
$(PYTHON) test_pythonlib.py --base2 --verify $(COMPILE)
15+
16+
#: Run longer Python 2.7's lib files known to be okay
17+
check-2.7-ok:
18+
$(PYTHON) test_pythonlib.py --ok-2.7 --verify $(COMPILE)
19+
20+
clean:
21+
find . -name '*_dis' -exec rm -v '{}' ';'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python
2+
from __future__ import print_function
3+
4+
"""
5+
compile_tests -- compile test patterns for the decompyle test suite
6+
"""
7+
8+
import py_compile, os, sys, getopt
9+
10+
work_dir = os.path.dirname(sys.argv[0])
11+
src_dir = work_dir
12+
13+
opts, args = getopt.getopt(sys.argv[1:], 's:w:')
14+
15+
for opt, val in opts:
16+
if opt == '-s':
17+
src_dir = val
18+
if opt == '-w':
19+
work_dir = val
20+
else:
21+
raise "Unknown Option '%s'" % opt
22+
if args:
23+
raise 'This tool does not want any arguments'
24+
25+
print("Using files in dir %s" % src_dir)
26+
print("Compiling into dir %s" % work_dir)
27+
28+
tests = {}
29+
30+
tests['1.5'] = ["class", "del", "docstring", 'empty', "exec",
31+
"exceptions", "expressions", "functions", "global",
32+
"globals", "import", "integers", "lambda", "loops",
33+
"misc", "nested_elif", "prettyprint", "print",
34+
'single_stmt', "slices", "tuple_params", 'tuples']
35+
36+
tests['1.6'] = ["applyEquiv", ] + tests['1.5']
37+
38+
tests['2.0'] = ["augmentedAssign", "extendedImport", "extendedPrint",
39+
"import_as", "listComprehensions", 'print_to'] + \
40+
tests['1.6'] # [ "--extendedarg", ]
41+
42+
tests['2.1'] = ['loops2', 'nested_scopes'] + tests['2.0']
43+
44+
tests['2.2'] = ['divide_future', 'divide_no_future', 'iterators',
45+
'yield'] + tests['2.1']
46+
47+
tests['2.3'] = tests['2.2']
48+
tests['2.5'] = tests['2.3']
49+
tests['2.6'] = tests['2.5']
50+
tests['2.7'] = ['mine'] + tests['2.6']
51+
tests['3.4'] = ['mine']
52+
total_tests = len(tests['2.7'])
53+
#tests['2.2'].sort(); print tests['2.2']
54+
55+
extension = '.py' + (__debug__ and 'c' or 'o')
56+
57+
def compile(file, target_dir):
58+
sfile = os.path.join(src_dir, 'test_%s.py' % file)
59+
cfile = os.path.join(target_dir, 'test_%s%s' % (file, extension) )
60+
py_compile.compile(sfile, cfile=cfile)
61+
62+
def compile_for_version(version):
63+
target_dir = os.path.join(work_dir, 'bytecode_' + version)
64+
if not os.path.exists(target_dir):
65+
os.mkdir(target_dir)
66+
for file in tests[version]:
67+
compile(file, target_dir)
68+
69+
try:
70+
version = '%i.%i' % sys.version_info[:2]
71+
except AttributeError:
72+
version = sys.version[:3]
73+
74+
print('Compiling test files for Python', version)
75+
print('(%i/%i files)' % (len(tests[version]), total_tests))
76+
compile_for_version(version)
77+
print('Done.')
File renamed without changes.
1.08 KB
Binary file not shown.
File renamed without changes.
1.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)
X Tutup