Change method of loading .py files in Python tests
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 26 Jan 2017 21:12:12 +0000 (16:12 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Thu, 26 Jan 2017 21:12:12 +0000 (16:12 -0500)
commit72ca04104418e4926790872a203f404af9453024
treee1315a30ae264a92846f1c92b83ecb7b9b15df71
parente3ceef3544fb2178cef284b5fb8b267bf0ab4397
Change method of loading .py files in Python tests

With my debug build of Python (--with-pydebug), many tests fails because
of the same issue.  Python scripts are loaded by the tests using this
pattern:

  (gdb) python exec (open ('file.py').read ())

This causes Python to output this warning:

  __main__:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='file.py' mode='r' encoding='ANSI_X3.4-1968'>

and the test to fail because of that extra output.  Instead of using the
open + read + exec trick which leaks the file and causes the warning,
why not just source the files?

  (gdb) source file.py

This patch changes this, and standardizes the test names of the tests I
touched to "load python file" (some of them were empty, others were
overly complicated).

gdb/testsuite/ChangeLog:

* gdb.python/py-bad-printers.exp: Load python file using "source".
* gdb.python/py-events.exp: Likewise.
* gdb.python/py-evsignal.exp: Likewise.
* gdb.python/py-evthreads.exp: Likewise.
* gdb.python/py-frame-args.exp: Likewise.
* gdb.python/py-framefilter-invalidarg.exp: Likewise.
* gdb.python/py-framefilter-mi.exp: Likewise.
* gdb.python/py-framefilter.exp: Likewise.
* gdb.python/py-mi.exp: Likewise.
* gdb.python/py-pp-maint.exp: Likewise.
* gdb.python/py-pp-registration.exp: Likewise.
* gdb.python/py-prettyprint.exp: Likewise.
(run_lang_tests): Likewise.
* gdb.python/py-typeprint.exp: Likewise.
14 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-bad-printers.exp
gdb/testsuite/gdb.python/py-events.exp
gdb/testsuite/gdb.python/py-evsignal.exp
gdb/testsuite/gdb.python/py-evthreads.exp
gdb/testsuite/gdb.python/py-frame-args.exp
gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
gdb/testsuite/gdb.python/py-framefilter-mi.exp
gdb/testsuite/gdb.python/py-framefilter.exp
gdb/testsuite/gdb.python/py-mi.exp
gdb/testsuite/gdb.python/py-pp-maint.exp
gdb/testsuite/gdb.python/py-pp-registration.exp
gdb/testsuite/gdb.python/py-prettyprint.exp
gdb/testsuite/gdb.python/py-typeprint.exp
This page took 0.027463 seconds and 4 git commands to generate.