Benjamin Peterson | 90f5ba5 | 2010-03-11 22:53:45 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python3 |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 2 | |
R. David Murray | 0ba81e0 | 2010-04-26 17:02:32 +0000 | [diff] [blame] | 3 | """ |
Chris Jerdonek | d6c18dc | 2012-12-27 18:53:12 -0800 | [diff] [blame] | 4 | Script to run Python regression tests. |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 5 | |
Chris Jerdonek | d6c18dc | 2012-12-27 18:53:12 -0800 | [diff] [blame] | 6 | Run this script with -h or --help for documentation. |
| 7 | """ |
| 8 | |
Nick Coghlan | be7e49f | 2012-07-20 23:40:09 +1000 | [diff] [blame] | 9 | # We import importlib *ASAP* in order to test #15386 |
| 10 | import importlib |
| 11 | |
Christian Heimes | b186d00 | 2008-03-18 15:15:01 +0000 | [diff] [blame] | 12 | import os |
Christian Heimes | b186d00 | 2008-03-18 15:15:01 +0000 | [diff] [blame] | 13 | import sys |
Victor Stinner | 36b3fbb | 2015-09-27 11:19:08 +0200 | [diff] [blame] | 14 | from test.libregrtest import main, main_in_temp_cwd |
Chris Jerdonek | 517e925 | 2013-02-27 09:02:53 -0800 | [diff] [blame] | 15 | |
Nick Coghlan | 4c4c0f2 | 2010-12-03 07:44:33 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 17 | if __name__ == '__main__': |
Nick Coghlan | 4c4c0f2 | 2010-12-03 07:44:33 +0000 | [diff] [blame] | 18 | # Remove regrtest.py's own directory from the module search path. Despite |
| 19 | # the elimination of implicit relative imports, this is still needed to |
| 20 | # ensure that submodules of the test package do not inappropriately appear |
| 21 | # as top-level modules even when people (or buildbots!) invoke regrtest.py |
| 22 | # directly instead of using the -m switch |
| 23 | mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) |
| 24 | i = len(sys.path) |
| 25 | while i >= 0: |
| 26 | i -= 1 |
| 27 | if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: |
| 28 | del sys.path[i] |
| 29 | |
Florent Xicluna | dc69e72 | 2010-09-13 16:35:02 +0000 | [diff] [blame] | 30 | # findtestdir() gets the dirname out of __file__, so we have to make it |
| 31 | # absolute before changing the working directory. |
| 32 | # For example __file__ may be relative when running trace or profile. |
| 33 | # See issue #9323. |
| 34 | __file__ = os.path.abspath(__file__) |
| 35 | |
| 36 | # sanity check |
Florent Xicluna | da7bfd5 | 2010-03-06 11:43:55 +0000 | [diff] [blame] | 37 | assert __file__ == os.path.abspath(sys.argv[0]) |
Ezio Melotti | 184bdfb | 2010-02-18 09:37:05 +0000 | [diff] [blame] | 38 | |
Chris Jerdonek | 517e925 | 2013-02-27 09:02:53 -0800 | [diff] [blame] | 39 | main_in_temp_cwd() |