Commit 108183fc authored by stijn's avatar stijn Committed by Damien George

tests/misc/sys_settrace: Make test output independent of invoked path.

The original logic of reducing a full path to a relative one assumes
"tests/misc" is in the filename which is limited in usage: it never works
for CPython on Windows since that will use a backslash as path separator,
and also won't work when the filename is a path not relative to the tests
directory which happens for example in the common case of running
"./run-tests -d misc".

Fix all cases by printing only the bare filename, which requires them all
to start with sys_settrace_ hence the renaming.
parent 505a1853
......@@ -20,8 +20,8 @@ def print_stacktrace(frame, level=0):
" ",
frame.f_globals["__name__"],
frame.f_code.co_name,
# reduce full path to some pseudo-relative
"misc" + "".join(frame.f_code.co_filename.split("tests/misc")[-1:]),
# Keep just the filename.
"sys_settrace_" + frame.f_code.co_filename.split("sys_settrace_")[-1],
frame.f_lineno,
)
)
......@@ -95,9 +95,9 @@ def do_tests():
print("Who loves the sun?")
print("Not every-", factorial(3))
from sys_settrace_subdir import trace_generic
from sys_settrace_subdir import sys_settrace_generic
trace_generic.run_tests()
sys_settrace_generic.run_tests()
return
......
......@@ -17,8 +17,8 @@ def print_stacktrace(frame, level=0):
" ",
frame.f_globals["__name__"],
frame.f_code.co_name,
# reduce full path to some pseudo-relative
"misc" + "".join(frame.f_code.co_filename.split("tests/misc")[-1:]),
# Keep just the filename.
"sys_settrace_" + frame.f_code.co_filename.split("sys_settrace_")[-1],
frame.f_lineno,
)
)
......
This diff is collapsed.
......@@ -17,8 +17,8 @@ def print_stacktrace(frame, level=0):
" ",
frame.f_globals["__name__"],
frame.f_code.co_name,
# reduce full path to some pseudo-relative
"misc" + "".join(frame.f_code.co_filename.split("tests/misc")[-1:]),
# Keep just the filename.
"sys_settrace_" + frame.f_code.co_filename.split("sys_settrace_")[-1],
frame.f_lineno,
)
)
......
### trace_handler::main event: call
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:41
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:41
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:43
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:43
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:44
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:44
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:45
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:45
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:44
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:44
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:45
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:45
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:44
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:44
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:45
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:45
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:44
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:44
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:45
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:45
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:46
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:46
1: @__main__:<module> => sys_settrace_loop.py:58
test_for_loop 3
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:49
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:49
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:50
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:50
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:51
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:51
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:53
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:53
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:52
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:52
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:53
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:53
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:52
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:52
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:53
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:53
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:52
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:52
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:53
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:53
1: @__main__:<module> => sys_settrace_loop.py:58
### trace_handler::main event: line
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:54
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:54
1: @__main__:<module> => sys_settrace_loop.py:58
test_while_loop 3
### trace_handler::main event: return
0: @__main__:test_loop => miscmisc/sys_settrace_loop.py:54
1: @__main__:<module> => miscmisc/sys_settrace_loop.py:58
0: @__main__:test_loop => sys_settrace_loop.py:54
1: @__main__:<module> => sys_settrace_loop.py:58
Total traces executed: 23
......@@ -41,10 +41,10 @@ def test_lambda():
# import
def test_import():
from sys_settrace_subdir import trace_importme
from sys_settrace_subdir import sys_settrace_importme
trace_importme.dummy()
trace_importme.saysomething()
sys_settrace_importme.dummy()
sys_settrace_importme.saysomething()
# class
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment