blob: fcc39375c031aa84eee919c7439cee277b60a00e [file] [log] [blame]
Benjamin Peterson90f5ba52010-03-11 22:53:45 +00001#! /usr/bin/env python3
Guido van Rossum152494a1996-12-20 03:12:20 +00002
R. David Murray0ba81e02010-04-26 17:02:32 +00003"""
Chris Jerdonekd6c18dc2012-12-27 18:53:12 -08004Script to run Python regression tests.
Guido van Rossum152494a1996-12-20 03:12:20 +00005
Chris Jerdonekd6c18dc2012-12-27 18:53:12 -08006Run this script with -h or --help for documentation.
7"""
8
Nick Coghlanbe7e49f2012-07-20 23:40:09 +10009# We import importlib *ASAP* in order to test #15386
10import importlib
11
Christian Heimesb186d002008-03-18 15:15:01 +000012import os
Christian Heimesb186d002008-03-18 15:15:01 +000013import sys
Victor Stinner36b3fbb2015-09-27 11:19:08 +020014from test.libregrtest import main, main_in_temp_cwd
Chris Jerdonek517e9252013-02-27 09:02:53 -080015
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000016
Guido van Rossum152494a1996-12-20 03:12:20 +000017if __name__ == '__main__':
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000018 # 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 Xiclunadc69e722010-09-13 16:35:02 +000030 # 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 Xiclunada7bfd52010-03-06 11:43:55 +000037 assert __file__ == os.path.abspath(sys.argv[0])
Ezio Melotti184bdfb2010-02-18 09:37:05 +000038
Chris Jerdonek517e9252013-02-27 09:02:53 -080039 main_in_temp_cwd()