blob: 0ffb3ed454eda07eb1ac32e94ad33d213e661d31 [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
Christian Heimesb186d002008-03-18 15:15:01 +00009import os
Christian Heimesb186d002008-03-18 15:15:01 +000010import sys
Victor Stinner3aac0ad2016-03-24 17:53:20 +010011from test.libregrtest import main
Chris Jerdonek517e9252013-02-27 09:02:53 -080012
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000013
Victor Stinner3aac0ad2016-03-24 17:53:20 +010014# Alias for backward compatibility (just in case)
15main_in_temp_cwd = main
Victor Stinner4ffcc3e2016-03-24 17:43:53 +010016
17
18def _main():
19 global __file__
20
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000021 # Remove regrtest.py's own directory from the module search path. Despite
22 # the elimination of implicit relative imports, this is still needed to
23 # ensure that submodules of the test package do not inappropriately appear
24 # as top-level modules even when people (or buildbots!) invoke regrtest.py
25 # directly instead of using the -m switch
26 mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
Victor Stinner4ffcc3e2016-03-24 17:43:53 +010027 i = len(sys.path) - 1
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000028 while i >= 0:
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000029 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
30 del sys.path[i]
Victor Stinner4ffcc3e2016-03-24 17:43:53 +010031 else:
32 i -= 1
Nick Coghlan4c4c0f22010-12-03 07:44:33 +000033
Florent Xiclunadc69e722010-09-13 16:35:02 +000034 # findtestdir() gets the dirname out of __file__, so we have to make it
35 # absolute before changing the working directory.
36 # For example __file__ may be relative when running trace or profile.
37 # See issue #9323.
38 __file__ = os.path.abspath(__file__)
39
40 # sanity check
Florent Xiclunada7bfd52010-03-06 11:43:55 +000041 assert __file__ == os.path.abspath(sys.argv[0])
Ezio Melotti184bdfb2010-02-18 09:37:05 +000042
Victor Stinner4ffcc3e2016-03-24 17:43:53 +010043 main()
44
45
46if __name__ == '__main__':
47 _main()