Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
4a690b37
Commit
4a690b37
authored
Mar 03, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #344 from rntz/tester-explicit-failure
Add should_error directive, for tests that should exit non-0
parents
ede5dbc3
bd4a04ce
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
131 additions
and
32 deletions
+131
-32
src/runtime/import.cpp
src/runtime/import.cpp
+1
-0
test/tests/21.py
test/tests/21.py
+2
-0
test/tests/22.py
test/tests/22.py
+1
-1
test/tests/23.py
test/tests/23.py
+1
-0
test/tests/24.py
test/tests/24.py
+1
-0
test/tests/39.py
test/tests/39.py
+1
-0
test/tests/40.py
test/tests/40.py
+1
-0
test/tests/46.py
test/tests/46.py
+4
-1
test/tests/48.py
test/tests/48.py
+1
-0
test/tests/49.py
test/tests/49.py
+4
-1
test/tests/60.py
test/tests/60.py
+8
-2
test/tests/66.py
test/tests/66.py
+1
-0
test/tests/69.py
test/tests/69.py
+1
-0
test/tests/75.py
test/tests/75.py
+1
-0
test/tests/assert.py
test/tests/assert.py
+1
-0
test/tests/augassign_analysis.py
test/tests/augassign_analysis.py
+4
-1
test/tests/augassign_reverse.py
test/tests/augassign_reverse.py
+4
-1
test/tests/basestring.py
test/tests/basestring.py
+4
-1
test/tests/break_outside_loop.py
test/tests/break_outside_loop.py
+1
-0
test/tests/capi_slots.py
test/tests/capi_slots.py
+4
-1
test/tests/class_noctor.py
test/tests/class_noctor.py
+1
-0
test/tests/closure_name_error.py
test/tests/closure_name_error.py
+4
-2
test/tests/continue_outside_loop.py
test/tests/continue_outside_loop.py
+1
-0
test/tests/control_flow.py
test/tests/control_flow.py
+4
-1
test/tests/data_descriptors.py
test/tests/data_descriptors.py
+2
-2
test/tests/del_name_scoping.py
test/tests/del_name_scoping.py
+4
-1
test/tests/exceptions_nonreprable.py
test/tests/exceptions_nonreprable.py
+3
-2
test/tests/expr_evaluation_order.py
test/tests/expr_evaluation_order.py
+4
-1
test/tests/future_non_existent.py
test/tests/future_non_existent.py
+1
-0
test/tests/future_not_at_beginning.py
test/tests/future_not_at_beginning.py
+2
-0
test/tests/future_not_at_beginning2.py
test/tests/future_not_at_beginning2.py
+2
-0
test/tests/getattr.py
test/tests/getattr.py
+4
-1
test/tests/getattr_nonstring.py
test/tests/getattr_nonstring.py
+1
-0
test/tests/getitem.py
test/tests/getitem.py
+4
-1
test/tests/globals.py
test/tests/globals.py
+4
-1
test/tests/init_must_return_none.py
test/tests/init_must_return_none.py
+1
-0
test/tests/listcomp_assigning.py
test/tests/listcomp_assigning.py
+4
-2
test/tests/object_new_arguments.py
test/tests/object_new_arguments.py
+1
-0
test/tests/resource_test.py
test/tests/resource_test.py
+1
-1
test/tests/return_in_class.py
test/tests/return_in_class.py
+1
-0
test/tests/return_outside_func.py
test/tests/return_outside_func.py
+1
-0
test/tests/setitem.py
test/tests/setitem.py
+4
-1
test/tests/sys_excinfo.py
test/tests/sys_excinfo.py
+1
-0
test/tests/tuple_unpacking_invalid.py
test/tests/tuple_unpacking_invalid.py
+1
-0
test/tests/varargs_protocol.py
test/tests/varargs_protocol.py
+4
-1
tools/tester.py
tools/tester.py
+25
-6
No files found.
src/runtime/import.cpp
View file @
4a690b37
...
...
@@ -149,6 +149,7 @@ static Box* importSub(const std::string& name, const std::string& full_name, Box
return
module
;
}
// TODO: these are a crude hack to help our tests, find a better way
if
(
name
==
"basic_test"
)
return
importTestExtension
(
"basic_test"
);
if
(
name
==
"descr_test"
)
...
...
test/tests/21.py
View file @
4a690b37
# should_error
# Expected failure: even though we could copy the "definedness" information in the assignment,
# that's actually an error.
...
...
test/tests/22.py
View file @
4a690b37
# should_error
# Expected failure: stacktrace testing
print
5
%
0
test/tests/23.py
View file @
4a690b37
# should_error
not_defined
test/tests/24.py
View file @
4a690b37
# should_error
# Expected failure: adding things that can't be added
1
+
""
test/tests/39.py
View file @
4a690b37
# should_error
int
.
a
=
1
test/tests/40.py
View file @
4a690b37
# should_error
i
=
0
i
.
a
=
0
test/tests/46.py
View file @
4a690b37
...
...
@@ -15,4 +15,7 @@ print C.b
print
C
.
a
print
o
.
c
print
o
.
b
print
o
.
a
# this should error
try
:
print
o
.
a
except
AttributeError
,
e
:
print
e
test/tests/48.py
View file @
4a690b37
# should_error
# This should raise a python level error, not an assertion in the compiler
x
=
1
...
...
test/tests/49.py
View file @
4a690b37
# This should raise a python level error, not an assertion in the compiler
print
int
.
doesnt_exist
try
:
print
int
.
doesnt_exist
except
AttributeError
,
e
:
print
e
test/tests/60.py
View file @
4a690b37
...
...
@@ -22,5 +22,11 @@ class C(object):
return
self
.
n
print
len
(
C
(
1
))
print
len
(
1
)
print
len
(
C
(
"hello world"
))
try
:
print
len
(
1
)
except
TypeError
,
e
:
print
e
try
:
print
len
(
C
(
"hello world"
))
except
TypeError
,
e
:
print
e
test/tests/66.py
View file @
4a690b37
# should_error
# Make sure that overriding __file__ doesn't change the traceback
# TODO the tester doesn't currently check the traceback
...
...
test/tests/69.py
View file @
4a690b37
# should_error
class
C
(
object
):
pass
...
...
test/tests/75.py
View file @
4a690b37
# should_error
def
f
():
if
0
:
str
=
0
...
...
test/tests/assert.py
View file @
4a690b37
# should_error
def
msg
():
print
"msg()"
return
"failure message"
...
...
test/tests/augassign_analysis.py
View file @
4a690b37
...
...
@@ -114,4 +114,7 @@ def f10():
# This should error: the lhs is evaluated first
x
+=
[
x
for
x
in
xrange
(
5
)][
0
]
print
x
f10
()
try
:
f10
()
except
UnboundLocalError
,
e
:
print
e
test/tests/augassign_reverse.py
View file @
4a690b37
...
...
@@ -9,5 +9,8 @@ def f():
# Augassigns can change the type of the variable:
i
+=
IntLike
()
print
i
i
+
1
try
:
i
+
1
except
TypeError
,
e
:
print
e
f
()
test/tests/basestring.py
View file @
4a690b37
...
...
@@ -4,4 +4,7 @@ print isinstance(3, basestring)
print
basestring
.
__doc__
# should raise an exception
t
=
basestring
.
__new__
(
basestring
)
try
:
t
=
basestring
.
__new__
(
basestring
)
except
TypeError
,
e
:
print
e
test/tests/break_outside_loop.py
View file @
4a690b37
# should_error
break
test/tests/capi_slots.py
View file @
4a690b37
...
...
@@ -157,4 +157,7 @@ try:
except
SystemError
,
e
:
print
e
print
c
.
foo
()
try
:
print
c
.
foo
()
except
SystemError
,
e
:
print
e
test/tests/class_noctor.py
View file @
4a690b37
# should_error
# skip-if: sys.version_info < (2, 7, 4)
# - Error message changed in 2.7.4
...
...
test/tests/closure_name_error.py
View file @
4a690b37
...
...
@@ -6,5 +6,7 @@ def bad_addr3(_x):
def
g
(
y3
):
return
x3
+
y3
return
g
print
bad_addr3
(
1
)(
2
)
try
:
print
bad_addr3
(
1
)(
2
)
except
NameError
,
e
:
print
e
test/tests/continue_outside_loop.py
View file @
4a690b37
# should_error
continue
test/tests/control_flow.py
View file @
4a690b37
...
...
@@ -5,4 +5,7 @@ def _escape():
if
code
:
return
code
_escape
()
try
:
_escape
()
except
NameError
,
e
:
print
e
test/tests/data_descriptors.py
View file @
4a690b37
...
...
@@ -34,8 +34,8 @@ C.ndd = 7
#TODO it would be nice to print these out (once __dict__ is implemented)
#print C.__dict__['dd']
#print C.__dict__['ndd']
print
c
.
dd
print
c
.
ndd
print
C
.
dd
print
C
.
ndd
# Repeat all of the above for subclasses of the descriptors
...
...
test/tests/del_name_scoping.py
View file @
4a690b37
...
...
@@ -4,4 +4,7 @@ def f():
# the del marks 'x' as a name written to in this scope
del
x
print
x
f
()
try
:
f
()
except
NameError
,
e
:
print
e
test/tests/exceptions_nonreprable.py
View file @
4a690b37
# should_error
class
BadException
(
Exception
):
def
__str__
(
self
):
print
"str"
...
...
@@ -7,7 +8,7 @@ try:
# This will raise:
print
BadException
()
assert
0
except
NotImplementedError
:
p
ass
except
NotImplementedError
,
e
:
p
rint
e
raise
BadException
()
test/tests/expr_evaluation_order.py
View file @
4a690b37
...
...
@@ -18,4 +18,7 @@ def f2(y):
return
x
return
y
print
g2
(
f2
(
2
))
try
:
print
g2
(
f2
(
2
))
except
NameError
,
e
:
print
e
test/tests/future_non_existent.py
View file @
4a690b37
# should_error
from
__future__
import
rvalue_references
# should cause syntax error
test/tests/future_not_at_beginning.py
View file @
4a690b37
# should_error
"docstring"
"not a docstring"
...
...
test/tests/future_not_at_beginning2.py
View file @
4a690b37
# should_error
"docstring"
def
f
():
...
...
test/tests/getattr.py
View file @
4a690b37
...
...
@@ -2,4 +2,7 @@ l = range(5)
print
getattr
(
l
,
"pop"
)()
print
getattr
([],
"a"
,
"default"
)
print
getattr
([],
"a"
)
try
:
print
getattr
([],
"a"
)
except
AttributeError
,
e
:
print
e
test/tests/getattr_nonstring.py
View file @
4a690b37
# should_error
print
getattr
([],
[])
test/tests/getitem.py
View file @
4a690b37
...
...
@@ -21,4 +21,7 @@ c = C()
c
.
__getitem__
=
gi
print
c
[
1
]
print
1
[
1
]
try
:
print
1
[
1
]
except
TypeError
,
e
:
print
e
test/tests/globals.py
View file @
4a690b37
...
...
@@ -4,7 +4,10 @@ def f():
print
True
# builtin, redefined
print
False
# builtin, not redefined
print
z
# local
print
y
# non-builtin, not defined
try
:
print
y
# non-builtin, not defined
except
NameError
,
e
:
print
e
x
=
2
z
=
2
...
...
test/tests/init_must_return_none.py
View file @
4a690b37
# should_error
# As the test filename says, init functions must return None.
# This file tests that; it also makes sure that it gets tested
# when in a patchpoint.
...
...
test/tests/listcomp_assigning.py
View file @
4a690b37
...
...
@@ -40,5 +40,7 @@ def f2(n, b):
f2
(
5
,
0
)
print
i
f2
(
0
,
1
)
f2
(
0
,
0
)
try
:
f2
(
0
,
0
)
except
UnboundLocalError
,
e
:
print
e
test/tests/object_new_arguments.py
View file @
4a690b37
# should_error
# skip-if: sys.version_info < (2, 7, 4)
# - Error message changed in 2.7.4
...
...
test/tests/resource_test.py
View file @
4a690b37
...
...
@@ -5,7 +5,7 @@ for k in sorted(dir(resource)):
continue
print
k
,
getattr
(
resource
,
k
)
TIME_LIMIT
=
100
TIME_LIMIT
=
5
resource
.
setrlimit
(
resource
.
RLIMIT_CPU
,
(
TIME_LIMIT
+
1
,
TIME_LIMIT
+
1
))
MAX_MEM_MB
=
100
...
...
test/tests/return_in_class.py
View file @
4a690b37
# should_error
class
C
(
object
):
return
test/tests/return_outside_func.py
View file @
4a690b37
# should_error
return
test/tests/setitem.py
View file @
4a690b37
...
...
@@ -17,4 +17,7 @@ def si(k, v):
c
.
__setitem__
=
si
c
[
3
]
=
4
1
[
2
]
=
3
try
:
1
[
2
]
=
3
except
TypeError
,
e
:
print
e
test/tests/sys_excinfo.py
View file @
4a690b37
# should_error
# Different ways of nesting exceptions
import
sys
...
...
test/tests/tuple_unpacking_invalid.py
View file @
4a690b37
# should_error
# Int not iterable:
a
,
b
,
c
=
1
test/tests/varargs_protocol.py
View file @
4a690b37
...
...
@@ -17,4 +17,7 @@ class C(object):
def
f
(
a
,
b
,
c
):
print
a
,
b
,
c
f
(
*
C
())
try
:
f
(
*
C
())
except
TypeError
,
e
:
print
e
tools/tester.py
View file @
4a690b37
...
...
@@ -126,6 +126,7 @@ def run_test(fn, check_stats, run_memcheck):
jit_args
=
[
"-rq"
]
+
EXTRA_JIT_ARGS
collect_stats
=
True
expected
=
"success"
should_error
=
False
allow_warnings
=
[]
for
l
in
open
(
fn
):
l
=
l
.
strip
()
...
...
@@ -141,6 +142,8 @@ def run_test(fn, check_stats, run_memcheck):
jit_args
+=
l
elif
l
.
startswith
(
"# expected:"
):
expected
=
l
[
len
(
"# expected:"
):].
strip
()
elif
l
.
startswith
(
"# should_error"
):
should_error
=
True
elif
l
.
startswith
(
"# fail-if:"
):
condition
=
l
.
split
(
':'
,
1
)[
1
].
strip
()
if
eval
(
condition
):
...
...
@@ -216,13 +219,29 @@ def run_test(fn, check_stats, run_memcheck):
if
expected
==
"fail"
:
r
+=
" Expected failure (got code %d, should be %d)"
%
(
code
,
expected_code
)
return
r
elif
KEEP_GOING
:
r
+=
"
\
033
[%dmFAILED
\
033
[0m (%s)"
%
(
color
,
msg
)
failed
.
append
(
fn
)
return
r
else
:
if
KEEP_GOING
:
r
+=
"
\
033
[%dmFAILED
\
033
[0m (%s)"
%
(
color
,
msg
)
failed
.
append
(
fn
)
return
r
else
:
raise
Exception
(
"%s
\
n
%s
\
n
%s"
%
(
msg
,
err
,
stderr
))
raise
Exception
(
"%s
\
n
%s
\
n
%s"
%
(
msg
,
err
,
stderr
))
elif
should_error
==
(
code
==
0
):
color
=
31
# red
if
code
==
0
:
msg
=
"Exited successfully; remove '# should_error' if this is expected"
else
:
msg
=
"Exited with code %d; add '# should_error' if this is expected"
%
code
if
KEEP_GOING
:
r
+=
"
\
033
[%dmFAILED
\
033
[0m (%s)"
%
(
color
,
msg
)
failed
.
append
(
fn
)
return
r
else
:
# show last line of stderr so we have some idea went wrong
print
"Last line of stderr: "
+
last_stderr_line
raise
Exception
(
msg
)
elif
out
!=
expected_out
:
if
expected
==
"fail"
:
r
+=
" Expected failure (bad output)"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment